FROM node:22-slim RUN apt-get update \ && apt-get install -y --no-install-recommends git ca-certificates python3 make g++ \ && rm -rf /var/lib/apt/lists/* \ && npm install -g pnpm@9 RUN useradd -m -u 1000 user USER user ENV HOME=/home/user WORKDIR /home/user/app # Pin to the commit this deployment was tested against (github.com/cloudflare/cloudflare-os). RUN git clone https://github.com/cloudflare/cloudflare-os.git . \ && git checkout e1ab8fbd4f609aff7ede9d490bafe1bcf9b2a682 RUN pnpm install --frozen-lockfile # Build exactly what run-local builds to serve the app: the typed-storage dist # (imported by the backend) and the static frontend bundle. RUN pnpm --filter @gadgets/typed-storage build \ && pnpm --filter @gadgets/workshop-frontend exec vite build # wrangler dev binds to localhost by default; inside the container it must # listen on 0.0.0.0 for the Space proxy to reach it. run-dev-server.js doesn't # expose an --ip passthrough, so append the flag where it builds wrangler args. RUN sed -i '/^const args = configs.flatMap/a args.push("--ip", "0.0.0.0");' run-dev-server.js ENV WRANGLER_SEND_METRICS=false EXPOSE 8787 CMD ["node", "run-dev-server.js", "--serve-frontend-assets"]