-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
57 lines (33 loc) · 983 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
# Build Stage 1
FROM node:20.10-alpine3.19 AS base
WORKDIR /usr/src/app
COPY package.json .
COPY package-lock.json .
RUN npm install
# docker build . --file Dockerfile --target test
# FROM base AS test
# COPY . .
# RUN npm run test:ci
# Build Stage 2 builder
FROM base AS builder
COPY . .
RUN npm run build
# Build Stage 3 prod
FROM node:20.10-alpine3.19 AS prod-stage
WORKDIR /usr/src/app
RUN chown -R node:node /usr/src/app
RUN apk upgrade --no-cache --update && \
apk add --no-cache ca-certificates && \
update-ca-certificates && \
rm -rf /var/cache/apk/*
COPY --chown=node:node package.json .
COPY --chown=node:node package-lock.json .
COPY --chown=node:node healthcheck.js .
COPY --chown=node:node db ./db
RUN npm install --omit=dev
COPY --chown=node:node --from=builder /usr/src/app/dist ./dist
EXPOSE 3050
USER node
HEALTHCHECK --interval=12s --timeout=12s --start-period=30s \
CMD node healthcheck.js
CMD [ "node" , "dist/index.js"]