-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
58 lines (45 loc) · 1014 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
FROM node:20.13.1-alpine3.18 AS node
ENV NODE_OPTIONS="--unhandled-rejections=strict --enable-source-maps"
WORKDIR /app
#
# Stage: NPM environment
#
FROM node AS npm
COPY .npmrc \
package.json \
package-lock.json \
./
#
# Stage: Development NPM install
#
FROM npm AS npm-dev
RUN npm ci
#
# Stage: Production NPM install
#
FROM npm AS npm-prod
RUN npm ci --production
#
# Stage: Production build
#
FROM npm AS build-prod
ENV NODE_ENV=production
COPY --from=npm-dev /app/node_modules/ node_modules/
COPY tsconfig.build.json \
tsconfig.json \
./
COPY src/ src/
RUN npx tsc --project tsconfig.build.json
#
# Stage: Production environment
#
FROM node AS prod
ENV NODE_ENV=production
RUN echo "{\"type\": \"module\"}" > package.json
COPY --from=npm-prod /app/node_modules/ node_modules/
COPY --from=build-prod /app/dist/ dist/
HEALTHCHECK --interval=5s --timeout=1s \
CMD wget --quiet --tries=1 --spider http://localhost:3000/health || exit 1
EXPOSE 3000
USER node
CMD ["node", "dist/index.js"]