-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
64 lines (44 loc) · 1.96 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
56
57
58
59
60
61
62
63
64
####################################################
# Base node image for dev + builder
####################################################
FROM node:9.6.1 AS dev
LABEL maintainer "Charlie McClung <charlie@bowtie.co>"
# Install chrome
RUN printf "deb http://archive.debian.org/debian/ jessie main\ndeb-src http://archive.debian.org/debian/ jessie main\ndeb http://security.debian.org jessie/updates main\ndeb-src http://security.debian.org jessie/updates main" > /etc/apt/sources.list
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
RUN apt-get update && apt-get install -yq google-chrome-stable
# Set working directory
RUN mkdir /usr/src/app
WORKDIR /usr/src/app
# Add `/usr/src/app/node_modules/.bin` to $PATH
ENV PATH /usr/src/app/node_modules/.bin:$PATH
# install and cache app dependencies
COPY package.json package-lock.json /usr/src/app/
RUN npm install
# Add app
COPY . /usr/src/app
# Start app
CMD [ "npm", "start" ]
####################################################
# run builder from dev for both staging & production
####################################################
FROM dev as builder
LABEL maintainer "Charlie McClung <charlie@bowtie.co>"
ENV BASE_DIR /app
RUN mkdir -p ${BASE_DIR}
RUN npm run build:staging && mv dist/atomic-angular-demo ${BASE_DIR}/staging
RUN npm run build:production && mv dist/atomic-angular-demo ${BASE_DIR}/production
####################################################
# run staging/production environment (based on ENV)
####################################################
FROM nginx:1.13.9-alpine
LABEL maintainer "Charlie McClung <charlie@bowtie.co>"
ENV BASE_DIR /app
RUN rm -rf /etc/nginx/conf.d
COPY nginx-entrypoint.sh /
COPY nginx /etc/nginx
COPY --from=builder ${BASE_DIR} ${BASE_DIR}
EXPOSE 80
ENTRYPOINT [ "/nginx-entrypoint.sh" ]
CMD ["nginx", "-g", "daemon off;"]