krishpotanwar commited on
Commit
cd52852
·
1 Parent(s): f86ef5b

fix(deploy): build frontend in node stage

Browse files
Files changed (1) hide show
  1. Dockerfile +16 -7
Dockerfile CHANGED
@@ -1,14 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  FROM python:3.11-slim
2
 
3
  WORKDIR /app
4
 
5
- # System deps + Node.js for frontend build
6
  RUN apt-get update && apt-get install -y --no-install-recommends \
7
  curl \
8
- gnupg \
9
- && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
10
- && apt-get install -y --no-install-recommends \
11
- nodejs \
12
  && rm -rf /var/lib/apt/lists/*
13
 
14
  # Copy & install Python deps first for layer caching
@@ -18,8 +27,8 @@ RUN pip install --no-cache-dir -r requirements.txt
18
  # Copy application
19
  COPY . .
20
 
21
- # Build the copied React frontend so FastAPI can serve it at /
22
- RUN cd frontend && npm ci && npm run build
23
 
24
  # Install package so [project.scripts] is callable
25
  RUN pip install --no-cache-dir -e .
 
1
+ FROM node:20-slim AS frontend-build
2
+
3
+ WORKDIR /frontend
4
+
5
+ COPY frontend/package.json frontend/package-lock.json ./
6
+ COPY frontend/tsconfig.json frontend/tsconfig.app.json frontend/tsconfig.node.json ./
7
+ COPY frontend/vite.config.ts frontend/eslint.config.js frontend/index.html ./
8
+ COPY frontend/public ./public
9
+ COPY frontend/src ./src
10
+
11
+ RUN npm ci && npm run build
12
+
13
+
14
  FROM python:3.11-slim
15
 
16
  WORKDIR /app
17
 
18
+ # System deps
19
  RUN apt-get update && apt-get install -y --no-install-recommends \
20
  curl \
 
 
 
 
21
  && rm -rf /var/lib/apt/lists/*
22
 
23
  # Copy & install Python deps first for layer caching
 
27
  # Copy application
28
  COPY . .
29
 
30
+ # Copy the built frontend bundle from the Node stage so FastAPI can serve it at /
31
+ COPY --from=frontend-build /frontend/dist ./frontend/dist
32
 
33
  # Install package so [project.scripts] is callable
34
  RUN pip install --no-cache-dir -e .