FROM golang:1.13-buster AS builder
WORKDIR /src
# Cache Go module downloads by first copying go.mod and go.sum
COPY go.mod go.sum ./
RUN go mod download
# Copy the rest of the source
COPY . ./
ENV CGO_ENABLED=0
# Build esbuild binary
RUN go build -trimpath -ldflags "-s -w" -o esbuild ./cmd/esbuild
# Final runtime image
FROM debian:bullseye-slim
# Install CA certificates for HTTPS requests at runtime
RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates && \
rm -rf /var/lib/apt/lists/*
COPY --from=builder /src/esbuild /esbuild
RUN chmod +x /esbuild
ENTRYPOINT ["/esbuild"]
# Node, Go modules, and environment metadata node_modules *.log .DS_Store .git .gitignore
Concerns: Builder base image golang:1.13-buster is quite old (Debian Buster). Consider updating to a newer Go image for security and compatibility., No explicit tests in the Dockerfile to verify the build output beyond compilation; smoke tests will cover runtime behavior, which is fine, but adding a lightweight CI check could help guard against breakages. Smoke [PASS]: /esbuild --version Smoke [PASS]: /esbuild --help Smoke [PASS]: test -x /esbuild