Merge pull request #16 from maxdorninger/add-versions

Fix the dockerfiles and startup scripts
This commit is contained in:
Maximilian Dorninger
2025-06-30 17:18:33 +02:00
committed by GitHub
6 changed files with 38 additions and 29 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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)

View File

@@ -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
uv run fastapi run /app/media_manager/main.py --port 8000

View File

@@ -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
FROM node:24-alpine AS build
WORKDIR /app
ARG VERSION
ARG BASE_URL
COPY --from=deps /app/node_modules ./node_modules
# Copy package files first for better layer caching
COPY package*.json ./
RUN npm ci
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 ./
RUN npm ci --only=production
# Copy built application and package files
COPY --from=build /app/build ./build
COPY --from=build /app/package*.json ./
COPY --chmod=755 entrypoint.sh .
# 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"]

View File

@@ -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
node build/index.js