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.
This commit is contained in:
2026-06-13 22:42:16 +02:00
parent f4c6a56d1c
commit 99ac83c706
2 changed files with 77 additions and 24 deletions
+18 -16
View File
@@ -1,24 +1,26 @@
FROM python:3.12-slim
FROM python:3.12-alpine
WORKDIR /app
# Poster rendering needs:
# - libcairo2 (cairosvg ↔ Cairo bindings) for SVG → PNG raster
# - fonts-dejavu-core for the DejaVuSans-Bold font used by PostersService
# These add ~15 MB to the image but keep poster generation in-process and fast.
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libcairo2 \
fonts-dejavu-core \
&& rm -rf /var/lib/apt/lists/*
# 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 \
fastf1 \
python-slugify \
pillow \
cairosvg
fastapi \
uvicorn \
python-slugify \
pillow \
cairosvg \
numpy
COPY cdn-api.py circuits_service.py ergast_service.py posters_service.py ./
COPY models/ ./models/