Skip to content

Commit cb27c61

Browse files
authored
Update Dockerfile
1 parent 851eae4 commit cb27c61

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

frontend/Dockerfile

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,27 @@
1-
FROM node:20
1+
# --- Stage 1: Build React app ---
2+
FROM node:18 AS build
23
WORKDIR /app
3-
COPY package.json ./
4+
5+
# Install dependencies
6+
COPY package.json package-lock.json ./
47
RUN npm install
8+
9+
# Copy source and build
510
COPY . .
6-
EXPOSE 8080
7-
CMD ["npm", "start"]
11+
RUN npm run build
12+
13+
# --- Stage 2: Serve with Nginx ---
14+
FROM nginx:alpine
15+
WORKDIR /usr/share/nginx/html
16+
17+
# Remove default nginx index page
18+
RUN rm -rf ./*
19+
20+
# Copy built React app from builder
21+
COPY --from=build /app/build .
22+
23+
# Copy custom nginx config
24+
COPY nginx.conf /etc/nginx/conf.d/default.conf
25+
26+
EXPOSE 80
27+
CMD ["nginx", "-g", "daemon off;"]

0 commit comments

Comments
 (0)