# inspired by: https://hono.dev/docs/getting-started/nodejs#dockerfile FROM node:24.21.0-alpine AS base FROM base AS builder RUN apk add --no-cache gcompat RUN npm install -g pnpm@11.1.3 WORKDIR /server # pnpm-workspace.yaml carries the allowBuilds settings — without it the # install refuses to run the esbuild install script. COPY package.json pnpm-lock.yaml pnpm-workspace.yaml tsconfig.json tsconfig.build.json ./ COPY src ./src # check-types gates (esbuild does not look at types); build:bundle emits # the single-file runtime artifact the production image ships too RUN pnpm install --frozen-lockfile && \ pnpm run check-types && \ pnpm run build:bundle FROM base AS runner WORKDIR /server RUN addgroup --system --gid 1001 nodejs RUN adduser --system --uid 1001 hono # the bundle folds sentry in (no --import preload) and carries every # dependency, so no node_modules are shipped. COPY --from=builder --chown=hono:nodejs /server/dist/bundle.mjs /server/bundle.mjs ENV NODE_ENV=production USER hono EXPOSE 8081 CMD ["node", "/server/bundle.mjs"]