refactor: optimize docker, robust config & country handling
All checks were successful
🚀 Docker Build and Push / build-and-push (push) Successful in 59s

- optimize(docker): use distroless/python3-debian12 & multi-stage build
- feat(app): replace Gunicorn with Waitress (pure python)
- feat(countries): replace static list with pycountry (dynamic & complete)
- feat(config): enforce mandatory APPRISE_URL (fatal if missing)
- feat(logging): add structured logging and graceful shutdown signal handling
- docs: update README with required env var and correct usage
This commit is contained in:
2025-12-31 18:46:21 +01:00
parent eef8c3835e
commit d180cb700c
4 changed files with 106 additions and 29 deletions

View File

@@ -1,12 +1,35 @@
FROM python:3.11-alpine
# ------------------------------------
# Stage 1: Build dependencies
# ------------------------------------
FROM python:3.11-slim-bookworm AS builder
WORKDIR /build
COPY requirements.txt .
# Install dependencies to a specific directory
RUN pip install --no-cache-dir --target=/build/packages -r requirements.txt
# ------------------------------------
# Stage 2: Final distroless image
# ------------------------------------
# Using Debian 12 (Bookworm) based distroless to match builder
FROM gcr.io/distroless/python3-debian12
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Add our packages to python path
ENV PYTHONPATH=/app/packages
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Copy dependencies
COPY --from=builder /build/packages /app/packages
# Copy application code
COPY app.py .
# Expose port (metadata only, distroless doesn't enforce)
EXPOSE 5000
CMD ["gunicorn", "-b", "0.0.0.0:5000", "app:app"]
# Run app.py directly (which uses waitress with signal handling)
CMD ["app.py"]