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 }} diff --git a/Dockerfile b/Dockerfile index a880fca..7805f94 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,40 @@ +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 + EXPOSE 8000 CMD ["/app/mediamanager-backend-startup.sh"] \ No newline at end of file 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 diff --git a/media_manager/main.py b/media_manager/main.py index b2a37ea..2f81674 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() @@ -288,5 +288,14 @@ 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) 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/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 diff --git a/web/Dockerfile b/web/Dockerfile index 994f598..b056f28 100644 --- a/web/Dockerfile +++ b/web/Dockerfile @@ -1,28 +1,37 @@ 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 ./ +COPY --chmod=755 mediamanager-frontend-startup.sh ./ +RUN npm ci --only=production EXPOSE 3000 - -CMD ["node","build/index.js"] +USER node +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 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 Logo
Media Manager - v{PUBLIC_VERSION} + {PUBLIC_VERSION}
{/snippet} 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, {