-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
102 lines (73 loc) · 3.09 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# ================ Unit test stage ================
FROM markadams/chromium-xvfb as test
# Build args required to work behind proxy
ARG http_proxy
ARG https_proxy
# Install curl (used to install nodejs) and build-essential (for compiling native nodejs libraries)
RUN apt-get update -qq && apt-get install -qqy curl build-essential git
# Install nodejs and update npm to latest version
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
RUN apt-get update -qq && apt-get install -y nodejs
WORKDIR /research-hub-web/
# Copies files required to install dependencies
COPY /package.json .
COPY /angular.json .
COPY /tsconfig.json .
COPY /tslint.json .
COPY /protractor.conf.js .
COPY /karma.conf.js .
COPY /e2e ./e2e
# Install dependencies
RUN npm install
# Copy sources
COPY /src ./src
# Run the unit tests
# They are not currently run as there are problems
# when run on the CI server.
#RUN npm run ci-test
# ================ Prepare stage ================
FROM nginx as prepare
# Build args required to work behind proxy
ARG http_proxy
ARG https_proxy
# Install curl (used to install nodejs) and build-essential (for compiling native nodejs libraries)
RUN apt-get update -qq && apt-get install -qqy curl build-essential git
# Install nodejs and update npm to latest version
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
RUN apt-get update -qq && apt-get install -y nodejs
WORKDIR /research-hub-web/
# Copy node_modules from test stage
COPY --from=test ./research-hub-web/node_modules ./node_modules
# ================ Local development stage ================
FROM prepare as local
WORKDIR /research-hub-web/
VOLUME ["./package.json","./angular.json","./tsconfig.json","./tslint.json","./protractor.conf.js","./karma.conf.js","./e2e","./src","./src/assets/env.js"]
COPY docker-entrypoint.sh ./
ENTRYPOINT ["./docker-entrypoint.sh","--local"]
# ================ Build stage ================
FROM prepare as build
# Copies files required to install dependencies
COPY /package.json .
COPY /angular.json .
COPY /tsconfig.json .
COPY /tslint.json .
COPY /protractor.conf.js .
COPY /karma.conf.js .
COPY /e2e ./e2e
RUN npm rebuild
# Copy sources
COPY /src ./src
# Build
RUN node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng build --prod
# ================ Clean stage ================
FROM nginx as clean
# Build args required to work behind proxy
ARG http_proxy
ARG https_proxy
# Copy dist from building stage
COPY --from=build ./research-hub-web/dist /usr/share/nginx/www
# Configure nginx
COPY /nginx.conf /etc/nginx/nginx.conf
# Custom entrypoint to copy over env.js at runtime from volume
COPY ./docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]