-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
67 lines (50 loc) · 1.66 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
FROM node:14-alpine as builder
ARG CACHE_PORT=8080
ARG PORT=8081
ARG HOST='0.0.0.0'
ENV HOST=$HOST \
PORT=$PORT \
CACHE_PORT=$CACHE_PORT \
TERM=xterm \
LANG=en_US.UTF-8 \
TZ='Europe/Moscow' \
NO_UPDATE_NOTIFIER=true \
NPM_CONFIG_USERCONFIG=/tmp/.npmrc \
NPM_CONFIG_CACHE=/tmp/npm-cache \
NPM_CONFIG_PREFIX=/tmp/npm-global
RUN apk add --no-cache yarn \
&& mkdir -p /usr/share/app && chown 1001:0 /usr/share/app \
&& mkdir -p /tmp/npm-cache \
&& mkdir -p /tmp/npm-global
WORKDIR /usr/share/app
COPY package.json .
RUN yarn --no-progress --silent
COPY . .
ARG NODE_ENV=production
ENV NODE_ENV $NODE_ENV
RUN sh ./bin/build.sh
# Change $PORT in Varnish config because constant is expected
RUN sed -i "s/\${PORT}/\"$PORT\"/g" ./config/varnish.vcl
FROM node:14-alpine as runner
ARG CACHE_PORT=8080
ARG PORT=8081
ARG HOST='0.0.0.0'
ARG NODE_ENV=production
ENV HOST=$HOST \
PORT=$PORT \
CACHE_PORT=$CACHE_PORT \
NODE_ENV=$NODE_ENV
WORKDIR /usr/share/app
RUN apk add --no-cache varnish=~6 \
&& mkdir -p ./varnish \
&& chown -R 1001:0 .
COPY --from=builder --chown=1001:0 /usr/share/app/bin ./bin
COPY --from=builder --chown=1001:0 /usr/share/app/config/varnish.vcl ./config/varnish.vcl
COPY --from=builder --chown=1001:0 /usr/share/app/dist ./dist
COPY --from=builder --chown=1001:0 /usr/share/app/static ./static
COPY --from=builder --chown=1001:0 /usr/share/app/node_modules/full-icu ./node_modules/full-icu
COPY --from=builder --chown=1001:0 /usr/share/app/node_modules/react-loadable ./node_modules/react-loadable
EXPOSE $CACHE_PORT
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 CMD [ "./bin/healthcheck.sh" ]
USER 1001
CMD [ "./bin/start.sh" ]