Skip to content

Commit 5a29b9e

Browse files
committed
Add "tip" version
This is pinned to the latest commit merged upstream before midnight (UTC) on Monday of the current week.
1 parent aa7af9a commit 5a29b9e

File tree

8 files changed

+789
-28
lines changed

8 files changed

+789
-28
lines changed

Dockerfile-linux.template

+65-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@ FROM buildpack-deps:{{ env.variant }}-scm AS build
1313

1414
ENV PATH /usr/local/go/bin:$PATH
1515

16+
{{ if env.version != "tip" then ( -}}
1617
ENV GOLANG_VERSION {{ .version }}
18+
{{ ) else ( -}}
19+
COPY --from=golang:{{ env.variant }} /usr/local/go /usr/local/goroot-bootstrap
20+
21+
# {{ .version }}: https://github.com/golang/go/tree/{{ .commit.version }}
22+
ARG GOLANG_COMMIT={{ .commit.version | @sh }}
23+
ENV GOLANG_COMMIT $GOLANG_COMMIT
24+
{{ ) end -}}
1725

1826
{{
1927
def os_arches:
@@ -54,16 +62,23 @@ RUN set -eux; \
5462
now="$(date '+%s')"; \
5563
{{ if is_alpine then ( -}}
5664
apk add --no-cache --virtual .fetch-deps \
65+
{{ if env.version != "tip" then ( -}}
5766
ca-certificates \
5867
gnupg \
5968
# busybox's "tar" doesn't handle directory mtime correctly, so our SOURCE_DATE_EPOCH lookup doesn't work (the mtime of "/usr/local/go" always ends up being the extraction timestamp)
6069
tar \
70+
{{ ) else ( -}}
71+
bash \
72+
git \
73+
{{ ) end -}}
6174
; \
6275
arch="$(apk --print-arch)"; \
6376
{{ ) else ( -}}
6477
arch="$(dpkg --print-architecture)"; arch="${arch##*-}"; \
6578
{{ ) end -}}
79+
{{ if env.version != "tip" then ( -}}
6680
url=; \
81+
{{ ) else "" end -}}
6782
case "$arch" in \
6883
{{
6984
[
@@ -78,8 +93,12 @@ RUN set -eux; \
7893
| (
7994
-}}
8095
{{ $osArch | @sh }}) \
96+
{{ if env.version != "tip" then ( -}}
8197
url={{ .url | @sh }}; \
8298
sha256={{ .sha256 | @sh }}; \
99+
{{ ) else ( -}}
100+
export {{ .env | to_entries | sort_by(.key) | map(.key + "=" + (.value | @sh)) | join(" ") }}; \
101+
{{ ) end -}}
83102
;; \
84103
{{
85104
)
@@ -88,6 +107,7 @@ RUN set -eux; \
88107
*) echo >&2 "error: unsupported architecture '$arch' (likely packaging update needed)"; exit 1 ;; \
89108
esac; \
90109
\
110+
{{ if env.version != "tip" then ( -}}
91111
wget -O go.tgz.asc "$url.asc"; \
92112
wget -O go.tgz "$url"{{ if is_alpine then "" else " --progress=dot:giga" end }}; \
93113
echo "$sha256 *go.tgz" | sha256sum -c -; \
@@ -107,14 +127,56 @@ RUN set -eux; \
107127
\
108128
# save the timestamp from the tarball so we can restore it for reproducibility, if necessary (see below)
109129
SOURCE_DATE_EPOCH="$(stat -c '%Y' /usr/local/go)"; \
130+
{{ ) else ( -}}
131+
# before we get too far, let's validate that our "bootstrap" Go works
132+
export GOROOT_BOOTSTRAP=/usr/local/goroot-bootstrap; \
133+
"$GOROOT_BOOTSTRAP/bin/go" version; \
134+
\
135+
git init --quiet /usr/local/go; \
136+
git -C /usr/local/go fetch --depth 1 https://github.com/golang/go.git "$GOLANG_COMMIT:"; \
137+
git -C /usr/local/go checkout --quiet FETCH_HEAD; \
138+
\
139+
# save the Git timestamp so we can use it for reproducibility
140+
SOURCE_DATE_EPOCH="$(git -C /usr/local/go log -1 --format='format:%ct' HEAD)"; \
141+
{{ ) end -}}
110142
export SOURCE_DATE_EPOCH; \
111143
touchy="$(date -d "@$SOURCE_DATE_EPOCH" '+%Y%m%d%H%M.%S')"; \
112144
# for logging validation/edification
113145
date --date "@$SOURCE_DATE_EPOCH" --rfc-2822; \
114146
# sanity check (detected value should be older than our wall clock)
115147
[ "$SOURCE_DATE_EPOCH" -lt "$now" ]; \
116148
\
117-
{{ if .arches["arm32v7"].url // "" | contains("armv6") then ( -}}
149+
{{ if env.version == "tip" then ( -}}
150+
( \
151+
export \
152+
GOCACHE='/tmp/gocache' \
153+
# set GOHOST* to make sure explicitly 32bit builds on 64bit infra work correctly
154+
GOHOSTOS="$GOOS" \
155+
GOHOSTARCH="$GOARCH" \
156+
; \
157+
\
158+
cd /usr/local/go/src; \
159+
./make.bash; \
160+
\
161+
# remove a few intermediate / bootstrapping files the official binary release tarballs do not contain (and ".git" that is hard to make reproducible)
162+
rm -rf \
163+
/usr/local/go/.git* \
164+
/usr/local/go/pkg/*/cmd \
165+
/usr/local/go/pkg/bootstrap \
166+
/usr/local/go/pkg/obj \
167+
/usr/local/go/pkg/tool/*/api \
168+
/usr/local/go/pkg/tool/*/go_bootstrap \
169+
/usr/local/go/src/cmd/dist/dist \
170+
"$GOCACHE" \
171+
; \
172+
\
173+
# clamp timestamps for reproducibility (allows "COPY --link" to be more clever/useful)
174+
touch -t "$touchy" /usr/local/.go-date-stamp; \
175+
find /usr/local/go -depth -newer /usr/local/.go-date-stamp -exec touch -ht "$touchy" '{}' +; \
176+
rm /usr/local/.go-date-stamp; \
177+
); \
178+
\
179+
{{ ) elif .arches["arm32v7"].url // "" | contains("armv6") then ( -}}
118180
if [ "$arch" = {{ os_arches["arm32v7"] | @sh }} ]; then \
119181
[ -s /usr/local/go/go.env ]; \
120182
before="$(go env GOARM)"; [ "$before" != {{ .arches["arm32v7"].env["GOARM"] | @sh }} ]; \
@@ -166,8 +228,10 @@ RUN set -eux; \
166228
rm -rf /var/lib/apt/lists/*
167229
{{ ) end -}}
168230

231+
{{ if env.version != "tip" then ( -}}
169232
ENV GOLANG_VERSION {{ .version }}
170233

234+
{{ ) else "" end -}}
171235
# don't auto-upgrade the gotoolchain
172236
# https://github.com/docker-library/golang/issues/472
173237
ENV GOTOOLCHAIN=local

generate-stackbrew-library.sh

-2
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,6 @@ for version; do
113113

114114
fullVersion="$(jq -r '.[env.version].version' versions.json)"
115115

116-
[[ "$fullVersion" == *.*[^0-9]* ]] || fullVersion+='.0'
117-
118116
if [ "$version" = "$fullVersion" ]; then
119117
baseAliases=( "${versionAliases[@]}" )
120118
else

tip/alpine3.20/Dockerfile

+126
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tip/alpine3.21/Dockerfile

+126
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)