Revize 5bbe3b0b
Přidáno uživatelem Pavel Fidransky před více než 4 roky(ů)
client/Dockerfile | ||
---|---|---|
1 |
#src: https://mherman.org/blog/dockerizing-an-angular-app/ |
|
2 | 1 |
############# |
3 | 2 |
### build ### |
4 | 3 |
############# |
... | ... | |
6 | 5 |
# base image |
7 | 6 |
FROM node:12.2.0 as build |
8 | 7 |
|
9 |
# install chrome for protractor tests |
|
10 |
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - |
|
11 |
RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' |
|
12 |
RUN apt-get update && apt-get install -yq google-chrome-stable |
|
13 |
|
|
14 | 8 |
# set working directory |
15 | 9 |
WORKDIR /app |
16 | 10 |
|
17 | 11 |
# add `/app/node_modules/.bin` to $PATH |
18 | 12 |
ENV PATH /app/node_modules/.bin:$PATH |
19 | 13 |
|
14 |
# copy package.json and package-lock.json to container |
|
15 |
COPY package.json package-lock.json ./ |
|
16 |
|
|
20 | 17 |
# install and cache app dependencies |
21 |
COPY package.json /app/package.json |
|
22 | 18 |
RUN npm install |
23 |
RUN npm install -g @angular/cli@8.3.8 |
|
24 | 19 |
|
25 | 20 |
# add app |
26 | 21 |
COPY . /app |
27 | 22 |
|
28 | 23 |
# run tests - COMMENTED, later |
29 |
#RUN ng test --watch=false |
|
30 |
#RUN ng e2e --port 4202 |
|
24 |
#RUN npm run test |
|
31 | 25 |
|
32 | 26 |
# generate build |
33 |
RUN ng build --output-path=dist
|
|
27 |
RUN npm run build
|
|
34 | 28 |
|
35 | 29 |
############ |
36 | 30 |
### prod ### |
37 | 31 |
############ |
38 | 32 |
|
33 |
# inspired by https://torstenwalter.de/openshift/nginx/2017/08/04/nginx-on-openshift.html |
|
34 |
|
|
39 | 35 |
# base image |
40 | 36 |
FROM nginx:1.16.0-alpine |
41 | 37 |
|
38 |
# support running as arbitrary user which belogs to the root group |
|
39 |
RUN chmod g+rwx /var/cache/nginx /var/run /var/log/nginx |
|
40 |
|
|
41 |
# expose port 8081 |
|
42 |
EXPOSE 8081 |
|
43 |
|
|
44 |
# comment user directive as master process is run as user in OpenShift anyhow |
|
45 |
RUN sed -i.bak 's/^user/#user/' /etc/nginx/nginx.conf |
|
46 |
|
|
42 | 47 |
# copy nginx configuration |
43 | 48 |
COPY nginx.conf /etc/nginx/conf.d/default.conf |
44 | 49 |
|
45 | 50 |
# copy artifact build from the 'build environment' |
46 |
COPY --from=build /app/dist /usr/share/nginx/html |
|
47 |
|
|
48 |
# expose port 80 |
|
49 |
EXPOSE 80 |
|
51 |
COPY --from=build /app/build /usr/share/nginx/html |
|
50 | 52 |
|
51 | 53 |
# run nginx |
52 | 54 |
CMD ["nginx", "-g", "daemon off;"] |
Také k dispozici: Unified diff
Docker image build config