mirror of
https://github.com/dockersrc/go
synced 2026-06-24 14:01:08 -04:00
✨ Install Go latest + full toolchain at image build time ✨
Go is now downloaded from go.dev/dl at build time (always latest stable, never pinned). All tools are baked into /usr/local/bin so they are on PATH out of the box. Module cache and build cache live in the volumed GOPATH (/usr/local/share/go) so they persist across container restarts without re-downloading. - Dockerfile: add /usr/local/go/bin to PATH in both build and final stage - rootfs/root/docker/setup/05-custom.sh: full Go install + tool install - detects arch (amd64/arm64/armv6l/386) via uname -m - fetches latest stable version from go.dev/dl?mode=json via jq - extracts to /usr/local/go; symlinks go+gofmt to /usr/local/bin - installs with GOBIN=/usr/local/bin (baked into image, not in volume): gopls, goimports, gofumpt, stringer, golangci-lint, staticcheck, govulncheck, gotestsum, dlv, air, goreleaser, wire, mockgen (uber), ko, protoc-gen-go, protoc-gen-go-grpc - cleans modcache and build cache after install to keep layer lean - rootfs/etc/profile.d/go.sh: add /usr/local/go/bin prepend so interactive shells always find the Go distribution binaries first Volume strategy: /usr/local/share/go → GOPATH (module cache + build cache + user bins) Mount a named volume or bind-mount here to avoid re-downloading modules: docker run -v go-cache:/usr/local/share/go casjaysdevdocker/go Dockerfile rootfs/etc/profile.d/go.sh rootfs/root/docker/setup/05-custom.sh
This commit is contained in:
+2
-2
@@ -58,7 +58,7 @@ ARG PACK_LIST="git make bash tini ca-certificates openssh-client curl wget tar t
|
||||
|
||||
ENV ENV=~/.profile
|
||||
ENV SHELL="/bin/sh"
|
||||
ENV PATH="/usr/local/share/go/bin:${PATH}"
|
||||
ENV PATH="/usr/local/go/bin:/usr/local/share/go/bin:${PATH}"
|
||||
ENV TZ="${TIMEZONE}"
|
||||
ENV TIMEZONE="${TZ}"
|
||||
ENV LANG="${LANGUAGE}"
|
||||
@@ -234,7 +234,7 @@ LABEL com.github.containers.toolbox="false"
|
||||
|
||||
ENV ENV=~/.bashrc
|
||||
ENV USER="${USER}"
|
||||
ENV PATH="/usr/local/share/go/bin:${PATH}"
|
||||
ENV PATH="/usr/local/go/bin:/usr/local/share/go/bin:${PATH}"
|
||||
ENV TZ="${TIMEZONE}"
|
||||
ENV SHELL="/bin/bash"
|
||||
ENV TIMEZONE="${TZ}"
|
||||
|
||||
Reference in New Issue
Block a user