# Two images from one file: # docker build --target prod . - runtime only: no pytest/mypy, no tests, no personal notes # docker build --target dev . - prod + dev tools, tests and notes (docker compose uses it) FROM python:3.13-slim AS base WORKDIR /app ENV PYTHONPATH=/app # Copy requirements first for better caching COPY requirements.txt ./ RUN pip install --no-cache-dir -r requirements.txt COPY alembic.ini ./ COPY ./app ./app COPY ./migrations ./migrations EXPOSE 8000 FROM base AS prod CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"] # The last stage is the default target. The project is developed only in Docker, so the dev # tools (pytest, mypy) live in this image. FROM base AS dev COPY requirements-dev.txt pyproject.toml ./ RUN pip install --no-cache-dir -r requirements-dev.txt COPY ./data ./data COPY ./tests ./tests # Command will be overridden by docker-compose CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]