File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,18 +36,28 @@ For smaller production images:
3636``` dockerfile
3737# Build stage
3838FROM denoland/deno:latest AS builder
39+ # Point Deno's cache at a known location so it can be copied to the next stage
40+ ENV DENO_DIR=/deno-dir
3941WORKDIR /app
4042COPY . .
4143# Install dependencies (use just `deno install` if deno.json has imports)
4244RUN deno install --entrypoint main.ts
4345
4446# Production stage
4547FROM denoland/deno:latest
48+ ENV DENO_DIR=/deno-dir
4649WORKDIR /app
4750COPY --from=builder /app .
51+ # Copy the populated Deno cache so the runtime stage has the dependencies
52+ COPY --from=builder /deno-dir /deno-dir
4853CMD ["deno" , "run" , "--allow-net" , "main.ts" ]
4954```
5055
56+ Without copying ` $DENO_DIR ` , ` deno install ` only writes to Deno's global cache
57+ inside the builder stage — those files do not travel with
58+ ` COPY --from=builder /app . ` , so the container re-downloads dependencies on
59+ first run.
60+
5161#### Permission Flags
5262
5363Specify required permissions explicitly:
You can’t perform that action at this time.
0 commit comments