-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
67 lines (48 loc) · 1.13 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
67
#######################################################
# Builder
#######################################################
FROM node:17-alpine as builder
ENV APP_UID=1000
ENV APP_GID=1000
ENV APP_HOME=/usr
ENV APP_USER=node
RUN apk --no-cache add shadow \
&& groupmod -g $APP_GID node \
&& usermod -u $APP_UID -g $APP_GID $APP_USER \
&& mkdir -p $APP_HOME \
&& chown -R $APP_USER $APP_HOME
WORKDIR $APP_HOME
COPY . .
RUN npm ci
USER $APP_USER
RUN npm run build
#######################################################
# App container
#######################################################
FROM node:slim as runtime
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
ENV NODE_ENV=production
ENV APP_UID=1000
ENV APP_GID=1000
ENV APP_HOME=/app
ENV APP_USER=node
ENV PORT=4000
WORKDIR $APP_HOME
USER $APP_USER
COPY --from=builder \
/usr/package.json \
$APP_HOME
COPY --from=builder \
/usr/tsconfig.json \
$APP_HOME
COPY --from=builder \
/usr/configs \
$APP_HOME/configs
COPY --from=builder \
/usr/dist/src \
$APP_HOME/dist
COPY --from=builder \
/usr/node_modules/ \
$APP_HOME/node_modules/
EXPOSE $PORT
CMD npm start