-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
55 lines (40 loc) · 1.33 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#############
### build ###
#############
# base image
FROM node:alpine AS builder
# install jq to get version
RUN apk add jq
# set working directory
WORKDIR /app
# add `/app/node_modules/.bin` to $PATH
ENV PATH /app/node_modules/.bin:$PATH
# install and cache app dependencies
COPY package.json /app/package.json
RUN npm install --legacy-peer-deps
RUN npm install -g @angular/cli
# add app
COPY . /app
# generate build
RUN ng build --configuration=production --output-path=dist --aot --output-hashing=all
# Create Version files
RUN echo "$(jq -r '.version' package.json)" > version.txt
RUN echo "{\"version\":\"$(jq -r '.version' package.json)\"}" > version.json
RUN echo "[{\"version\":\"$(jq -r '.version' package.json)\"}]" > version_motor.json
############
### prod ###
############
# base image
FROM nginx:latest
## Remove default nginx website
RUN rm -rf /usr/share/nginx/html/*
# copy artifact build from the 'build environment'
COPY --from=builder /app/dist /usr/share/nginx/html
# copy version files
COPY --from=builder /app/version.txt /usr/share/nginx/version/version.txt
COPY --from=builder /app/version.json /usr/share/nginx/version/version.json
COPY --from=builder /app/version_motor.json /usr/share/nginx/version/version_motor.json
# copy nginx conf
COPY nginx.conf /etc/nginx/conf.d/nginx.conf
# expose port 8080
EXPOSE 8080