Skip to content

Instantly share code, notes, and snippets.

@copyleftdev
Created May 26, 2026 19:58
Show Gist options
  • Select an option

  • Save copyleftdev/39d821643e35851ae102facfda35860c to your computer and use it in GitHub Desktop.

Select an option

Save copyleftdev/39d821643e35851ae102facfda35860c to your computer and use it in GitHub Desktop.
micro-containers: WASM/WASI Dockerfile — scratch base + wasip1 binary
# WASM image — compiled to WASI preview1 target (Go 1.21+).
# The resulting container holds a single .wasm binary on a scratch base.
# Run via Docker+Wasm (experimental) or directly with wasmtime/wasmedge.
# Build (from repo root): docker build -f runtimes/wasm/Dockerfile -t micro-containers-wasm .
FROM golang:1.24 AS builder
WORKDIR /src
COPY go.mod ./
RUN go mod download
COPY cmd/wasm/ ./cmd/wasm/
RUN GOOS=wasip1 GOARCH=wasm go build \
-o /server.wasm \
./cmd/wasm/
# scratch = zero bytes. The only content is the .wasm binary (~3 MB).
FROM scratch
COPY --from=builder /server.wasm /server.wasm
ENTRYPOINT ["/server.wasm"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment