-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
59 lines (38 loc) · 1.22 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
ARG NODE_VERSION='20'
ARG DISTRO='alpine'
# base node image
FROM us.gcr.io/broad-dsp-gcr-public/base/nodejs:${NODE_VERSION}-${DISTRO} as base
# set for base and all layer that inherit from it
ENV NODE_ENV=production
RUN apk --no-cache -U upgrade
# Install all node_modules, including dev dependencies
FROM base as deps
WORKDIR /app
ADD package.json .npmrc ./
RUN npm install --include=dev
# Setup production node_modules
FROM base as production-deps
WORKDIR /app
COPY --from=deps /app/node_modules /app/node_modules
ADD package.json .npmrc ./
RUN npm prune --omit=dev
# Build the app
FROM base as build
WORKDIR /app
COPY --from=deps /app/node_modules /app/node_modules
ADD . .
RUN npm run build
# Finally, build the production image with minimal footprint
FROM base
WORKDIR /app
# This argo needs to be in here so that it can be referenced by the ENV
ARG BUILD_VERSION
ENV BUILD_VERSION=${BUILD_VERSION:-unknown}
ENV PORT=80
COPY --chown=node:node --from=production-deps /app/node_modules /app/node_modules
COPY --chown=node:node --from=build /app/build/server /app/build/server
COPY --chown=node:node --from=build /app/build/client /app/build/client
ADD --chown=node:node . .
USER node
EXPOSE 80/tcp
CMD ["npm", "run", "start"]