- backend dep-cache stage stubs only main.rs/lib.rs, but Cargo.toml
declares a second [[bin]] crawler at src/bin/crawler.rs, so
`cargo build --locked` aborts ("can't find bin crawler"). Stub it too.
- runtime was debian:bookworm-slim (glibc 2.36) while rust:1-slim now
tracks trixie (glibc 2.41) -> "GLIBC_2.39 not found" at boot. Pin the
runtime to debian:trixie-slim so it matches the builder's glibc.
- frontend healthcheck probed localhost (-> musl picks IPv6 ::1) but the
Node server binds IPv4 0.0.0.0 only -> false "unhealthy". Probe 127.0.0.1.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
36 lines
1.3 KiB
Docker
36 lines
1.3 KiB
Docker
FROM node:22-alpine AS builder
|
|
WORKDIR /app
|
|
COPY package.json package-lock.json* ./
|
|
# `npm ci` installs the locked versions exactly; `npm install` would
|
|
# silently rewrite package-lock.json mid-build. CI (.gitea/workflows)
|
|
# also uses `npm ci`, so this keeps the image build deterministic and
|
|
# matches what the test job validated.
|
|
RUN npm ci
|
|
COPY . .
|
|
RUN npm run build
|
|
|
|
FROM node:22-alpine
|
|
WORKDIR /app
|
|
ENV NODE_ENV=production
|
|
ENV HOST=0.0.0.0
|
|
ENV PORT=3000
|
|
|
|
# node:22-alpine ships a `node` user (UID 1000); use it instead of
|
|
# running the SvelteKit server as root.
|
|
COPY --from=builder --chown=node:node /app/build ./build
|
|
COPY --from=builder --chown=node:node /app/node_modules ./node_modules
|
|
COPY --from=builder --chown=node:node /app/package.json ./
|
|
|
|
USER node
|
|
EXPOSE 3000
|
|
|
|
# Alpine's busybox `wget` is the canonical lightweight HTTP probe. Probe
|
|
# 127.0.0.1, not `localhost`: musl resolves `localhost` to IPv6 ::1 first,
|
|
# but the Node server binds IPv4 0.0.0.0 only, so a localhost probe gets
|
|
# "connection refused" and the container is wrongly marked unhealthy. Use a
|
|
# GET (`-O /dev/null`) since `node build` serves 200 on `/`.
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
|
CMD wget -q -O /dev/null http://127.0.0.1:3000/ || exit 1
|
|
|
|
CMD ["node", "build"]
|