Skip to content

Commit

Permalink
Merge pull request #41 from canonical/eaudetcobello/patch-install-go
Browse files Browse the repository at this point in the history
get go from go.dev/dl in Dockerfile

use a less error-prone approach to  getting the archive of a go version
  • Loading branch information
eaudetcobello authored Aug 22, 2024
1 parent 681192d commit 486c239
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion templates/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ RUN apt-get update \
## NOTE(neoaggelos): Go version used to build components
## !!!IMPORTANT!!! Keep up to date with "snapcraft.yaml:parts.build-deps.build-snaps.go"
ADD install-go.sh /
RUN /install-go.sh 1.22 && ln -s /usr/local/go/bin/go /usr/local/bin/go
RUN /install-go.sh 1.22.6 && ln -s /usr/local/go/bin/go /usr/local/bin/go

## Prepare build environment
ENV SNAPCRAFT_PART_INSTALL=/out
Expand Down
12 changes: 6 additions & 6 deletions templates/docker/install-go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
# Author: Angelos Kolaitis <[email protected]>
#
# Usage:
# $ install-go.sh 1.22
# $ install-go.sh 1.22.6
#
# Description: Download latest go version and install under /usr/local/go
# Description: Download go version and install under /usr/local/go

VERSION="$1"

fname="$(curl -s https://go.dev/dl/ | grep -o "go$VERSION.*.linux-amd64.tar.gz" | head -1)"
wget "https://go.dev/dl/$fname"
tar -C /usr/local -xvzf "$fname"
rm "$fname"
fname="go${VERSION}.linux-amd64.tar.gz"
wget "https://go.dev/dl/${fname}"
tar -C /usr/local -xvzf "${fname}"
rm "${fname}"

0 comments on commit 486c239

Please sign in to comment.