-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
49 lines (42 loc) · 1.89 KB
/
Copy pathDockerfile
File metadata and controls
49 lines (42 loc) · 1.89 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
46
47
48
49
# syntax=docker/dockerfile:1
#
# idea2spec — single-image build for Render.
#
# Mirrors interview-lab's architecture (deliberately single-process, see
# AGENTS.md): one uvicorn serves both the JSON API and the built SPA. So
# unlike a typical two-service (frontend + backend) deploy, we do NOT need a
# separate nginx/Next.js container — FastAPI's StaticFiles + the /api route
# alias in services/api/main.py serve the Next.js static export directly.
#
# Stage 1 node — build the Next.js static export -> out/
# Stage 2 python — FastAPI runtime that serves API + SPA from one process
# ---------- Stage 1: build the Next.js static export ----------
FROM node:22-alpine AS web-build
WORKDIR /web
# package-lock.json is committed; npm ci gives a reproducible install
COPY apps/web/package.json apps/web/package-lock.json ./
RUN npm ci
COPY apps/web/ ./
# `output: 'export'` (see next.config.js — enabled during PHASE_PRODUCTION_BUILD)
# writes the static site to out/
RUN npm run build
# ---------- Stage 2: FastAPI runtime ----------
FROM python:3.12-slim
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
APP_ENV=production
WORKDIR /app
# Install Python deps (all pinned deps ship wheels; no apt packages needed).
COPY requirements.txt requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# Backend source. The repo-root layout must be preserved (services/,
# packages/, scripts/) because paths are derived from __file__ — e.g.
# services/api/db.py locates scripts/init_db.sql via parents[2].
COPY services/ services/
COPY packages/ packages/
COPY scripts/ scripts/
# Built SPA — served from webapp/dist relative to cwd (see services/api/main.py)
COPY --from=web-build /web/out webapp/dist
# Render injects $PORT (default 10000); 5101 is only the local-docker fallback.
EXPOSE 5101
CMD ["sh", "-c", "python -m uvicorn services.api.main:app --host 0.0.0.0 --port ${PORT:-5101}"]