havinashpatil commited on
Commit
43ecf30
·
1 Parent(s): da3a03d

Fix Dockerfile with multi-stage build for frontend

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -14
Dockerfile CHANGED
@@ -1,24 +1,22 @@
1
- FROM python:3.10-slim
2
-
3
- WORKDIR /app
4
 
5
- # Install Node.js for building frontend
6
- RUN apt-get update && apt-get install -y --no-install-recommends \
7
- build-essential \
8
- curl \
9
- && curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
10
- && apt-get install -y nodejs \
11
- && rm -rf /var/lib/apt/lists/*
12
-
13
- # Build frontend
14
- COPY frontend/package*.json ./frontend/
15
  WORKDIR /app/frontend
 
 
16
  RUN npm install
17
- COPY frontend/ .
 
18
  RUN npm run build
19
 
 
 
 
20
  WORKDIR /app
21
 
 
 
 
22
  # Install Python dependencies
23
  COPY requirements.txt .
24
  RUN pip install --no-cache-dir -r requirements.txt
 
1
+ # Multi-stage build: Build frontend with Node.js
2
+ FROM node:18-alpine AS frontend-builder
 
3
 
 
 
 
 
 
 
 
 
 
 
4
  WORKDIR /app/frontend
5
+
6
+ COPY frontend/package*.json ./
7
  RUN npm install
8
+
9
+ COPY frontend/ ./
10
  RUN npm run build
11
 
12
+ # Main stage: Python app
13
+ FROM python:3.10-slim
14
+
15
  WORKDIR /app
16
 
17
+ # Copy built frontend
18
+ COPY --from=frontend-builder /app/frontend/dist ./frontend/dist
19
+
20
  # Install Python dependencies
21
  COPY requirements.txt .
22
  RUN pip install --no-cache-dir -r requirements.txt