Compare commits

..

No commits in common. "ceca8895e2d722aa32b46a71b749a7a5e00cb80a" and "7dfcb19547ce61eb0557bc7dc5dc8baa22e1a400" have entirely different histories.

View File

@ -1,32 +1,37 @@
FROM python:3.12-slim FROM debian:bookworm-slim
# Environment settings # Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED=1 ENV PYTHONUNBUFFERED 1
# Set work directory # Set work directory
WORKDIR /app WORKDIR /app
# System dependencies
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
build-essential \ build-essential \
curl wget \ curl wget \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# Copy dependency file RUN curl -LsSf https://astral.sh/uv/install.sh | sh
COPY requirements.txt . ENV PATH="/root/.local/bin:${PATH}"
# Install Python dependencies # Copy only the dependency definitions first to leverage Docker's layer caching
RUN pip install --no-cache-dir -r requirements.txt COPY pyproject.toml uv.lock .python-version ./
# Copy project files # Install Python dependencies for production
RUN uv sync --no-group dev --group prod
# Copy the rest of the application code into the container
COPY . . COPY . .
# Expose port # Collect the static files
RUN uv run --no-sync ./manage.py collectstatic --noinput
# Migrate the database
RUN uv run --no-sync ./manage.py migrate
# Expose the port Gunicorn will run on
EXPOSE 8000 EXPOSE 8000
# Run migrations + collectstatic + gunicorn at runtime # Run with gunicorn
CMD \ CMD ["uv", "run", "--no-sync", "gunicorn", "--bind", "0.0.0.0:8000", "--workers", "3", "--access-logfile", "-", "--error-logfile", "-", "--log-level", "info", "config.wsgi:application"]
python manage.py migrate && \
python manage.py collectstatic --noinput && \
gunicorn config.wsgi:application --bind 0.0.0.0:8000 --workers 3