Commit 3faa31f9 authored by Administrator's avatar Administrator

Update Dockerfile

parent c1afbc45
Pipeline #600 failed with stages
in 1 second
FROM node:latest as build
RUN apt-get update && apt-get install -y --no-install-recommends git && mkdir -p /usr/src/app/ && rm -rf /var/lib/apt/lists/*
RUN npm install -g @angular/cli
RUN npm install -g npm@latest
ENV NODE_PATH=/usr/local/lib/node_modules/:/usr/local/lib NODE_ENV=production
WORKDIR /usr/src/app
COPY package.json /usr/src/app/
RUN npm install
RUN npm install node-sass@latest
COPY . /usr/src/app/
RUN ng build --sourcemap=false
FROM nginx:latest
### STAGE 1: Build ###
# We label our stage as 'builder'
FROM node:9-alpine as builder
COPY package.json package-lock.json ./
RUN npm set progress=false && npm config set depth 0 && npm cache clean --force
## Storing node modules on a separate layer will prevent unnecessary npm installs at each build
RUN npm i && mkdir /ng-app && cp -R ./node_modules ./ng-app
WORKDIR /ng-app
COPY . .
## Build the angular app in production mode and store the artifacts in dist folder
RUN $(npm bin)/ng build --prod
### STAGE 2: Setup ###
FROM nginx:1.13.3-alpine
## Copy our default nginx config
COPY nginx/default.conf /etc/nginx/conf.d/
## Remove default nginx website
RUN rm -rf /usr/share/nginx/html/*
COPY --from=build /usr/src/app/dist /usr/share/nginx/html
CMD ["nginx", "-g", "daemon off;"]
\ No newline at end of file
## From 'builder' stage copy over the artifacts in dist folder to default nginx public folder
COPY --from=builder /ng-app/dist /usr/share/nginx/html
CMD ["nginx", "-g", "daemon off;"]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment