-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathDockerfile
66 lines (46 loc) · 1.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
########
# BASE
########
FROM node:20-alpine3.20 as base
WORKDIR /usr/app
RUN apk add --no-cache tini
############
# PROD DEPS
############
FROM base as prodDeps
COPY package*.json ./
# Install build tools for erlpack, then install prod deps only
RUN apk add --no-cache make gcc g++ python3 \
&& npm ci --omit=dev
########
# BUILD
########
FROM base as build
COPY package*.json ./
# Install build tools for erlpack, then install prod deps only
RUN apk add --no-cache make gcc g++ python3 \
&& npm ci --omit=dev
# Copy all jsons
COPY package*.json tsconfig.json ./
# Add dev deps
RUN npm ci
# Copy source code
COPY src src
RUN npm run build
########
# DEPLOY
########
FROM base as deploy
USER node
# Steal node_modules from base image
COPY --from=prodDeps /usr/app/node_modules node_modules
# Steal compiled code from build image
COPY --from=build /usr/app/dist dist
# Copy package.json for version number
COPY package.json ./
# RUN mkdir config
ARG COMMIT_SHA=""
ENV NODE_ENV=production \
COMMIT_SHA=${COMMIT_SHA}
ENTRYPOINT ["/sbin/tini", "--"]
CMD [ "node", "/usr/app/dist/index.js" ]