2026-01-06 16:41:39 +00:00
|
|
|
# ---- Builder stage ----
|
|
|
|
|
FROM python:3.12-slim AS builder
|
2025-11-19 21:16:32 +00:00
|
|
|
WORKDIR /app
|
2025-11-23 09:08:01 +00:00
|
|
|
|
2026-01-06 16:41:39 +00:00
|
|
|
# Install dependencies
|
2025-11-19 21:16:32 +00:00
|
|
|
COPY requirements.txt .
|
2026-01-06 16:41:39 +00:00
|
|
|
RUN pip install --upgrade pip && \
|
|
|
|
|
pip install --no-cache-dir -r requirements.txt
|
2026-01-06 12:51:40 +00:00
|
|
|
|
2026-01-06 16:41:39 +00:00
|
|
|
# ---- Runtime stage ----
|
|
|
|
|
FROM python:3.12-slim
|
|
|
|
|
WORKDIR /app
|
2026-01-06 15:44:53 +00:00
|
|
|
|
2026-01-06 16:41:39 +00:00
|
|
|
# Copy installed packages from builder
|
|
|
|
|
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
|
2026-01-06 15:44:53 +00:00
|
|
|
|
2026-01-06 16:41:39 +00:00
|
|
|
# Copy application code
|
|
|
|
|
COPY app ./app
|
2025-11-19 21:16:32 +00:00
|
|
|
|
2026-01-06 16:41:39 +00:00
|
|
|
# Create data directory for SQLite and other persistent data
|
|
|
|
|
RUN mkdir -p /app/data
|
2026-01-06 15:44:53 +00:00
|
|
|
|
2026-01-06 16:41:39 +00:00
|
|
|
# Set environment variables
|
|
|
|
|
ENV PYTHONUNBUFFERED=1 \
|
|
|
|
|
PYTHONDONTWRITEBYTECODE=1
|
2026-01-06 15:44:53 +00:00
|
|
|
|
2026-01-06 16:41:39 +00:00
|
|
|
# Add healthcheck
|
|
|
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
|
|
|
|
|
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health').read()" || exit 1
|
2025-11-23 09:08:01 +00:00
|
|
|
|
2026-01-06 16:41:39 +00:00
|
|
|
EXPOSE 8000
|
2026-01-06 12:51:40 +00:00
|
|
|
|
2026-01-06 16:41:39 +00:00
|
|
|
# Run with production settings
|
|
|
|
|
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--proxy-headers", "--forwarded-allow-ips", "*"]
|