# syntax = docker/dockerfile:1-experimental FROM golang:1.23-alpine AS builder WORKDIR /home/appuser COPY go.mod go.sum . COPY index.html index.html COPY assets ./assets RUN go mod download COPY main.go . # -s disable symbol table, -w disable DWARF generation (smaller binary) # cross compile for amd64 RUN --mount=type=cache,target=/root/.cache/go-build \ CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o /bin/mock-server . # Set platform to x64 FROM --platform=linux/amd64 gcr.io/distroless/static-debian12:nonroot as server WORKDIR /home/appuser COPY index.html index.html COPY assets ./assets COPY --from=builder --chown=nonroot:nonroot /bin/mock-server ./bin/mock-server EXPOSE 3001/tcp ENTRYPOINT ["./bin/mock-server"]