balaji958685 commited on
Commit
cf295d6
Β·
verified Β·
1 Parent(s): 62fe604

Add frontend Dockerfile

Browse files
Files changed (1) hide show
  1. frontend/Dockerfile +38 -0
frontend/Dockerfile ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ─── SmartClass Frontend ─────────────────────────────────────────────
2
+ # Stage 1: Build React app
3
+ FROM node:20-alpine AS builder
4
+
5
+ WORKDIR /app
6
+
7
+ # Install dependencies
8
+ COPY package.json package-lock.json ./
9
+ RUN npm ci
10
+
11
+ # Build argument for API URL (baked into build)
12
+ ARG VITE_API_URL=http://localhost:8000
13
+ ENV VITE_API_URL=${VITE_API_URL}
14
+
15
+ # Copy source and build
16
+ COPY . .
17
+ RUN npm run build
18
+
19
+ # Stage 2: Serve with nginx
20
+ FROM nginx:alpine AS production
21
+
22
+ LABEL maintainer="SmartClass Team"
23
+ LABEL description="SmartClass Frontend - React + Nginx"
24
+
25
+ # Custom nginx configuration
26
+ COPY nginx.conf /etc/nginx/conf.d/default.conf
27
+
28
+ # Copy built app from builder stage
29
+ COPY --from=builder /app/dist /usr/share/nginx/html
30
+
31
+ # Expose port 80
32
+ EXPOSE 80
33
+
34
+ # Health check
35
+ HEALTHCHECK --interval=15s --timeout=5s --retries=3 \
36
+ CMD wget --no-verbose --tries=1 --spider http://127.0.0.1:80/ || exit 1
37
+
38
+ CMD ["nginx", "-g", "daemon off;"]