-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
60 lines (42 loc) · 1010 Bytes
/
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
ARG APP_FOLDER=/app
ARG APP_GID=1000
ARG APP_UID=1000
ARG APP_USER=node
ARG ENABLE_LOGS=false
#######################################################
# Builder
#######################################################
FROM node:16-alpine as builder
ARG APP_FOLDER
ARG APP_GID
ARG APP_UID
ARG APP_USER
RUN apk --no-cache add shadow \
&& groupmod -g $APP_GID node \
&& usermod -u $APP_UID -g $APP_GID $APP_USER
WORKDIR $APP_FOLDER
COPY . .
RUN npm ci
RUN npm run build
RUN chown -R $APP_USER $APP_FOLDER
USER $APP_USER
#######################################################
# App container
#######################################################
FROM node:slim as runtime
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
ARG APP_FOLDER
ARG APP_USER
ENV NODE_ENV=production
WORKDIR $APP_FOLDER
COPY --from=builder \
$APP_FOLDER/dist/ \
.
COPY --from=builder \
$APP_FOLDER/node_modules/ \
node_modules
COPY --from=builder \
$APP_FOLDER/package.json \
package.json
USER $APP_USER
CMD node index.js