Skip to content

Add "tip" version #531

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 65 additions & 1 deletion Dockerfile-linux.template
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ FROM buildpack-deps:{{ env.variant }}-scm AS build

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

{{ if env.version != "tip" then ( -}}
ENV GOLANG_VERSION {{ .version }}
{{ ) else ( -}}
COPY --from=golang:{{ env.variant }} /usr/local/go /usr/local/goroot-bootstrap

# {{ .version }}: https://github.com/golang/go/tree/{{ .commit.version }}
ARG GOLANG_COMMIT={{ .commit.version | @sh }}
ENV GOLANG_COMMIT $GOLANG_COMMIT
{{ ) end -}}

{{
def os_arches:
Expand Down Expand Up @@ -54,16 +62,23 @@ RUN set -eux; \
now="$(date '+%s')"; \
{{ if is_alpine then ( -}}
apk add --no-cache --virtual .fetch-deps \
{{ if env.version != "tip" then ( -}}
ca-certificates \
gnupg \
# 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)
tar \
{{ ) else ( -}}
bash \
git \
{{ ) end -}}
; \
arch="$(apk --print-arch)"; \
{{ ) else ( -}}
arch="$(dpkg --print-architecture)"; arch="${arch##*-}"; \
{{ ) end -}}
{{ if env.version != "tip" then ( -}}
url=; \
{{ ) else "" end -}}
case "$arch" in \
{{
[
Expand All @@ -78,8 +93,12 @@ RUN set -eux; \
| (
-}}
{{ $osArch | @sh }}) \
{{ if env.version != "tip" then ( -}}
url={{ .url | @sh }}; \
sha256={{ .sha256 | @sh }}; \
{{ ) else ( -}}
export {{ .env | to_entries | sort_by(.key) | map(.key + "=" + (.value | @sh)) | join(" ") }}; \
{{ ) end -}}
;; \
{{
)
Expand All @@ -88,6 +107,7 @@ RUN set -eux; \
*) echo >&2 "error: unsupported architecture '$arch' (likely packaging update needed)"; exit 1 ;; \
esac; \
\
{{ if env.version != "tip" then ( -}}
wget -O go.tgz.asc "$url.asc"; \
wget -O go.tgz "$url"{{ if is_alpine then "" else " --progress=dot:giga" end }}; \
echo "$sha256 *go.tgz" | sha256sum -c -; \
Expand All @@ -107,14 +127,56 @@ RUN set -eux; \
\
# save the timestamp from the tarball so we can restore it for reproducibility, if necessary (see below)
SOURCE_DATE_EPOCH="$(stat -c '%Y' /usr/local/go)"; \
{{ ) else ( -}}
# before we get too far, let's validate that our "bootstrap" Go works
export GOROOT_BOOTSTRAP=/usr/local/goroot-bootstrap; \
"$GOROOT_BOOTSTRAP/bin/go" version; \
\
git init --quiet /usr/local/go; \
git -C /usr/local/go fetch --depth 1 https://github.com/golang/go.git "$GOLANG_COMMIT:"; \
git -C /usr/local/go checkout --quiet FETCH_HEAD; \
\
# save the Git timestamp so we can use it for reproducibility
SOURCE_DATE_EPOCH="$(git -C /usr/local/go log -1 --format='format:%ct' HEAD)"; \
{{ ) end -}}
export SOURCE_DATE_EPOCH; \
touchy="$(date -d "@$SOURCE_DATE_EPOCH" '+%Y%m%d%H%M.%S')"; \
# for logging validation/edification
date --date "@$SOURCE_DATE_EPOCH" --rfc-2822; \
# sanity check (detected value should be older than our wall clock)
[ "$SOURCE_DATE_EPOCH" -lt "$now" ]; \
\
{{ if .arches["arm32v7"].url // "" | contains("armv6") then ( -}}
{{ if env.version == "tip" then ( -}}
( \
export \
GOCACHE='/tmp/gocache' \
# set GOHOST* to make sure explicitly 32bit builds on 64bit infra work correctly
GOHOSTOS="$GOOS" \
GOHOSTARCH="$GOARCH" \
; \
\
cd /usr/local/go/src; \
./make.bash; \
\
# remove a few intermediate / bootstrapping files the official binary release tarballs do not contain (and ".git" that is hard to make reproducible)
rm -rf \
/usr/local/go/.git* \
/usr/local/go/pkg/*/cmd \
/usr/local/go/pkg/bootstrap \
/usr/local/go/pkg/obj \
/usr/local/go/pkg/tool/*/api \
/usr/local/go/pkg/tool/*/go_bootstrap \
/usr/local/go/src/cmd/dist/dist \
"$GOCACHE" \
; \
\
# clamp timestamps for reproducibility (allows "COPY --link" to be more clever/useful)
touch -t "$touchy" /usr/local/.go-date-stamp; \
find /usr/local/go -depth -newer /usr/local/.go-date-stamp -exec touch -ht "$touchy" '{}' +; \
rm /usr/local/.go-date-stamp; \
); \
\
{{ ) elif .arches["arm32v7"].url // "" | contains("armv6") then ( -}}
if [ "$arch" = {{ os_arches["arm32v7"] | @sh }} ]; then \
[ -s /usr/local/go/go.env ]; \
before="$(go env GOARM)"; [ "$before" != {{ .arches["arm32v7"].env["GOARM"] | @sh }} ]; \
Expand Down Expand Up @@ -166,8 +228,10 @@ RUN set -eux; \
rm -rf /var/lib/apt/lists/*
{{ ) end -}}

{{ if env.version != "tip" then ( -}}
ENV GOLANG_VERSION {{ .version }}

{{ ) else "" end -}}
# don't auto-upgrade the gotoolchain
# https://github.com/docker-library/golang/issues/472
ENV GOTOOLCHAIN=local
Expand Down
2 changes: 0 additions & 2 deletions generate-stackbrew-library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ for version; do

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

[[ "$fullVersion" == *.*[^0-9]* ]] || fullVersion+='.0'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is technically valid even without this PR, but it's currently harmless (however with it in this PR, we end up with tags like tip-YYYYMMDD.0, which is undesirable).


if [ "$version" = "$fullVersion" ]; then
baseAliases=( "${versionAliases[@]}" )
else
Expand Down
126 changes: 126 additions & 0 deletions tip/alpine3.20/Dockerfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

126 changes: 126 additions & 0 deletions tip/alpine3.21/Dockerfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading