-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile
54 lines (37 loc) · 1.27 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
# ---- Base Node ----
FROM node:21-alpine AS base
# set working directory
WORKDIR /app
# ---- Dependencies ----
FROM base AS dependencies
RUN apk add --no-cache make gcc g++ python3
RUN npm set progress=false && npm config set depth 0
COPY package*.json ./
# only production dependencies so we can later use them in the final image
RUN npm ci --omit=dev --loglevel info
# ---- Build ----
FROM dependencies AS build
# now also install dev dependencies required for the build
RUN npm ci --loglevel info
#copy all project files
COPY . .
RUN npm run build
# ---- final ----
FROM base AS final
RUN apk add --no-cache curl
# --- Entrypoint ---
ENV HTTP_PORT=3000
EXPOSE 3000
#allows attaching a debugger
#EXPOSE 9229
HEALTHCHECK --interval=1m --timeout=20s --start-period=2m \
CMD curl -f --max-time 18 "http://127.0.0.1:${HTTP_PORT}/health" || exit 1
CMD ["node","--inspect=0.0.0.0:9229","--enable-source-maps","/app/built/index.js"]
VOLUME /app/log
VOLUME /app/db
#VOLUME /app/conf #need some work to move the config file into a seperate folder
# Copy files at last to maximise caching potential
COPY --from=dependencies /app/node_modules /app/node_modules
COPY --from=build /app/built /app/built
# For server-health endoint..
COPY --from=build /app/package.json /app/package.json