-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
53 lines (36 loc) · 1.33 KB
/
Dockerfile
File metadata and controls
53 lines (36 loc) · 1.33 KB
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
# Choose builder base image
FROM node:16-alpine as builder
# Create app directory
WORKDIR /srv/app
# Builder image must contain a certificate /etc/ssl/certs/ca-bundle.crt
# Default Node image is spkp-docker.nexus-ci.corp.dev.vtb/ubi8/nodejs-14
# Install build essentials
RUN apk add --no-cache make gcc g++ python3 curl git
# Install app dependencies
COPY package.json package-lock.json ./
RUN npm ci
# ========================================================================
# Everyhing above here should change rarely to benefit from docker caching
# ========================================================================
# Copy source code and pre-build artifacts
COPY . .
# Build app
USER root
RUN npm run build \
&& npm prune --production \
&& chown -R root:root node_modules
# ======================================
# Everyhing above here is the build step
# ======================================
# Choose runtime base image
FROM node:16-alpine
# Create app directory
WORKDIR /srv/app
# Copy the build artifacts from the build stage
# Ordered by change frequency to benefit from docker caching
COPY --from=builder /srv/app/dist dist
COPY --from=builder /srv/app/package.json package.json
COPY --from=builder /srv/app/node_modules node_modules
COPY --from=builder /srv/app/index.js index.js
# Start app
CMD ["npm", "run", "start"]