Files
f1-circuits/service/Dockerfile
jschoubben 99ac83c706 Use season hero photos as poster bg + switch image to Alpine
posters_service.render_season_poster() now fetches /dilbert/sports/
formula1/cars/{year}.jpg from the files-api CDN, centre-crops to 2:3,
and composites a vertical dark gradient so the FORMULA 1 / year /
WORLD CHAMPIONSHIP text stays legible over any photo.

Dockerfile:
  - python:3.12-slim → python:3.12-alpine (smaller, no fastf1 leftover)
  - fonts-dejavu-core → ttf-liberation: same font Arch dev ships, so
    posters render byte-identical on dev and in the container.
  - Drop fastf1 (unused in the served code path); add numpy explicitly
    because models/geo_json/geometry.py imports it at module load.
2026-06-13 22:42:16 +02:00

32 lines
951 B
Docker

FROM python:3.12-alpine
WORKDIR /app
# Runtime deps:
# - cairo provides libcairo so cairosvg can rasterise SVG → PNG.
# - ttf-liberation gives Liberation Sans Bold at
# /usr/share/fonts/liberation/LiberationSans-Bold.ttf — exactly where Arch
# installs it, so dev (shanks) and prod (this container) render with the
# same font and the posters come out identical.
RUN apk add --no-cache \
cairo \
ttf-liberation
# All pip deps ship musllinux wheels — no build-deps needed.
# numpy is pulled in by models/geo_json/geometry.py for vector ops at import time.
RUN pip install --no-cache-dir \
fastapi \
uvicorn \
python-slugify \
pillow \
cairosvg \
numpy
COPY cdn-api.py circuits_service.py ergast_service.py posters_service.py ./
COPY models/ ./models/
COPY circuits/ ./circuits/
EXPOSE 8000
CMD ["uvicorn", "cdn-api:app", "--host", "0.0.0.0", "--port", "8000"]