-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
42 lines (27 loc) · 1.16 KB
/
Dockerfile
File metadata and controls
42 lines (27 loc) · 1.16 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
# ── Stage 1: Build client ────────────────────────────────────────────
FROM node:18-alpine AS builder
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --ignore-scripts
COPY client/package.json client/package-lock.json* client/
RUN cd client && npm ci --ignore-scripts
COPY . .
RUN cd client && npm run build
# ── Stage 2: Production image ────────────────────────────────────────
FROM node:18-alpine AS production
RUN apk add --no-cache tini dumb-init \
&& addgroup -S app && adduser -S app -G app
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --omit=dev --ignore-scripts && npm cache clean --force
COPY server/ server/
COPY --from=builder /app/client/dist client/dist/
RUN mkdir -p data && chown -R app:app /app
USER app
ENV NODE_ENV=production
ENV PORT=3000
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD wget -qO- http://localhost:3000/api/health || exit 1
ENTRYPOINT ["tini", "--"]
CMD ["node", "server/index.js"]