-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
65 lines (48 loc) · 1.88 KB
/
Dockerfile
File metadata and controls
65 lines (48 loc) · 1.88 KB
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
65
# syntax=docker/dockerfile:1.7
###############################################################################
# Stage 1 — build native deps (better-sqlite3) on a full toolchain image
###############################################################################
FROM node:20-bookworm-slim AS build
ENV NODE_ENV=production \
npm_config_loglevel=warn
# better-sqlite3 needs python + build-essential to compile its native bindings
# the first time on a given arch. Once compiled, the artifact is copied to the
# runtime stage.
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
python3 \
make \
g++ \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY package.json package-lock.json* ./
RUN npm ci --omit=dev --no-audit --no-fund
COPY . .
###############################################################################
# Stage 2 — slim runtime image
###############################################################################
FROM node:20-bookworm-slim AS runtime
ENV NODE_ENV=production \
PORT=3000 \
SQLITE_PATH=/data/uptime.sqlite
# iputils-ping: needed for the ICMP / "ping" monitor type
# tini: PID 1, forwards signals, reaps zombies — small and battle-tested
# ca-certificates: TLS trust store for outbound HTTPS probes
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
iputils-ping \
tini \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=build /app /app
RUN mkdir -p /data /app/logs \
&& chown -R node:node /data /app
USER node
VOLUME ["/data"]
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \
CMD node -e "require('http').get('http://127.0.0.1:'+(process.env.PORT||3000)+'/healthz',r=>process.exit(r.statusCode<500?0:1)).on('error',()=>process.exit(1))"
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["node", "src/server.js"]