Jotzy/backend/Dockerfile

40 lines
1 KiB
Docker
Raw Normal View History

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:51:05 +00:00
# Copy startup script
COPY start.sh /app/start.sh
RUN chmod +x /app/start.sh
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:47:18 +00:00
# Add healthcheck with longer start period for initialization
HEALTHCHECK --interval=10s --timeout=5s --start-period=40s --retries=3 \
2026-01-06 16:41:39 +00:00
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:51:05 +00:00
# Run with startup script
CMD ["/app/start.sh"]