# Backend image: FastAPI + APScheduler + Alembic + scrapers. # # Keeps the image small (python:3.12-slim) and the layer cache hot by copying # only pyproject.toml first and installing deps before the source lands. The # same image serves both the API (uvicorn) and the scheduler # (``python -m app.sync.cli scheduler``) — the docker-compose ``command:`` key # selects which entrypoint runs. FROM python:3.12-slim # Build-time / runtime deps for asyncmy (compiled C extension) + httpx + # cryptography.``libmariadb`` is what asyncmy links against on Debian. RUN apt-get update \ && apt-get install -y --no-install-recommends \ build-essential \ libmariadb-dev \ libffi-dev \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # Install dependencies first (cache-friendly: only re-installs when # pyproject.toml changes). The project itself is installed in editable-like # mode by copying the package in afterwards. COPY pyproject.toml ./ COPY app/__init__.py app/__init__.py COPY app/ ./app/ # Install the package + dev dependencies (the dev extras include aiosqlite + # pytest, which are tiny and convenient for in-container smoke checks). Pin # the install to the local source so the package import path resolves. RUN pip install --no-cache-dir -e ".[dev]" # Default command — overridden per-service in docker-compose. The API service # runs uvicorn; the scheduler service runs the CLI. CMD ["uvicorn", "app.api.main:app", "--host", "0.0.0.0", "--port", "8000"]