Skip to content

Commit c8b6c1a

Browse files
authored
Merge pull request #42 from infosiftr/riscv64
Update `.go-env.sh` for riscv64
2 parents 6c1c0c5 + fd8dc0b commit c8b6c1a

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

.go-env.sh

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,35 @@ if [ -t 0 ] && [ -t 1 ]; then
7373
fi
7474
fi
7575

76-
go="$(awk '$1 == "go" { print $2; exit }' "$dir/go.mod")"
77-
if [[ "$go" == *.*.* ]]; then
78-
go="${go%.*}" # strip to just X.Y
76+
if [ -z "${GOLANG_IMAGE:-}" ]; then
77+
go="$(awk '$1 == "go" { print $2; exit }' "$dir/go.mod")"
78+
if [[ "$go" == *.*.* ]]; then
79+
go="${go%.*}" # strip to just X.Y
80+
fi
81+
GOLANG_IMAGE="golang:$go"
82+
83+
# handle riscv64 "gracefully" (no golang image yet because no stable distro releases yet)
84+
{
85+
if ! docker image inspect --format '.' "$GOLANG_IMAGE" &> /dev/null && ! docker pull "$GOLANG_IMAGE"; then
86+
if [ -n "${BASHBREW_ARCH:-}" ] && docker buildx inspect "bashbrew-$BASHBREW_ARCH" &> /dev/null; then
87+
# a very rough hack to avoid:
88+
# ERROR: failed to solve: failed to solve with frontend dockerfile.v0: failed to read dockerfile: failed to load cache key: subdir not supported yet
89+
# (we need buildkit/buildx for --build-context, but newer buildkit than our dockerd might have for build-from-git-with-subdir)
90+
export BUILDX_BUILDER="bashbrew-$BASHBREW_ARCH"
91+
fi
92+
(
93+
set -x
94+
# TODO make this more dynamic, less hard-coded 🙈
95+
# https://github.com/docker-library/golang/blob/ea6bbce8c9b13acefed0f5507336be01f0918f97/1.21/bookworm/Dockerfile
96+
GOLANG_IMAGE='golang:1.21' # to be explicit
97+
docker buildx build --load --tag "$GOLANG_IMAGE" --build-context 'buildpack-deps:bookworm-scm=docker-image://buildpack-deps:unstable-scm' 'https://github.com/docker-library/golang.git#ea6bbce8c9b13acefed0f5507336be01f0918f97:1.21/bookworm'
98+
)
99+
fi
100+
} >&2
79101
fi
102+
80103
args+=(
81-
"golang:$go"
104+
"$GOLANG_IMAGE"
82105
"$@"
83106
)
84107

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module github.com/docker-library/meta-scripts
22

3+
// ideally this would be the single source of truth for this entire repository, but riscv64 means this bleeds into .go-env.sh too -- if changing this, see that file too
34
go 1.21
45

56
require (

0 commit comments

Comments
 (0)