From 2ad0275cd72f725fbaa034a7168179c86f39f254 Mon Sep 17 00:00:00 2001
From: maxDorninger <97409287+maxDorninger@users.noreply.github.com>
Date: Mon, 30 Jun 2025 13:29:02 +0200
Subject: [PATCH 01/12] optimize the frontend's dockerfile and fix version not
displaying in the frontend
---
web/Dockerfile | 28 +++++++++++++++--------
web/src/lib/components/app-sidebar.svelte | 2 +-
2 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/web/Dockerfile b/web/Dockerfile
index 994f598..7ac89b3 100644
--- a/web/Dockerfile
+++ b/web/Dockerfile
@@ -1,28 +1,36 @@
ARG VERSION
ARG BASE_URL=""
-FROM node:24-alpine AS build
-USER node:node
+FROM node:24-alpine AS deps
WORKDIR /app
-COPY --chown=node:node . .
+COPY package*.json ./
+RUN npm ci --only=production
+FROM node:24-alpine AS build
+WORKDIR /app
+ARG VERSION
+ARG BASE_URL
+
+COPY --from=deps /app/node_modules ./node_modules
+COPY package*.json ./
RUN npm ci
+
+COPY . .
RUN env PUBLIC_VERSION=${VERSION} BASE_URL=${BASE_URL} npm run build
FROM node:24-alpine AS frontend
ARG VERSION
-USER node:node
+WORKDIR /app
LABEL version=${VERSION}
LABEL description="Docker image for the web frontend of MediaManager"
ENV PUBLIC_VERSION=${VERSION}
ENV PUBLIC_SSR_WEB=false
-WORKDIR /app
-COPY --chown=node:node package*.json ./
-COPY --chown=node:node --from=build /app/node_modules ./node_modules/
-COPY --chown=node:node --from=build /app/build/ ./build/
+COPY --from=build /app/build/ ./build/
+COPY package*.json ./
+RUN npm ci --only=production
EXPOSE 3000
-
-CMD ["node","build/index.js"]
+USER node
+CMD ["node","build/index.js"]
\ No newline at end of file
diff --git a/web/src/lib/components/app-sidebar.svelte b/web/src/lib/components/app-sidebar.svelte
index fe49617..d533f95 100644
--- a/web/src/lib/components/app-sidebar.svelte
+++ b/web/src/lib/components/app-sidebar.svelte
@@ -99,7 +99,7 @@
Media Manager
- v{PUBLIC_VERSION}
+ {PUBLIC_VERSION}
{/snippet}
From 992ac94b0e1a5630678ca8700580372bf1a4226c Mon Sep 17 00:00:00 2001
From: maxDorninger <97409287+maxDorninger@users.noreply.github.com>
Date: Mon, 30 Jun 2025 13:52:38 +0200
Subject: [PATCH 02/12] fix query parameter name mismatch in movies router.py
---
media_manager/movies/router.py | 7 +++++--
web/src/lib/components/download-movie-dialog.svelte | 2 +-
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/media_manager/movies/router.py b/media_manager/movies/router.py
index a65c877..34bd7cf 100644
--- a/media_manager/movies/router.py
+++ b/media_manager/movies/router.py
@@ -241,10 +241,13 @@ def get_all_available_torrents_for_a_movie(
def download_torrent_for_movie(
movie_service: movie_service_dep,
movie_id: MovieId,
- indexer_result_id: IndexerQueryResultId,
+ public_indexer_result_id: IndexerQueryResultId,
+ override_file_path_suffix: str = "",
):
return movie_service.download_torrent(
- public_indexer_result_id=indexer_result_id, movie_id=movie_id
+ public_indexer_result_id=public_indexer_result_id,
+ movie_id=movie_id,
+ override_movie_file_path_suffix=override_file_path_suffix,
)
diff --git a/web/src/lib/components/download-movie-dialog.svelte b/web/src/lib/components/download-movie-dialog.svelte
index d35e6d3..e8fbb51 100644
--- a/web/src/lib/components/download-movie-dialog.svelte
+++ b/web/src/lib/components/download-movie-dialog.svelte
@@ -27,7 +27,7 @@
let url = new URL(apiUrl + `/movies/${movie.id}/torrents`);
url.searchParams.append('public_indexer_result_id', result_id);
if (filePathSuffix !== '') {
- url.searchParams.append('file_path_suffix', filePathSuffix);
+ url.searchParams.append('override_file_path_suffix', filePathSuffix);
}
try {
const response = await fetch(url, {
From b6af87ea882456a28b793046f61492f107879ed7 Mon Sep 17 00:00:00 2001
From: maxDorninger <97409287+maxDorninger@users.noreply.github.com>
Date: Mon, 30 Jun 2025 14:00:56 +0200
Subject: [PATCH 03/12] fix weekly tasks being triggered every hour
---
media_manager/main.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/media_manager/main.py b/media_manager/main.py
index b2a37ea..20b42c0 100644
--- a/media_manager/main.py
+++ b/media_manager/main.py
@@ -131,7 +131,7 @@ weekly_trigger = CronTrigger(
day_of_week="mon", hour=0, minute=0, jitter=60 * 60 * 24 * 2
)
scheduler.add_job(hourly_tasks, trigger)
-scheduler.add_job(weekly_tasks, trigger)
+scheduler.add_job(weekly_tasks, weekly_trigger)
scheduler.start()
From f837a75c73fb1b414d5f39c49a9a13921dde2f9a Mon Sep 17 00:00:00 2001
From: maxDorninger <97409287+maxDorninger@users.noreply.github.com>
Date: Mon, 30 Jun 2025 14:12:24 +0200
Subject: [PATCH 04/12] add version to api, add hello world route to api and
optimize the backend's dockerfile
---
Dockerfile | 39 ++++++++++++++++++++++++++++++---------
media_manager/main.py | 7 +++++++
2 files changed, 37 insertions(+), 9 deletions(-)
diff --git a/Dockerfile b/Dockerfile
index a880fca..ee770ea 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,23 +1,44 @@
+FROM ghcr.io/astral-sh/uv:debian-slim AS builder
+WORKDIR /app
+
+RUN apt-get update && \
+ apt-get install -y --no-install-recommends ca-certificates gcc python3-dev && \
+ apt-get clean && \
+ rm -rf /var/lib/apt/lists/*
+
+COPY pyproject.toml uv.lock ./
+
+RUN uv sync --locked
+
FROM ghcr.io/astral-sh/uv:debian-slim
ARG VERSION
LABEL version=${VERSION}
LABEL description="Docker image for the backend of MediaManager"
-ENV IMAGE_DIRECTORY=/data/images
-ENV TV_SHOW_DIRECTORY=/data/tv
-ENV MOVIE_DIRECTORY=/data/movies
-ENV TORRENT_DIRECTORY=/data/torrents
-ENV OPENID_ENABLED=FALSE
+ENV IMAGE_DIRECTORY=/data/images \
+ TV_SHOW_DIRECTORY=/data/tv \
+ MOVIE_DIRECTORY=/data/movies \
+ TORRENT_DIRECTORY=/data/torrents \
+ OPENID_ENABLED=FALSE \
+ PUBLIC_VERSION=${VERSION}
-RUN apt update && apt install -y ca-certificates gcc python3-dev
+RUN apt-get update && \
+ apt-get install -y --no-install-recommends ca-certificates && \
+ apt-get clean && \
+ rm -rf /var/lib/apt/lists/*
WORKDIR /app
+
+COPY --from=builder /usr/local/lib/python3.*/site-packages /usr/local/lib/python3.*/site-packages/
+
COPY --chmod=755 mediamanager-backend-startup.sh .
COPY media_manager ./media_manager
COPY alembic ./alembic
COPY alembic.ini .
-COPY pyproject.toml .
-COPY uv.lock .
-RUN uv sync --locked
+
+RUN useradd -m appuser && \
+ chown -R appuser:appuser /app /data
+
+USER appuser
EXPOSE 8000
CMD ["/app/mediamanager-backend-startup.sh"]
\ No newline at end of file
diff --git a/media_manager/main.py b/media_manager/main.py
index 20b42c0..a22d6f4 100644
--- a/media_manager/main.py
+++ b/media_manager/main.py
@@ -288,5 +288,12 @@ except Exception as e:
log.error(f"Error creating test directory: {e}")
raise
+@app.get("/", response_model={"message": str, "version": str})
+async def hello_world():
+ """
+ A simple endpoint to check if the API is running.
+ """
+ return {"message": "Hello World!", "version": os.getenv("PUBLIC_VERSION")}
+
if __name__ == "__main__":
uvicorn.run(app, host="127.0.0.1", port=5049, log_config=LOGGING_CONFIG)
From be3e7f8cd8f7b6c7a88186d1e9f52ee02de0fb71 Mon Sep 17 00:00:00 2001
From: maxDorninger <97409287+maxDorninger@users.noreply.github.com>
Date: Mon, 30 Jun 2025 14:14:20 +0200
Subject: [PATCH 05/12] format files
---
media_manager/main.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/media_manager/main.py b/media_manager/main.py
index a22d6f4..2f81674 100644
--- a/media_manager/main.py
+++ b/media_manager/main.py
@@ -288,6 +288,7 @@ except Exception as e:
log.error(f"Error creating test directory: {e}")
raise
+
@app.get("/", response_model={"message": str, "version": str})
async def hello_world():
"""
@@ -295,5 +296,6 @@ async def hello_world():
"""
return {"message": "Hello World!", "version": os.getenv("PUBLIC_VERSION")}
+
if __name__ == "__main__":
uvicorn.run(app, host="127.0.0.1", port=5049, log_config=LOGGING_CONFIG)
From 908e51c40417457ab675c12c6e107eacca98eac3 Mon Sep 17 00:00:00 2001
From: maxDorninger <97409287+maxDorninger@users.noreply.github.com>
Date: Mon, 30 Jun 2025 14:21:33 +0200
Subject: [PATCH 06/12] update backend startup script
---
mediamanager-backend-startup.sh | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/mediamanager-backend-startup.sh b/mediamanager-backend-startup.sh
index 2b8c59d..bdf8af5 100644
--- a/mediamanager-backend-startup.sh
+++ b/mediamanager-backend-startup.sh
@@ -1,4 +1,18 @@
#!/bin/bash
# This script is used to start the MediaManager backend service.
+
+
+# text created with https://patorjk.com/software/taag/ font: Slanted
+cat << EOF
+ __ ___ ___ __ ___ ____ __ __
+ / |/ /__ ____/ (_)___ _/ |/ /___ _____ ____ _____ ____ _____ / __ )____ ______/ /_____ ____ ____/ /
+ / /|_/ / _ \/ __ / / __ `/ /|_/ / __ `/ __ \/ __ `/ __ `/ _ \/ ___/ / __ / __ `/ ___/ //_/ _ \/ __ \/ __ /
+ / / / / __/ /_/ / / /_/ / / / / /_/ / / / / /_/ / /_/ / __/ / / /_/ / /_/ / /__/ ,< / __/ / / / /_/ /
+/_/ /_/\___/\__,_/_/\__,_/_/ /_/\__,_/_/ /_/\__,_/\__, /\___/_/ /_____/\__,_/\___/_/|_|\___/_/ /_/\__,_/
+ /____/
+EOF
+echo "Buy me a coffee at https://buymeacoffee.com/maxdorninger"
+echo "Running DB migrations..."
uv run alembic upgrade head
+echo "Starting MediaManager backend service..."
uv run fastapi run /app/media_manager/main.py
\ No newline at end of file
From a1403d7805b219d1e85656af5c05be4d19b15d94 Mon Sep 17 00:00:00 2001
From: maxDorninger <97409287+maxDorninger@users.noreply.github.com>
Date: Mon, 30 Jun 2025 14:24:13 +0200
Subject: [PATCH 07/12] update readme
---
README.md | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 45d67f6..c345d43 100644
--- a/README.md
+++ b/README.md
@@ -54,11 +54,14 @@ other services.
- [x] create separate metadata relay service, so that api keys for TMDB and TVDB are not strictly needed
- [x] support for movies
- [x] expand README with more information and a quickstart guide
+- [x] improve reliability of scheduled tasks
- [ ] add notification system
- [ ] add in-depth documentation on the architecture of the codebase
- [ ] make indexer module multithreaded
- [ ] add support for deluge and transmission
-- [ ] improve reliability of scheduled tasks
+- [ ] add delete button for movies/TV shows
+- [ ] rework prowlarr module (select which indexers to use, etc.)
+- [ ] add sequence diagrams to the documentation
- [ ] _maybe_ rework the logo
- [ ] _maybe_ add support for configuration via toml config file
From 548ba4535c1202354776e7bb4c3f9b92156291d6 Mon Sep 17 00:00:00 2001
From: maxDorninger <97409287+maxDorninger@users.noreply.github.com>
Date: Mon, 30 Jun 2025 14:56:51 +0200
Subject: [PATCH 08/12] update worklfow for backend
---
.github/workflows/build-push-backend.yml | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/build-push-backend.yml b/.github/workflows/build-push-backend.yml
index 2536145..51bc911 100644
--- a/.github/workflows/build-push-backend.yml
+++ b/.github/workflows/build-push-backend.yml
@@ -94,6 +94,16 @@ jobs:
type=semver,pattern={{major}}
type=sha
+ - name: Extract version
+ id: version
+ run: |
+ if [[ "${{ github.ref }}" == refs/tags/* ]]; then
+ VERSION=${GITHUB_REF#refs/tags/}
+ else
+ VERSION="dev-${GITHUB_SHA::7}"
+ fi
+ echo "version=$VERSION" >> $GITHUB_OUTPUT
+
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
@@ -104,4 +114,4 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
- VERSION=${{ steps.meta.outputs.version }}
+ VERSION=${{ steps.version.outputs.version }}
From e965490a6579abd9b0e1be9403c98f7caabcfb72 Mon Sep 17 00:00:00 2001
From: maxDorninger <97409287+maxDorninger@users.noreply.github.com>
Date: Mon, 30 Jun 2025 15:02:17 +0200
Subject: [PATCH 09/12] add startup script to frontend docker container
---
web/Dockerfile | 3 ++-
web/mediamanager-frontend-startup.sh | 16 ++++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
create mode 100644 web/mediamanager-frontend-startup.sh
diff --git a/web/Dockerfile b/web/Dockerfile
index 7ac89b3..b056f28 100644
--- a/web/Dockerfile
+++ b/web/Dockerfile
@@ -29,8 +29,9 @@ ENV PUBLIC_SSR_WEB=false
COPY --from=build /app/build/ ./build/
COPY package*.json ./
+COPY --chmod=755 mediamanager-frontend-startup.sh ./
RUN npm ci --only=production
EXPOSE 3000
USER node
-CMD ["node","build/index.js"]
\ No newline at end of file
+CMD ["/app/mediamanager-frontend-startup.sh"]
diff --git a/web/mediamanager-frontend-startup.sh b/web/mediamanager-frontend-startup.sh
new file mode 100644
index 0000000..72da9c6
--- /dev/null
+++ b/web/mediamanager-frontend-startup.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+# This script is used to start the MediaManager backend service.
+
+
+# text created with https://patorjk.com/software/taag/ font: Slanted
+cat << EOF
+ __ ___ ___ __ ___ ______ __ __
+ / |/ /__ ____/ (_)___ _/ |/ /___ _____ ____ _____ ____ _____ / ____/________ ____ / /____ ____ ____/ /
+ / /|_/ / _ \/ __ / / __ `/ /|_/ / __ `/ __ \/ __ `/ __ `/ _ \/ ___/ / /_ / ___/ __ \/ __ \/ __/ _ \/ __ \/ __ /
+ / / / / __/ /_/ / / /_/ / / / / /_/ / / / / /_/ / /_/ / __/ / / __/ / / / /_/ / / / / /_/ __/ / / / /_/ /
+/_/ /_/\___/\__,_/_/\__,_/_/ /_/\__,_/_/ /_/\__,_/\__, /\___/_/ /_/ /_/ \____/_/ /_/\__/\___/_/ /_/\__,_/
+ /____/
+EOF
+echo "Buy me a coffee at https://buymeacoffee.com/maxdorninger"
+echo "Starting MediaManager frontend service..."
+node build/index.js
\ No newline at end of file
From 17272207cf18faa9b7270a7d9b54f5c0bc73bebe Mon Sep 17 00:00:00 2001
From: maxDorninger <97409287+maxDorninger@users.noreply.github.com>
Date: Mon, 30 Jun 2025 15:08:42 +0200
Subject: [PATCH 10/12] update backend docker file
---
Dockerfile | 4 ----
1 file changed, 4 deletions(-)
diff --git a/Dockerfile b/Dockerfile
index ee770ea..7805f94 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -36,9 +36,5 @@ COPY media_manager ./media_manager
COPY alembic ./alembic
COPY alembic.ini .
-RUN useradd -m appuser && \
- chown -R appuser:appuser /app /data
-
-USER appuser
EXPOSE 8000
CMD ["/app/mediamanager-backend-startup.sh"]
\ No newline at end of file
From a3a61710d3ce0d07e83e49d6b3dbc07497185944 Mon Sep 17 00:00:00 2001
From: maxDorninger <97409287+maxDorninger@users.noreply.github.com>
Date: Mon, 30 Jun 2025 15:46:59 +0200
Subject: [PATCH 11/12] trying to optimize runtime of worklfow building the
frontend containers
---
.github/workflows/build-push-frontend.yml | 6 +++++-
web/Dockerfile | 8 ++++----
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/.github/workflows/build-push-frontend.yml b/.github/workflows/build-push-frontend.yml
index 6473617..2c2e824 100644
--- a/.github/workflows/build-push-frontend.yml
+++ b/.github/workflows/build-push-frontend.yml
@@ -26,8 +26,10 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: '20'
+ cache: 'npm'
+ cache-dependency-path: './web/package-lock.json'
- name: Install dependencies
- run: npm install
+ run: npm ci
working-directory: ./web
- name: Lint code
run: npm run lint
@@ -91,3 +93,5 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ steps.version.outputs.version }}
+ cache-from: type=gha
+ cache-to: type=gha,mode=max
diff --git a/web/Dockerfile b/web/Dockerfile
index b056f28..e4967c7 100644
--- a/web/Dockerfile
+++ b/web/Dockerfile
@@ -4,16 +4,15 @@ FROM node:24-alpine AS deps
WORKDIR /app
COPY package*.json ./
-RUN npm ci --only=production
+RUN npm ci --only=production && npm cache clean --force
FROM node:24-alpine AS build
WORKDIR /app
ARG VERSION
ARG BASE_URL
-COPY --from=deps /app/node_modules ./node_modules
COPY package*.json ./
-RUN npm ci
+RUN npm ci && npm cache clean --force
COPY . .
RUN env PUBLIC_VERSION=${VERSION} BASE_URL=${BASE_URL} npm run build
@@ -30,7 +29,8 @@ ENV PUBLIC_SSR_WEB=false
COPY --from=build /app/build/ ./build/
COPY package*.json ./
COPY --chmod=755 mediamanager-frontend-startup.sh ./
-RUN npm ci --only=production
+
+COPY --from=deps /app/node_modules ./node_modules
EXPOSE 3000
USER node
From 4d67db6545cafbc68b9715b74cd57c5dcba4d564 Mon Sep 17 00:00:00 2001
From: maxDorninger <97409287+maxDorninger@users.noreply.github.com>
Date: Mon, 30 Jun 2025 17:17:21 +0200
Subject: [PATCH 12/12] fix the docker files and startup scripts, also fix a
bug in the hello world route of the backend
---
Dockerfile | 6 ++--
media_manager/main.py | 5 ++--
mediamanager-backend-startup.sh | 10 ++++---
web/Dockerfile | 28 ++++++++++---------
...ager-frontend-startup.sh => entrypoint.sh} | 8 +++---
5 files changed, 31 insertions(+), 26 deletions(-)
rename web/{mediamanager-frontend-startup.sh => entrypoint.sh} (76%)
diff --git a/Dockerfile b/Dockerfile
index 7805f94..8e510f2 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -20,7 +20,8 @@ ENV IMAGE_DIRECTORY=/data/images \
MOVIE_DIRECTORY=/data/movies \
TORRENT_DIRECTORY=/data/torrents \
OPENID_ENABLED=FALSE \
- PUBLIC_VERSION=${VERSION}
+ PUBLIC_VERSION=${VERSION} \
+ UV_PROJECT_ENVIRONMENT=/app/.venv
RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates && \
@@ -29,7 +30,8 @@ RUN apt-get update && \
WORKDIR /app
-COPY --from=builder /usr/local/lib/python3.*/site-packages /usr/local/lib/python3.*/site-packages/
+COPY --from=builder /app/.venv /app/.venv
+COPY --from=builder /app/pyproject.toml /app/uv.lock ./
COPY --chmod=755 mediamanager-backend-startup.sh .
COPY media_manager ./media_manager
diff --git a/media_manager/main.py b/media_manager/main.py
index 2f81674..75984dd 100644
--- a/media_manager/main.py
+++ b/media_manager/main.py
@@ -289,13 +289,12 @@ except Exception as e:
raise
-@app.get("/", response_model={"message": str, "version": str})
-async def hello_world():
+@app.get("/")
+async def hello_world() -> dict:
"""
A simple endpoint to check if the API is running.
"""
return {"message": "Hello World!", "version": os.getenv("PUBLIC_VERSION")}
-
if __name__ == "__main__":
uvicorn.run(app, host="127.0.0.1", port=5049, log_config=LOGGING_CONFIG)
diff --git a/mediamanager-backend-startup.sh b/mediamanager-backend-startup.sh
index bdf8af5..169b803 100644
--- a/mediamanager-backend-startup.sh
+++ b/mediamanager-backend-startup.sh
@@ -3,16 +3,18 @@
# text created with https://patorjk.com/software/taag/ font: Slanted
-cat << EOF
+echo "
__ ___ ___ __ ___ ____ __ __
/ |/ /__ ____/ (_)___ _/ |/ /___ _____ ____ _____ ____ _____ / __ )____ ______/ /_____ ____ ____/ /
- / /|_/ / _ \/ __ / / __ `/ /|_/ / __ `/ __ \/ __ `/ __ `/ _ \/ ___/ / __ / __ `/ ___/ //_/ _ \/ __ \/ __ /
+ / /|_/ / _ \/ __ / / __ \`/ /|_/ / __ \`/ __ \/ __ \`/ __ \`/ _ \/ ___/ / __ / __ \`/ ___/ //_/ _ \/ __ \/ __ /
/ / / / __/ /_/ / / /_/ / / / / /_/ / / / / /_/ / /_/ / __/ / / /_/ / /_/ / /__/ ,< / __/ / / / /_/ /
/_/ /_/\___/\__,_/_/\__,_/_/ /_/\__,_/_/ /_/\__,_/\__, /\___/_/ /_____/\__,_/\___/_/|_|\___/_/ /_/\__,_/
/____/
-EOF
+"
echo "Buy me a coffee at https://buymeacoffee.com/maxdorninger"
echo "Running DB migrations..."
+
uv run alembic upgrade head
+
echo "Starting MediaManager backend service..."
-uv run fastapi run /app/media_manager/main.py
\ No newline at end of file
+uv run fastapi run /app/media_manager/main.py --port 8000
diff --git a/web/Dockerfile b/web/Dockerfile
index e4967c7..11ab5e5 100644
--- a/web/Dockerfile
+++ b/web/Dockerfile
@@ -1,37 +1,39 @@
ARG VERSION
ARG BASE_URL=""
-FROM node:24-alpine AS deps
-WORKDIR /app
-
-COPY package*.json ./
-RUN npm ci --only=production && npm cache clean --force
-
FROM node:24-alpine AS build
WORKDIR /app
ARG VERSION
ARG BASE_URL
+# Copy package files first for better layer caching
COPY package*.json ./
RUN npm ci && npm cache clean --force
+# Copy source code after dependencies are installed
COPY . .
RUN env PUBLIC_VERSION=${VERSION} BASE_URL=${BASE_URL} npm run build
FROM node:24-alpine AS frontend
ARG VERSION
+
+USER node
+EXPOSE 3000
WORKDIR /app
+
LABEL version=${VERSION}
LABEL description="Docker image for the web frontend of MediaManager"
+
ENV PUBLIC_VERSION=${VERSION}
ENV PUBLIC_SSR_WEB=false
-COPY --from=build /app/build/ ./build/
-COPY package*.json ./
-COPY --chmod=755 mediamanager-frontend-startup.sh ./
+# Copy built application and package files
+COPY --from=build /app/build ./build
+COPY --from=build /app/package*.json ./
+COPY --chmod=755 entrypoint.sh .
-COPY --from=deps /app/node_modules ./node_modules
+# Install only production dependencies needed for the Node adapter
+RUN npm ci --only=production && npm cache clean --force
+
+CMD ["/app/entrypoint.sh"]
-EXPOSE 3000
-USER node
-CMD ["/app/mediamanager-frontend-startup.sh"]
diff --git a/web/mediamanager-frontend-startup.sh b/web/entrypoint.sh
similarity index 76%
rename from web/mediamanager-frontend-startup.sh
rename to web/entrypoint.sh
index 72da9c6..0acf8d1 100644
--- a/web/mediamanager-frontend-startup.sh
+++ b/web/entrypoint.sh
@@ -1,16 +1,16 @@
-#!/bin/bash
-# This script is used to start the MediaManager backend service.
+#!/bin/sh
+# This script is used to start the MediaManager frontend service.
# text created with https://patorjk.com/software/taag/ font: Slanted
cat << EOF
__ ___ ___ __ ___ ______ __ __
/ |/ /__ ____/ (_)___ _/ |/ /___ _____ ____ _____ ____ _____ / ____/________ ____ / /____ ____ ____/ /
- / /|_/ / _ \/ __ / / __ `/ /|_/ / __ `/ __ \/ __ `/ __ `/ _ \/ ___/ / /_ / ___/ __ \/ __ \/ __/ _ \/ __ \/ __ /
+ / /|_/ / _ \/ __ / / __ \`/ /|_/ / __ \`/ __ \/ __ \`/ __ \`/ _ \/ ___/ / /_ / ___/ __ \/ __ \/ __/ _ \/ __ \/ __ /
/ / / / __/ /_/ / / /_/ / / / / /_/ / / / / /_/ / /_/ / __/ / / __/ / / / /_/ / / / / /_/ __/ / / / /_/ /
/_/ /_/\___/\__,_/_/\__,_/_/ /_/\__,_/_/ /_/\__,_/\__, /\___/_/ /_/ /_/ \____/_/ /_/\__/\___/_/ /_/\__,_/
/____/
EOF
echo "Buy me a coffee at https://buymeacoffee.com/maxdorninger"
echo "Starting MediaManager frontend service..."
-node build/index.js
\ No newline at end of file
+node build/index.js