FROM python:3.12-slim # Set environment variables ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 # Set work directory WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ gcc \ libpq-dev \ netcat-openbsd \ && rm -rf /var/lib/apt/lists/* # Install Python dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy project COPY . . # Make entrypoint executable COPY docker-entrypoint.sh /docker-entrypoint.sh RUN chmod +x /docker-entrypoint.sh # Create staticfiles directory before creating non-root user RUN mkdir -p /app/staticfiles # Create non-root user RUN adduser --disabled-password --gecos '' appuser && \ chown -R appuser:appuser /app && \ chown appuser:appuser /docker-entrypoint.sh USER appuser # Expose port EXPOSE 8000 # Set entrypoint ENTRYPOINT ["/docker-entrypoint.sh"] # Default command CMD ["gunicorn", "sportstime.wsgi:application", "--bind", "0.0.0.0:8000", "--workers", "3"]