-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
43 lines (38 loc) · 1000 Bytes
/
Dockerfile
File metadata and controls
43 lines (38 loc) · 1000 Bytes
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
# ========================#
# Build environment #
# ========================#
# Use small image
FROM node:14.5.0-alpine3.12 as build
WORKDIR /app
# Install dependencies
COPY package*.json ./
COPY tsconfig*.json ./
RUN npm ci --silent
# Copy app files
COPY . ./
# Build app
RUN npm run build
# ========================#
# Post-build environment #
# ========================#
# Use small image
FROM node:14.5.0-alpine3.12 as post-build
WORKDIR /app
# Only copy output files from build environment
COPY --from=build /app/package*.json ./
COPY --from=build /app/dist ./dist/
# Install dependencies
RUN npm ci --silent --only=production
# ========================#
# Runtime environment #
# ========================#
# Use small image
FROM node:14.5.0-alpine3.12
# Copy app from post-build environment
WORKDIR /app
COPY --from=post-build /app ./
EXPOSE 3000
# Run with unpriviledged user
USER node
# Run directly without using package script to circumvent prestart script
CMD ["node", "."]