-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
41 lines (28 loc) · 898 Bytes
/
Dockerfile
File metadata and controls
41 lines (28 loc) · 898 Bytes
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
#
# Railway single-service deployment for monorepo:
# - Build React/Vite frontend
# - Run FastAPI backend (and serve built frontend assets)
#
### Stage 1: build frontend
FROM node:20.19-alpine AS web
WORKDIR /app/client
COPY client/package.json client/package-lock.json ./
RUN npm ci
# Build-time API base URL (same-origin by default)
ARG VITE_API_BASE_URL=/api/v1
ENV VITE_API_BASE_URL=$VITE_API_BASE_URL
COPY client/ ./
RUN npm run build
### Stage 2: run backend
FROM python:3.12-slim AS api
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONPATH=/app/api \
SERVE_CLIENT=true
WORKDIR /app/api
COPY api/requirements.txt ./requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
COPY api/ ./
# Copy built frontend into FastAPI container
COPY --from=web /app/client/dist ./static
CMD ["sh", "-c", "uvicorn main:app --host 0.0.0.0 --port ${PORT:-8000}"]