-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
49 lines (37 loc) · 2.21 KB
/
Copy pathDockerfile
File metadata and controls
49 lines (37 loc) · 2.21 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
# ─────────────────────────────────────────────────────────────────────────────
# Stage 1: Build the React frontend
# ─────────────────────────────────────────────────────────────────────────────
FROM node:20-alpine AS frontend-build
WORKDIR /frontend
# Install deps first (layer cached unless package.json changes)
COPY frontend/package.json frontend/package-lock.json ./
RUN npm ci
# Copy source and build
COPY frontend/ ./
RUN npm run build
# Output: /frontend/dist
# ─────────────────────────────────────────────────────────────────────────────
# Stage 2: Python backend + serve built frontend
# ─────────────────────────────────────────────────────────────────────────────
FROM python:3.11-slim AS final
# System deps needed by some Python packages (argon2-cffi, psycopg, etc.)
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc libpq-dev git \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Install Python dependencies
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
# Copy application source
COPY app/ ./app/
COPY core/ ./core/
COPY integrations/ ./integrations/
COPY utils/ ./utils/
COPY main.py ./
# Copy the built React frontend from stage 1
COPY --from=frontend-build /frontend/dist ./frontend/dist
# Railway injects $PORT at runtime — do NOT hardcode it here.
# EXPOSE is documentation only; Railway routes via $PORT env var.
EXPOSE 8080
# Start FastAPI: echo the port for deploy log visibility, then exec uvicorn.
CMD ["sh", "-c", "echo \">>> Starting uvicorn on port ${PORT:-8080}\" && exec uvicorn app.api:app --host 0.0.0.0 --port ${PORT:-8080}"]