Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions runtime/reference/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ To use the official image, create a `Dockerfile` in your project directory:
```dockerfile
FROM denoland/deno:latest

# Create working directory
WORKDIR /app

# Copy source
COPY . .
# Cache dependencies by copying config files first
COPY deno.json deno.lock ./
RUN deno install

# Install dependencies (use just `deno install` if deno.json has imports)
# Copy source and install entrypoint
COPY . .
RUN deno install --entrypoint main.ts

# Run the app
Expand All @@ -37,17 +38,27 @@ For smaller production images:
# Build stage
FROM denoland/deno:latest AS builder
WORKDIR /app

# Cache dependencies by copying config files first
COPY deno.json deno.lock ./
RUN deno install

# Then copy source and install entrypoint
COPY . .
# Install dependencies (use just `deno install` if deno.json has imports)
RUN deno install --entrypoint main.ts

# Production stage
FROM denoland/deno:latest
WORKDIR /app
COPY --from=builder /app .
COPY --from=builder /deno-dir /deno-dir
CMD ["deno", "run", "--allow-net", "main.ts"]
```

The `DENO_DIR` (which defaults to `/deno-dir/` in the official Docker image)
contains cached dependencies from `deno install`. Copying it to the production
stage ensures dependencies don't need to be re-downloaded at runtime.

#### Permission Flags

Specify required permissions explicitly:
Expand Down
Loading