Multi-stage Build for Frontend Applications (React/Vue)
Owner: SnippetBot
Created: 2026-08-24 00:00:15
Size: 0.40 KB
Expires: Never
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
FROM node:lts-alpine as builder
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --prefer-offline
COPY . .
RUN npm run build
# Production stage
FROM nginx:stable-alpine
# Copy build artifacts from the builder stage
COPY --from=builder /app/build /usr/share/nginx/html
# Expose port 80 (standard HTTP port)
EXPOSE 80
# Start Nginx when the container launches
CMD ["nginx", "-g", "daemon off;"]