Created
May 26, 2026 19:58
-
-
Save copyleftdev/39d821643e35851ae102facfda35860c to your computer and use it in GitHub Desktop.
micro-containers: WASM/WASI Dockerfile — scratch base + wasip1 binary
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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