cc694e71b4
- Add pyproject.toml with proper metadata and dependency groups - Create multi-stage Dockerfile for backend - Add docker-compose.yml with dev/prod profiles - Create frontend Dockerfile with nginx - Add .dockerignore for optimized builds - Update README with Docker instructions and troubleshooting - Remove requirements.txt in favor of pyproject.toml - Ensure data persistence with Docker volumes
51 lines
1.2 KiB
Docker
51 lines
1.2 KiB
Docker
# Stage 1: Builder
|
|
FROM python:3.14 AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Install build dependencies
|
|
RUN pip install --no-cache-dir setuptools wheel
|
|
|
|
# Copy pyproject.toml first for better layer caching
|
|
COPY pyproject.toml ./
|
|
|
|
# Copy source code
|
|
COPY app/ ./app/
|
|
COPY backup/ ./backup/
|
|
COPY alembic/ ./alembic/
|
|
COPY alembic.ini ./
|
|
|
|
# Build the package with dev dependencies
|
|
RUN pip install --no-cache-dir -e ".[dev]"
|
|
|
|
# Stage 2: Runtime
|
|
FROM python:3.14-slim
|
|
|
|
WORKDIR /app
|
|
|
|
# Create non-root user
|
|
RUN groupadd -r backup-tool && useradd -r -g backup-tool backup-tool
|
|
|
|
# Copy installed packages from builder
|
|
COPY --from=builder /usr/local/lib/python3.14/site-packages/ /usr/local/lib/python3.14/site-packages/
|
|
COPY --from=builder /usr/local/bin/ /usr/local/bin/
|
|
|
|
# Copy application code
|
|
COPY --from=builder /app/ ./
|
|
|
|
# Create data directory for SQLite and backups
|
|
RUN mkdir -p /app/data /app/backups && \
|
|
chown -R backup-tool:backup-tool /app
|
|
|
|
USER backup-tool
|
|
|
|
# Expose port
|
|
EXPOSE 8000
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
|
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/api/health')" || exit 1
|
|
|
|
# Default command
|
|
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
|