-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
60 lines (43 loc) · 1.05 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
#######################
# Step 1: Base target #
#######################
FROM node:20 as development
ARG NPM_VERBOSE
ARG app_path
# Base dir /app
WORKDIR $app_path
COPY package.json ./
RUN if [ -z "${NPM_VERBOSE}" ]; then\
npm install; \
else \
npm install --verbose; \
fi
VOLUME ${app_path}/src
VOLUME ${app_path}/dist
VOLUME ${app_path}/tests
VOLUME ${app_path}/data
COPY tsconfig.json ./
ENTRYPOINT ["npm","run", "dev"]
##########################
# Step 3: "build" target #
##########################
FROM development as build
ARG app_path
WORKDIR $app_path
ADD src ./src
COPY tsconfig.json ./
RUN npm run build
###############################
# Step 4: "production" target #
###############################
FROM node:20-alpine as production
ARG app_path
RUN apk add --no-cache tzdata
WORKDIR $app_path
COPY package.json ./
ADD src ./src
ADD tests ./tests
VOLUME ${app_path}/data
COPY --from=build ${app_path}/node_modules ${app_path}/node_modules
COPY --from=build ${app_path}/dist ${app_path}/dist
ENTRYPOINT ["npm","run", "start"]