Files
Kochbuch/Dockerfile
T
Kyle DammannandClaude Opus 5.5 f96cbe965e Add phase 6: backup/restore scripts and full README
- backup.sh: pg_dump (custom format), media volume and .env in one
  archive with retention (KEEP), cron example
- restore.sh: confirmation, restores .env if missing, pg_restore
  --clean in one transaction, replaces media, restarts the app
- Fix: MEDIA_ROOT=/data/media in the image so photos land on the volume
- README: installation, Nginx/Cloudflare client-IP setup, configuration
  table, AI and Instagram notes, update, backup, troubleshooting, security
- Test settings independent of the local .env

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-30 21:56:01 +01:00

37 lines
1.1 KiB
Docker

FROM python:3.12-slim AS base
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
MEDIA_ROOT=/data/media
RUN groupadd --system --gid 1000 app \
&& useradd --system --uid 1000 --gid app --home /app app
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
RUN sed -i 's/\r$//' docker/entrypoint.sh && chmod +x docker/entrypoint.sh \
&& SECRET_KEY=build-only python manage.py collectstatic --noinput \
&& mkdir -p /data/media && chown -R app:app /data
USER app
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
CMD python -c "import urllib.request,sys; sys.exit(0 if urllib.request.urlopen('http://127.0.0.1:8000/healthz', timeout=4).status == 200 else 1)"
ENTRYPOINT ["/app/docker/entrypoint.sh"]
# Test image: same app plus dev dependencies (docker compose --profile test run --rm test)
FROM base AS test
USER root
COPY requirements-dev.txt .
RUN pip install -r requirements-dev.txt
USER app
ENTRYPOINT []
CMD ["pytest", "-p", "no:cacheprovider"]
FROM base AS production