mirror of
https://github.com/hanzoai/ltx.git
synced 2026-10-30 18:28:37 +00:00
The official golang images set GOTOOLCHAIN=local, so a go.mod `go` directive
newer than the base image fails the build at the first go command:
go: go.mod requires go >= 1.26.5 (running go 1.26.4; GOTOOLCHAIN=local)
Two orthogonal changes. Pinning the base to the exact patch go.mod names makes
the build hermetic — the versions match, so no toolchain is downloaded.
GOTOOLCHAIN=auto is the resilience half: when go.mod next moves ahead of the
pin, the toolchain is fetched and checksum-verified against sum.golang.org
instead of failing the build outright.
Co-authored-by: Hanzo Dev <[email protected]>
20 lines
553 B
Docker
20 lines
553 B
Docker
FROM golang:1.26.5 AS builder
|
|
# go.mod pins the toolchain. The golang base image sets GOTOOLCHAIN=local,
|
|
# which turns a `go` directive newer than the image into a hard build
|
|
# failure instead of a download.
|
|
ENV GOTOOLCHAIN=auto
|
|
|
|
WORKDIR /src/ltx
|
|
COPY . .
|
|
|
|
ARG LTX_VERSION=
|
|
ARG LTX_COMMIT=
|
|
|
|
RUN go build -ldflags "-s -w -X 'main.Version=${LTX_VERSION}' -X 'main.Commit=${LTX_COMMIT}' -extldflags '-static'" -o /usr/local/bin/ltx ./cmd/ltx
|
|
|
|
|
|
FROM scratch
|
|
COPY --from=builder /usr/local/bin/ltx /usr/local/bin/ltx
|
|
ENTRYPOINT ["/usr/local/bin/ltx"]
|
|
CMD []
|