Files
kennethreitz.org/Dockerfile
T
kennethreitz 8267a8e646 Performance: add GZip compression, externalize CSS, bump cache, reduce workers
- Add Starlette GZipMiddleware for response compression (~60% smaller HTML)
- Extract 290 lines of inline CSS to /static/site.css (browser-cacheable)
- Bump HTML Cache-Control from 5min to 1hr
- Reduce Granian workers from 4 to 2 (matches shared-cpu-2x)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 17:43:17 -04:00

30 lines
892 B
Docker

FROM astral/uv:python3.14-bookworm
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
UV_SYSTEM_PYTHON=1
WORKDIR /app
# Install system dependencies for WeasyPrint (PDF generation)
RUN apt-get update && apt-get install -y \
libcairo2 \
libpango-1.0-0 \
libpangocairo-1.0-0 \
libgdk-pixbuf2.0-0 \
libffi-dev \
shared-mime-info \
&& rm -rf /var/lib/apt/lists/*
# Copy dependency files and required package files
COPY pyproject.toml README.md ./
COPY tuftecms ./tuftecms
# Install dependencies directly without creating a venv (since we're in a container)
RUN uv pip install . --system
# Copy the rest of the application
COPY . .
CMD ["granian", "--interface", "asgi", "--host", "0.0.0.0", "--port", "8000", "--workers", "2", "--static-path-route", "/static", "--static-path-mount", "tuftecms/static", "--static-path-expires", "604800", "engine:api"]