43 lines
884 B
Docker
43 lines
884 B
Docker
# Use Python 3.12 slim image
|
|
FROM python:3.12-slim
|
|
|
|
# Set environment variables
|
|
ENV PYTHONUNBUFFERED=1 \
|
|
PYTHONDONTWRITEBYTECODE=1 \
|
|
PIP_NO_CACHE_DIR=1 \
|
|
PIP_DISABLE_PIP_VERSION_CHECK=1
|
|
|
|
# Set work directory
|
|
WORKDIR /app
|
|
|
|
# Install system dependencies
|
|
RUN apt-get update && apt-get install -y \
|
|
postgresql-client \
|
|
gcc \
|
|
python3-dev \
|
|
musl-dev \
|
|
libpq-dev \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy requirements
|
|
COPY pyproject.toml ./
|
|
|
|
# Install Python dependencies
|
|
RUN pip install --upgrade pip setuptools wheel && \
|
|
pip install -e ".[dev]"
|
|
|
|
# Copy project
|
|
COPY . .
|
|
|
|
# Create necessary directories
|
|
RUN mkdir -p logs media staticfiles
|
|
|
|
# Collect static files
|
|
RUN python manage.py collectstatic --noinput || true
|
|
|
|
# Expose port
|
|
EXPOSE 8000
|
|
|
|
# Default command
|
|
CMD ["gunicorn", "config.wsgi:application", "--bind", "0.0.0.0:8000", "--workers", "3"]
|