field-guide / Dockerfile
pngwn
fix build
58d9edc
# syntax=docker/dockerfile:1
# ---------- build stage ----------
FROM node:22-slim AS builder
WORKDIR /app
# Enable pnpm via corepack
RUN corepack enable
# Install dependencies first so they cache across source-only changes
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
# Build the SvelteKit app -> build/ (adapter-node)
COPY . .
RUN pnpm run build
# ---------- run stage ----------
FROM node:22-slim AS runner
# The node image already ships a non-root `node` user at UID 1000 — exactly what
# HF Spaces expects. Reuse it rather than creating a colliding user.
RUN corepack enable
WORKDIR /home/node/app
RUN chown -R node:node /home/node/app
USER node
ENV HOME=/home/node \
PATH=/home/node/.local/bin:$PATH
# Production dependencies only (the `prepare` script no-ops without devDeps)
COPY --chown=node package.json pnpm-lock.yaml ./
RUN pnpm install --prod --frozen-lockfile
# Built standalone Node server + prerendered assets
COPY --chown=node --from=builder /app/build ./build
ENV NODE_ENV=production \
PORT=7860 \
HOST=0.0.0.0
EXPOSE 7860
CMD ["node", "build/index.js"]