-
-
Notifications
You must be signed in to change notification settings - Fork 86
/
Dockerfile
91 lines (88 loc) · 2.61 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
FROM node:18.17.1-alpine as base
WORKDIR /app
RUN mkdir -p dist node_modules .yarn-cache && chown -R node:node .
FROM base as build
ARG API_URL
ARG UPLOAD_URL
ARG DATA_URL
ARG BLIP_URL
ARG REALM_HOST
ARG PORT=3001
ARG SERVICE_NAME=uploader
ARG ROLLBAR_POST_SERVER_TOKEN
ARG I18N_ENABLED=false
ARG RX_ENABLED=false
ARG PENDO_ENABLED=true
ARG TRAVIS_COMMIT
# Set ENV from ARGs
ENV \
API_URL=$API_URL \
UPLOAD_URL=$UPLOAD_URL \
DATA_URL=$DATA_URL \
BLIP_URL=$BLIP_URL \
REALM_HOST=$REALM_HOST \
PORT=$PORT \
SERVICE_NAME=$SERVICE_NAME \
ROLLBAR_POST_TOKEN=$ROLLBAR_POST_SERVER_TOKEN \
I18N_ENABLED=$I18N_ENABLED \
RX_ENABLED=$RX_ENABLED \
PENDO_ENABLED=$PENDO_ENABLED \
TRAVIS_COMMIT=$TRAVIS_COMMIT \
NODE_ENV=development
# Install dependancies
RUN \
echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \
&& echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \
&& echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
&& apk --no-cache update \
&& apk --no-cache upgrade \
&& apk add --no-cache --virtual .build-deps alpine-sdk python3 linux-headers eudev-dev ffmpeg-dev \
&& rm -rf /var/cache/apk/* /tmp/*
USER node
RUN mkdir -p /home/node/.yarn-cache /home/node/.cache/yarn
COPY --chown=node:node package.json yarn.lock ./
RUN --mount=type=cache,target=/home/node/.yarn-cache,id=yarn,uid=1000,gid=1000 yarn install --ignore-scripts --cache-folder /home/node/.yarn-cache
# Copy source files, and possibily invalidate so we have to rebuild
COPY --chown=node:node . .
RUN npm run build-web
USER root
RUN apk del .build-deps
FROM base as production
ARG API_URL
ARG UPLOAD_URL
ARG DATA_URL
ARG BLIP_URL
ARG REALM_HOST
ARG PORT=3001
ARG SERVICE_NAME=uploader
ARG ROLLBAR_POST_SERVER_TOKEN
ARG I18N_ENABLED=false
ARG RX_ENABLED=false
ARG PENDO_ENABLED=true
ARG TRAVIS_COMMIT
# Set ENV from ARGs
ENV \
API_URL=$API_URL \
UPLOAD_URL=$UPLOAD_URL \
DATA_URL=$DATA_URL \
BLIP_URL=$BLIP_URL \
REALM_HOST=$REALM_HOST \
PORT=$PORT \
SERVICE_NAME=$SERVICE_NAME \
ROLLBAR_POST_TOKEN=$ROLLBAR_POST_SERVER_TOKEN \
I18N_ENABLED=$I18N_ENABLED \
RX_ENABLED=$RX_ENABLED \
PENDO_ENABLED=$PENDO_ENABLED \
TRAVIS_COMMIT=$TRAVIS_COMMIT \
NODE_ENV=production
# Only install dependancies needed for the production server
USER node
RUN yarn add express@4.16.3 helmet@7.0.0 body-parser@1.18.3
# Copy only files needed to run the server
COPY --from=build /app/dist dist
COPY --from=build \
/app/config.server.js \
/app/package.json \
/app/server.js \
./
CMD ["node", "server.js"]