-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
64 lines (45 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
ARG APP_FOLDER=/app
ARG APP_GID=1000
ARG APP_UID=1000
ARG APP_USER=node
ARG ENABLE_LOGS=false
#######################################################
# Builder
#######################################################
FROM node:22-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:22-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
COPY --from=builder \
$APP_FOLDER/tsconfig.json \
tsconfig.json
USER $APP_USER
CMD node -r tsconfig-paths/register index.js