Updated Dockerfile to be faster and more secure #6
1 changed files with 10 additions and 2 deletions
12
Dockerfile
12
Dockerfile
|
@ -1,13 +1,21 @@
|
||||||
# build stage
|
# build stage
|
||||||
FROM node:lts-alpine as build-stage
|
FROM node:lts-alpine as build-stage
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package*.json ./
|
COPY package.json package-lock.json ./
|
||||||
RUN npm install
|
RUN npm ci --omit=dev
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
# production stage
|
# production stage
|
||||||
FROM nginx:stable-alpine as production-stage
|
FROM nginx:stable-alpine as production-stage
|
||||||
|
|
||||||
|
# Remove default Nginx index page
|
||||||
|
RUN rm -rf /usr/share/nginx/html/*
|
||||||
|
# Copy built files from build stage
|
||||||
COPY --from=build-stage /app/dist /usr/share/nginx/html
|
COPY --from=build-stage /app/dist /usr/share/nginx/html
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
|
# Use a non-root user for security
|
||||||
|
USER nginx
|
||||||
|
|
||||||
CMD ["nginx", "-g", "daemon off;"]
|
CMD ["nginx", "-g", "daemon off;"]
|
Loading…
Add table
Reference in a new issue