forked from StateVoicesNational/Spoke
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
35 lines (30 loc) · 1.02 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
ARG BUILDER_IMAGE=node:16.18
ARG RUNTIME_IMAGE=node:16.18-alpine
ARG PHONE_NUMBER_COUNTRY=US
FROM ${BUILDER_IMAGE} as builder
ENV NODE_ENV=production \
OUTPUT_DIR=./build \
ASSETS_DIR=./build/client/assets \
ASSETS_MAP_FILE=assets.json \
PHONE_NUMBER_COUNTRY=${PHONE_NUMBER_COUNTRY}
COPY . /spoke
WORKDIR /spoke
RUN yarn install --ignore-scripts --non-interactive --frozen-lockfile && \
yarn run prod-build && \
rm -rf node_modules && \
yarn install --production --ignore-scripts
# Spoke Runtime
FROM ${RUNTIME_IMAGE}
WORKDIR /spoke
COPY --from=builder /spoke/build build
COPY --from=builder /spoke/node_modules node_modules
COPY --from=builder /spoke/package.json /spoke/yarn.lock ./
ENV NODE_ENV=production \
PORT=3000 \
ASSETS_DIR=./build/client/assets \
ASSETS_MAP_FILE=assets.json \
JOBS_SAME_PROCESS=1
# Switch to non-root user https://github.com/nodejs/docker-node/blob/d4d52ac41b1f922242d3053665b00336a50a50b3/docs/BestPractices.md#non-root-user
USER node
EXPOSE 3000
CMD ["npm", "start"]