Skip to content

Commit 962b062

Browse files
committed
optimize docker build
1 parent 5e49764 commit 962b062

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
# Stage 1: build the application
2-
FROM nginx:alpine AS build-nginx
2+
FROM node:19 as build-app
33
WORKDIR /app
4-
RUN apk add nodejs npm
54
COPY . .
65
RUN npm i
76
RUN npm run build
7+
8+
# Stage 2: Build nginx
9+
FROM nginx:alpine AS build-nginx
10+
WORKDIR /usr/share/nginx/html/
11+
COPY --from=build-app /app/public /usr/share/nginx/html/
812
RUN rm -rf /etc/nginx/conf.d/*
913
COPY nginx.conf /etc/nginx/
10-
COPY public /usr/share/nginx/html/
1114
EXPOSE 80
1215

1316
# Stage 2: final image

0 commit comments

Comments
 (0)