-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathDockerfile
More file actions
40 lines (31 loc) · 1.17 KB
/
Dockerfile
File metadata and controls
40 lines (31 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# --- Stage 1: build the Worker with Wrangler -----------------------
FROM node:25-alpine AS builder
WORKDIR /app
# Install dependencies & wrangler
COPY package*.json wrangler.toml ./
RUN npm ci
# Copy source and build
COPY src ./src
RUN npx wrangler deploy --dry-run --outdir=dist
# --- Stage 2: minimal runtime with workerd -------------------------
FROM node:25-slim AS runtime
ARG TARGETARCH
# Install ca-certificates for SSL, then install workerd via npm
RUN apt-get update && \
apt-get install -y ca-certificates && \
rm -rf /var/lib/apt/lists/* && \
case "${TARGETARCH}" in \
amd64) WORKERD_PKG="@cloudflare/workerd-linux-64" ;; \
arm64) WORKERD_PKG="@cloudflare/workerd-linux-arm64" ;; \
*) echo "Unsupported TARGETARCH: ${TARGETARCH}" && exit 1 ;; \
esac && \
npm install -g "${WORKERD_PKG}" && \
ln -s "/usr/local/lib/node_modules/${WORKERD_PKG}/bin/workerd" /usr/local/bin/workerd && \
workerd --version
WORKDIR /worker
# Bring in the compiled Worker bundle and config
COPY --from=builder /app/dist ./dist
COPY config.capnp ./config.capnp
# Expose the port workerd listens on
EXPOSE 8080
CMD ["workerd", "serve", "config.capnp"]