GET /posters/race/{grand_prix_name}/{season}.png
GET /posters/season/{season}.png
1000x1500 PNGs composed with Pillow + cairosvg:
checkered-flag strips top/bottom, F1 wordmark, round/year ribbon,
GP name, rasterised track outline (white), race date. Season poster
is wordmark + giant year + 'WORLD CHAMPIONSHIP'. Cached under
cache/posters/ so cold renders happen once.
30 lines
777 B
Docker
30 lines
777 B
Docker
FROM python:3.12-slim
|
|
|
|
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/*
|
|
|
|
RUN pip install --no-cache-dir \
|
|
fastapi \
|
|
uvicorn \
|
|
fastf1 \
|
|
python-slugify \
|
|
pillow \
|
|
cairosvg
|
|
|
|
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"]
|