mirror of
https://github.com/rommapp/romm.git
synced 2026-11-29 01:58:41 +01:00
Merge branch 'master' into misc/move-fakeredis-to-test-dependency
This commit is contained in:
@@ -12,7 +12,7 @@ from models.rom import Rom
|
||||
from pydantic import BaseModel, Field, computed_field
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
SORT_COMPARE_REGEX = r"^([Tt]he|[Aa]|[Aa]nd)\s"
|
||||
SORT_COMPARE_REGEX = re.compile(r"^([Tt]he|[Aa]|[Aa]nd)\s")
|
||||
|
||||
RomIGDBMetadata = TypedDict( # type: ignore[misc]
|
||||
"RomIGDBMetadata",
|
||||
@@ -101,8 +101,7 @@ class RomSchema(BaseModel):
|
||||
@property
|
||||
def sort_comparator(self) -> str:
|
||||
return (
|
||||
re.sub(
|
||||
SORT_COMPARE_REGEX,
|
||||
SORT_COMPARE_REGEX.sub(
|
||||
"",
|
||||
self.name or self.file_name_no_tags,
|
||||
)
|
||||
|
||||
@@ -5,8 +5,8 @@ from enum import Enum
|
||||
|
||||
from config.config_manager import config_manager as cm
|
||||
|
||||
TAG_REGEX = r"\(([^)]+)\)|\[([^]]+)\]"
|
||||
EXTENSION_REGEX = r"\.(([a-z]+\.)*\w+)$"
|
||||
TAG_REGEX = re.compile(r"\(([^)]+)\)|\[([^]]+)\]")
|
||||
EXTENSION_REGEX = re.compile(r"\.(([a-z]+\.)*\w+)$")
|
||||
|
||||
LANGUAGES = [
|
||||
("Ar", "Arabic"),
|
||||
@@ -95,14 +95,14 @@ class FSHandler:
|
||||
)
|
||||
|
||||
def get_file_name_with_no_extension(self, file_name: str) -> str:
|
||||
return re.sub(EXTENSION_REGEX, "", file_name).strip()
|
||||
return EXTENSION_REGEX.sub("", file_name).strip()
|
||||
|
||||
def get_file_name_with_no_tags(self, file_name: str) -> str:
|
||||
file_name_no_extension = self.get_file_name_with_no_extension(file_name)
|
||||
return re.split(TAG_REGEX, file_name_no_extension)[0].strip()
|
||||
return TAG_REGEX.split(file_name_no_extension)[0].strip()
|
||||
|
||||
def parse_file_extension(self, file_name) -> str:
|
||||
match = re.search(EXTENSION_REGEX, file_name)
|
||||
match = EXTENSION_REGEX.search(file_name)
|
||||
return match.group(1) if match else ""
|
||||
|
||||
def _exclude_files(self, files, filetype) -> list[str]:
|
||||
|
||||
@@ -33,7 +33,7 @@ class FSRomsHandler(FSHandler):
|
||||
regs = []
|
||||
langs = []
|
||||
other_tags = []
|
||||
tags = [tag[0] or tag[1] for tag in re.findall(TAG_REGEX, file_name)]
|
||||
tags = [tag[0] or tag[1] for tag in TAG_REGEX.findall(file_name)]
|
||||
tags = [tag for subtags in tags for tag in subtags.split(",")]
|
||||
tags = [tag.strip() for tag in tags]
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@ def conditionally_set_cache(
|
||||
|
||||
|
||||
# These are loaded in cache in update_switch_titledb_task
|
||||
SWITCH_TITLEDB_REGEX: Final = r"(70[0-9]{12})"
|
||||
SWITCH_PRODUCT_ID_REGEX: Final = r"(0100[0-9A-F]{12})"
|
||||
SWITCH_TITLEDB_REGEX: Final = re.compile(r"(70[0-9]{12})")
|
||||
SWITCH_PRODUCT_ID_REGEX: Final = re.compile(r"(0100[0-9A-F]{12})")
|
||||
|
||||
|
||||
# No regex needed for MAME
|
||||
@@ -33,12 +33,12 @@ MAME_XML_KEY: Final = "romm:mame_xml"
|
||||
conditionally_set_cache(MAME_XML_KEY, "mame_index.json")
|
||||
|
||||
# PS2 OPL
|
||||
PS2_OPL_REGEX: Final = r"^([A-Z]{4}_\d{3}\.\d{2})\..*$"
|
||||
PS2_OPL_REGEX: Final = re.compile(r"^([A-Z]{4}_\d{3}\.\d{2})\..*$")
|
||||
PS2_OPL_KEY: Final = "romm:ps2_opl_index"
|
||||
conditionally_set_cache(PS2_OPL_KEY, "ps2_opl_index.json")
|
||||
|
||||
# Sony serial codes for PS1, PS2, and PSP
|
||||
SONY_SERIAL_REGEX: Final = r".*([a-zA-Z]{4}-\d{5}).*$"
|
||||
SONY_SERIAL_REGEX: Final = re.compile(r".*([a-zA-Z]{4}-\d{5}).*$")
|
||||
|
||||
PS1_SERIAL_INDEX_KEY: Final = "romm:ps1_serial_index"
|
||||
conditionally_set_cache(PS1_SERIAL_INDEX_KEY, "ps1_serial_index.json")
|
||||
|
||||
@@ -341,13 +341,13 @@ class IGDBBaseHandler(MetadataHandler):
|
||||
fallback_rom = IGDBRom(igdb_id=None)
|
||||
|
||||
# Support for PS2 OPL filename format
|
||||
match = re.match(PS2_OPL_REGEX, file_name)
|
||||
match = PS2_OPL_REGEX.match(file_name)
|
||||
if platform_igdb_id == PS2_IGDB_ID and match:
|
||||
search_term = await self._ps2_opl_format(match, search_term)
|
||||
fallback_rom = IGDBRom(igdb_id=None, name=search_term)
|
||||
|
||||
# Support for sony serial filename format (PS, PS3, PS3)
|
||||
match = re.search(SONY_SERIAL_REGEX, file_name, re.IGNORECASE)
|
||||
match = SONY_SERIAL_REGEX.search(file_name, re.IGNORECASE)
|
||||
if platform_igdb_id == PS1_IGDB_ID and match:
|
||||
search_term = await self._ps1_serial_format(match, search_term)
|
||||
fallback_rom = IGDBRom(igdb_id=None, name=search_term)
|
||||
@@ -361,7 +361,7 @@ class IGDBBaseHandler(MetadataHandler):
|
||||
fallback_rom = IGDBRom(igdb_id=None, name=search_term)
|
||||
|
||||
# Support for switch titleID filename format
|
||||
match = re.search(SWITCH_TITLEDB_REGEX, file_name)
|
||||
match = SWITCH_TITLEDB_REGEX.search(file_name)
|
||||
if platform_igdb_id == SWITCH_IGDB_ID and match:
|
||||
search_term, index_entry = await self._switch_titledb_format(
|
||||
match, search_term
|
||||
@@ -376,7 +376,7 @@ class IGDBBaseHandler(MetadataHandler):
|
||||
)
|
||||
|
||||
# Support for switch productID filename format
|
||||
match = re.search(SWITCH_PRODUCT_ID_REGEX, file_name)
|
||||
match = SWITCH_PRODUCT_ID_REGEX.search(file_name)
|
||||
if platform_igdb_id == SWITCH_IGDB_ID and match:
|
||||
search_term, index_entry = await self._switch_productid_format(
|
||||
match, search_term
|
||||
|
||||
@@ -172,13 +172,13 @@ class MobyGamesHandler(MetadataHandler):
|
||||
fallback_rom = MobyGamesRom(moby_id=None)
|
||||
|
||||
# Support for PS2 OPL filename format
|
||||
match = re.match(PS2_OPL_REGEX, file_name)
|
||||
match = PS2_OPL_REGEX.match(file_name)
|
||||
if platform_moby_id == PS2_MOBY_ID and match:
|
||||
search_term = await self._ps2_opl_format(match, search_term)
|
||||
fallback_rom = MobyGamesRom(moby_id=None, name=search_term)
|
||||
|
||||
# Support for sony serial filename format (PS, PS3, PS3)
|
||||
match = re.search(SONY_SERIAL_REGEX, file_name, re.IGNORECASE)
|
||||
match = SONY_SERIAL_REGEX.search(file_name, re.IGNORECASE)
|
||||
if platform_moby_id == PS1_MOBY_ID and match:
|
||||
search_term = await self._ps1_serial_format(match, search_term)
|
||||
fallback_rom = MobyGamesRom(moby_id=None, name=search_term)
|
||||
@@ -192,7 +192,7 @@ class MobyGamesHandler(MetadataHandler):
|
||||
fallback_rom = MobyGamesRom(moby_id=None, name=search_term)
|
||||
|
||||
# Support for switch titleID filename format
|
||||
match = re.search(SWITCH_TITLEDB_REGEX, file_name)
|
||||
match = SWITCH_TITLEDB_REGEX.search(file_name)
|
||||
if platform_moby_id == SWITCH_MOBY_ID and match:
|
||||
search_term, index_entry = await self._switch_titledb_format(
|
||||
match, search_term
|
||||
@@ -207,7 +207,7 @@ class MobyGamesHandler(MetadataHandler):
|
||||
)
|
||||
|
||||
# Support for switch productID filename format
|
||||
match = re.search(SWITCH_PRODUCT_ID_REGEX, file_name)
|
||||
match = SWITCH_PRODUCT_ID_REGEX.search(file_name)
|
||||
if platform_moby_id == SWITCH_MOBY_ID and match:
|
||||
search_term, index_entry = await self._switch_productid_format(
|
||||
match, search_term
|
||||
|
||||
@@ -1,11 +1,33 @@
|
||||
ARG ALPINE_VERSION=3.19
|
||||
ARG NGINX_VERSION=1.27.0
|
||||
ARG PYTHON_VERSION=3.11
|
||||
|
||||
# Build frontend
|
||||
FROM node:lts-alpine as front-build-stage
|
||||
FROM node:lts-alpine${ALPINE_VERSION} as front-build-stage
|
||||
WORKDIR /front
|
||||
COPY ./frontend ./
|
||||
RUN npm install && npm run build
|
||||
|
||||
# Build backend environment
|
||||
FROM python:${PYTHON_VERSION}-alpine${ALPINE_VERSION} AS backend-build
|
||||
|
||||
RUN apk add --no-cache \
|
||||
gcc \
|
||||
mariadb-connector-c-dev \
|
||||
musl-dev
|
||||
|
||||
RUN pip install poetry
|
||||
|
||||
ENV POETRY_NO_INTERACTION=1 \
|
||||
POETRY_VIRTUALENVS_IN_PROJECT=1
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
COPY ./pyproject.toml ./poetry.lock /src/
|
||||
RUN poetry install --no-ansi --no-cache --only main
|
||||
|
||||
# Setup frontend and backend
|
||||
FROM nginx:1.27.0-alpine3.19-slim as production-stage
|
||||
FROM nginx:${NGINX_VERSION}-alpine${ALPINE_VERSION}-slim as production-stage
|
||||
ARG WEBSERVER_FOLDER=/var/www/html
|
||||
|
||||
COPY --from=front-build-stage /front/dist ${WEBSERVER_FOLDER}
|
||||
@@ -19,58 +41,11 @@ RUN mkdir -p ${WEBSERVER_FOLDER}/assets/romm && \
|
||||
# Install required packages and dependencies
|
||||
RUN apk add --no-cache \
|
||||
bash \
|
||||
curl \
|
||||
libffi \
|
||||
mariadb-connector-c \
|
||||
netcat-openbsd \
|
||||
python3 \
|
||||
tzdata \
|
||||
gcc \
|
||||
libffi-dev \
|
||||
mariadb-connector-c-dev \
|
||||
musl-dev \
|
||||
python3-dev \
|
||||
py3-pip \
|
||||
git \
|
||||
coreutils \
|
||||
make \
|
||||
openssl-dev \
|
||||
redis
|
||||
|
||||
# Create python venv and install dependencies
|
||||
COPY ./pyproject.toml ./poetry.lock /
|
||||
RUN python3 -m venv /backend/ && \
|
||||
. /backend/bin/activate && \
|
||||
pip install --no-cache --upgrade pip && \
|
||||
pip install --no-cache git+https://github.com/radoering/poetry.git@non-package-mode && \
|
||||
pip freeze | awk -F= '{print $1}' > /installed_pip_requirements.txt && \
|
||||
mkdir -p /root/.cache/pypoetry/virtualenvs && \
|
||||
python3 -m poetry config --no-cache virtualenvs.create false && \
|
||||
python3 -m poetry env use 3.11 && \
|
||||
python3 -m poetry install --no-interaction --no-ansi --no-cache --only main && \
|
||||
python3 -m poetry export --without-hashes --only main --without-urls | awk -F= '{print $1}' > /installed_poetry_requirements.txt && \
|
||||
grep -v -x -f /installed_poetry_requirements.txt /installed_pip_requirements.txt > /build_requirements.txt && \
|
||||
pip uninstall -y -r /build_requirements.txt
|
||||
|
||||
# Cleanup unnecessary packages and files
|
||||
RUN apk del \
|
||||
gcc \
|
||||
libffi-dev \
|
||||
mariadb-connector-c-dev \
|
||||
musl-dev \
|
||||
python3-dev \
|
||||
py3-pip \
|
||||
git \
|
||||
coreutils \
|
||||
make \
|
||||
openssl-dev && \
|
||||
rm -r \
|
||||
/pyproject.toml \
|
||||
/poetry.lock \
|
||||
/installed_pip_requirements.txt \
|
||||
/installed_poetry_requirements.txt \
|
||||
/build_requirements.txt
|
||||
|
||||
COPY ./backend /backend
|
||||
|
||||
# Setup init script and config files
|
||||
@@ -83,13 +58,18 @@ RUN addgroup -g 1000 -S romm && adduser -u 1000 -D -S -G romm romm && \
|
||||
|
||||
# Move everything to final stage
|
||||
FROM scratch as final-stage
|
||||
|
||||
COPY --from=production-stage / /
|
||||
|
||||
COPY --from=backend-build /src/.venv /src/.venv
|
||||
# Fix virtualenv link to python binary
|
||||
RUN ln -sf "$(which python)" /src/.venv/bin/python
|
||||
ENV PATH="/src/.venv/bin:${PATH}"
|
||||
|
||||
# Declare the supported volumes
|
||||
VOLUME ["/romm/resources", "/romm/library", "/romm/assets", "/romm/config", "/redis-data"]
|
||||
|
||||
# Expose ports and start
|
||||
EXPOSE 8080
|
||||
EXPOSE 6379/tcp
|
||||
EXPOSE 8080 6379/tcp
|
||||
WORKDIR /romm
|
||||
CMD ["/init"]
|
||||
|
||||
@@ -5,10 +5,6 @@ set -o nounset # treat unset variables as an error
|
||||
set -o pipefail # treat errors in pipes as fatal
|
||||
shopt -s inherit_errexit # inherit errexit
|
||||
|
||||
# use virtualenvs
|
||||
# shellcheck disable=SC1091
|
||||
source /backend/bin/activate
|
||||
|
||||
# make it possible to disable the inotify watcher process
|
||||
ENABLE_RESCAN_ON_FILESYSTEM_CHANGE="${ENABLE_RESCAN_ON_FILESYSTEM_CHANGE:="true"}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user