FROM node:22-alpine@sha256:cb15fca92530d7ac113467696cf1001208dac49c3c64355fd1348c11a88ddf8f AS builder WORKDIR /app COPY package.json package-lock.json* ./ # `npm ci` (not `install`) for lockfile-exact reproducibility. # `--include=optional` ensures the platform-specific @tailwindcss/oxide # native binary lands — without it, postcss fails with "Cannot read # properties of undefined (reading 'All')" at build time. RUN npm ci --include=optional COPY . . ARG NEXT_PUBLIC_PLATFORM_URL=http://localhost:8080 ARG NEXT_PUBLIC_WS_URL=ws://localhost:8080/ws ARG NEXT_PUBLIC_ADMIN_TOKEN= ENV NEXT_PUBLIC_PLATFORM_URL=$NEXT_PUBLIC_PLATFORM_URL ENV NEXT_PUBLIC_WS_URL=$NEXT_PUBLIC_WS_URL ENV NEXT_PUBLIC_ADMIN_TOKEN=$NEXT_PUBLIC_ADMIN_TOKEN RUN npm run build FROM node:22-alpine@sha256:cb15fca92530d7ac113467696cf1001208dac49c3c64355fd1348c11a88ddf8f WORKDIR /app COPY --from=builder /app/.next/standalone ./ COPY --from=builder /app/.next/static ./.next/static COPY --from=builder /app/public ./public EXPOSE 3000 ENV PORT=3000 ENV HOSTNAME="0.0.0.0" # Git SHA the image was built from, surfaced at /api/buildinfo so canvas # deploys are verifiable by the served SHA the same way workspace-server's # /buildinfo is (core#2235). Wired from `${{ github.sha }}` in # publish-canvas-image.yml. Server-only (not NEXT_PUBLIC_) — the route # handler reads it at runtime on the standalone Node server, so it stays # out of the client bundle. Set on the final stage (not the builder) so it # lives in the runtime env that force-dynamic reads per request. Default # "dev" matches the route + workspace-server sentinel: an unwired build # fails the SHA comparison closed instead of looking deployed. ARG BUILD_SHA=dev ENV BUILD_SHA=$BUILD_SHA # Non-root runtime — use addgroup/adduser without fixed GID/UID to avoid conflicts with base image RUN addgroup canvas 2>/dev/null || true && adduser -G canvas -s /bin/sh -D canvas 2>/dev/null || true USER canvas CMD ["node", "server.js"]