-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
45 lines (36 loc) · 1.78 KB
/
Copy pathDockerfile
File metadata and controls
45 lines (36 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
FROM python:3.12-slim
# Faster, more reproducible installs.
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_NO_CACHE_DIR=1
WORKDIR /app
# Slim image needs build-essential only because psycopg[binary] ships its
# own libpq — no system libpq required. fal-client / pillow are gone, so
# the build is much lighter than the previous iteration.
RUN apt-get update \
&& apt-get install -y --no-install-recommends build-essential \
&& rm -rf /var/lib/apt/lists/*
# Install Python deps first (better Docker layer caching). requirements.txt
# is the source of truth — pyproject.toml is kept for local editable installs
# (`pip install -e .`) but Docker uses the pinned list.
COPY requirements.txt ./
RUN pip install --upgrade pip && pip install -r requirements.txt
# `python -m backend.migrate` is invoked from render.yaml's preDeployCommand
# and needs psycopg. Pull it in here because it's not a runtime dep of the
# server itself, so it's intentionally absent from requirements.txt.
RUN pip install "psycopg[binary]>=3.2"
# App code.
COPY backend ./backend
# Local-fallback upload storage. The primary path is Supabase Storage; this
# directory only matters when `SUPABASE_URL` / `SUPABASE_SERVICE_ROLE_KEY`
# are unset (dev). Render rewrites this dir on every deploy — Supabase
# Storage is the only durable surface in production.
RUN mkdir -p ./storage
ENV STORAGE_DIR=/app/storage
EXPOSE 8000
ENV PORT=8000
# Honour $PORT (Render, Fly, Cloud Run all set this). Bind 0.0.0.0 for the
# container's external interface. proxy-headers + forwarded-allow-ips make
# FastAPI trust the X-Forwarded-* headers Render injects at the edge.
CMD ["sh", "-c", "uvicorn backend.main:app --host 0.0.0.0 --port ${PORT:-8000} --proxy-headers --forwarded-allow-ips='*'"]