-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContainerfile.node
More file actions
54 lines (46 loc) · 2.85 KB
/
Copy pathContainerfile.node
File metadata and controls
54 lines (46 loc) · 2.85 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
# Multi-stage Containerfile for the jesssullivan.github.io node-backend SHADOW.
#
# Tailnet-only. Production (transscendsurvival.org) stays adapter-static and is
# FROZEN — it never uses this image. This image is built only with
# BLOG_ADAPTER=node and runs the SvelteKit adapter-node server (build/index.js).
#
# Build locally:
# podman build -t blog-node:dev -f Containerfile.node .
ARG BASE_REGISTRY=docker.io
# ─────────────────────────────────────────────────────────────────────────
# Stage 1: deps — install npm dependencies from the committed package-lock.
# Workspace manifests (packages/*) must be present for `npm ci`.
# ─────────────────────────────────────────────────────────────────────────
FROM ${BASE_REGISTRY}/node:22-alpine AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json package-lock.json .npmrc ./
COPY packages ./packages
RUN npm ci
# ─────────────────────────────────────────────────────────────────────────
# Stage 2: build — produce the adapter-node bundle (BLOG_ADAPTER=node).
# ─────────────────────────────────────────────────────────────────────────
FROM deps AS build
WORKDIR /app
COPY . .
ENV BLOG_ADAPTER=node
RUN npm run build
# ─────────────────────────────────────────────────────────────────────────
# Stage 3: production — minimal runtime image.
# node:22-alpine ships a non-root `node` user at uid/gid 1000; reuse it.
# tini is PID 1 for correct signal handling / zombie reaping.
# ─────────────────────────────────────────────────────────────────────────
FROM ${BASE_REGISTRY}/node:22-alpine AS production
RUN apk add --no-cache tini
WORKDIR /app
ENV NODE_ENV=production
ENV HOST=0.0.0.0
ENV PORT=3000
# Only the adapter-node bundle, package.json, and node_modules ride into runtime.
COPY --from=build --chown=node:node /app/build ./build
COPY --from=build --chown=node:node /app/package.json ./package.json
COPY --from=build --chown=node:node /app/node_modules ./node_modules
USER node
EXPOSE 3000
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["node", "build/index.js"]