Files
KeepItGoingServer/Dockerfile
T
Keith SmithandClaude Sonnet 4.5 a52b09463a Update Dockerfile for PostgreSQL support
- Replace MySQL client with PostgreSQL client
- Use libpq-dev instead of libmysqlclient-dev
- Remove mysqlclient installation (using psycopg2-binary from requirements.txt)
- Install postgresql-client for pg_isready health checks

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-26 16:54:14 -07:00

65 lines
2.0 KiB
Docker

# ===================================================================
# Stage 1: Builder - Install dependencies
# ===================================================================
FROM python:3.12-slim-bookworm AS builder
# Install build dependencies for PostgreSQL and other packages
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
# Install Python dependencies
COPY requirements.txt /tmp/
RUN pip install --user --no-cache-dir -r /tmp/requirements.txt \
&& pip install --user --no-cache-dir gunicorn
# ===================================================================
# Stage 2: Runtime - Minimal production image
# ===================================================================
FROM python:3.12-slim-bookworm
# Install runtime dependencies only
RUN apt-get update && apt-get install -y --no-install-recommends \
postgresql-client \
curl \
&& rm -rf /var/lib/apt/lists/*
# Create django user (non-root for security)
RUN useradd -m -u 1000 -s /bin/bash django
# Set working directory
WORKDIR /app
# Copy Python dependencies from builder stage
COPY --from=builder /root/.local /home/django/.local
# Copy application code
COPY --chown=django:django . /app/
# Create directories for media and static files
RUN mkdir -p /app/media /app/staticfiles && \
chown -R django:django /app/media /app/staticfiles
# Switch to django user
USER django
# Add .local/bin to PATH for installed packages
ENV PATH=/home/django/.local/bin:$PATH
# Set Python to run in unbuffered mode (better for Docker logs)
ENV PYTHONUNBUFFERED=1
# Expose port 8000 for Gunicorn
EXPOSE 8000
# Health check - ping the API endpoint
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD curl -f http://localhost:8000/api/ || exit 1
# Entrypoint script handles migrations, static collection, and service startup
ENTRYPOINT ["/app/docker/entrypoint.sh"]
# Default command is to run Gunicorn
CMD ["gunicorn"]