alternative-backend-service/dockerfile
saani e722cbe311 refactor(docker): replace uv with pip and move Django commands to runtime
Replace uv package manager with standard pip for dependency management.
Switch base image from debian:bookworm-slim to python:3.12-slim to include
Python runtime by default.

Key changes:
- Remove uv installation and configuration
- Use requirements.txt instead of pyproject.toml/uv.lock
- Install dependencies with pip instead of uv sync
- Move collectstatic and migrate from build-time to runtime in CMD
- Simplify gunicorn command invocation

This simplifies the build process and makes the image more portable by
using standard Python tooling. Running migrations and collectstatic at
container startup ensures they execute against the correct database and
storage backend.
2025-11-23 19:12:27 +00:00

33 lines
670 B
Plaintext

FROM python:3.12-slim
# Environment settings
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Set work directory
WORKDIR /app
# System dependencies
RUN apt-get update && apt-get install -y \
build-essential \
curl wget \
&& rm -rf /var/lib/apt/lists/*
# Copy dependency file
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy project files
COPY . .
# Expose port
EXPOSE 8000
# Run migrations + collectstatic + gunicorn at runtime
CMD \
python manage.py migrate && \
python manage.py collectstatic --noinput && \
gunicorn config.wsgi:application --bind 0.0.0.0:8000 --workers 3