FROM golang:1.25.8-bookworm AS builder WORKDIR /build # Cache Go module downloads COPY go.mod go.sum ./ RUN go mod download # Copy source and build COPY . . # Build static binary suitable for Linux ENV CGO_ENABLED=0 ENV GOOS=linux ENV GOARCH=amd64 RUN go build -o investool # Runtime image FROM alpine:3.23.3 WORKDIR /srv # Install runtime certificates RUN apk add --no-cache ca-certificates # Copy built binary and config into the runtime image COPY --from=builder /build/investool /srv/investool COPY config.toml /srv/config.toml EXPOSE 4869 4870 ENTRYPOINT ["./investool", "-c", "/srv/config.toml"]
git *.log *.tmp *.tar.gz **/dist/** **/vendor/** node_modules coverage.out *.exe *.dll *.so *.db .DS_Store
Concerns: config.toml must be present in the build context for the runtime COPY to succeed; otherwise docker build will fail, assumes the Go build produces a statically linked binary; CGO_ENABLED=0 is set, but verify the resulting binary is portable on Alpine (static is expected) Smoke [PASS]: test -x /srv/investool Smoke [PASS]: test -f /srv/config.toml Smoke [PASS]: ls -l /srv | grep investool