Skip to content

Instantly share code, notes, and snippets.

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

  • Save copyleftdev/10f272a6623c1ef96655e779e98f45ef to your computer and use it in GitHub Desktop.

Select an option

Save copyleftdev/10f272a6623c1ef96655e779e98f45ef to your computer and use it in GitHub Desktop.
micro-containers: distroless OCI Dockerfile — same image for runc, gVisor, Kata, Firecracker
# OCI image — works with runc, gVisor (runsc), Kata (QEMU), and Kata (Firecracker).
# The runtime is injected via RUNTIME_NAME at `docker run` time.
# Build: docker build -t micro-containers .
FROM golang:1.24-alpine AS builder
WORKDIR /src
COPY go.mod ./
RUN go mod download
COPY cmd/server/ ./cmd/server/
RUN CGO_ENABLED=0 GOOS=linux go build \
-ldflags="-w -s" \
-o /server \
./cmd/server/
# distroless/static has no shell, no libc — just the binary + CA certs.
# Image size: ~5 MB vs ~50 MB for Alpine.
FROM gcr.io/distroless/static-debian12:nonroot
COPY --from=builder /server /server
EXPOSE 8080
ENTRYPOINT ["/server"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment