reddit-media-collector/Dockerfile
Richard Nixon d02e071ddf feat(deploy): publish image to GHCR and document Synology DSM setup
Add a release workflow that publishes a linux/amd64 image to
ghcr.io/richardnixondev/reddit-media-collector on every v* tag, plus a
ready-to-paste docker-compose for Synology Container Manager.

Persist scheduler state across container restarts by reading the DB and
config paths from RMC_SCHEDULER_DB / RMC_SCHEDULER_CONFIG (previously
written to /app, which is not a volume).

Drive-by fixes uncovered while smoke-testing the image:
- Dockerfile now copies README.md (required by pyproject) and drops the
  single-file VOLUME entry that breaks bind mounts; adds an OCI source
  label and a socket-based HEALTHCHECK so Container Manager reflects real
  liveness.
- src/web/app.py uses the new Starlette TemplateResponse signature so the
  index page does not 500 under fresh dependency pins.
2026-05-17 14:48:02 +01:00

40 lines
1.2 KiB
Docker

FROM python:3.12-slim AS base
RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
FROM base AS builder
COPY pyproject.toml README.md ./
COPY src/ ./src/
RUN pip install --no-cache-dir .
FROM base AS runtime
LABEL org.opencontainers.image.source="https://github.com/richardnixondev/reddit-media-collector"
LABEL org.opencontainers.image.description="Self-hosted media collector for Reddit with Immich integration"
LABEL org.opencontainers.image.licenses="MIT"
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin
WORKDIR /app
COPY src/ ./src/
RUN mkdir -p /app/downloads /app/data
ENV RMC_DOWNLOAD_DIR=/app/downloads
ENV RMC_DB_PATH=/app/data/media.db
ENV RMC_CONFIG_PATH=/app/config.yaml
ENV RMC_TIMEZONE=UTC
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
CMD python -c "import socket,sys; s=socket.socket(); s.settimeout(3); s.connect(('127.0.0.1',8000)); s.close()" || exit 1
CMD ["uvicorn", "src.web.app:app", "--host", "0.0.0.0", "--port", "8000"]