Skip to content

Commit

Permalink
Handle Go version used to build image (#28)
Browse files Browse the repository at this point in the history
* do not use Go 1.21

* auto install latest Go version
  • Loading branch information
neoaggelos authored Jul 22, 2024
1 parent f74ddc3 commit 35872fb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
13 changes: 2 additions & 11 deletions templates/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,8 @@ 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"
RUN wget https://go.dev/dl/go1.22.4.linux-amd64.tar.gz \
&& mkdir -p /usr/local/go122 \
&& tar -C /usr/local/go122 -xzf go1.22.4.linux-amd64.tar.gz \
&& ln -s /usr/local/go122/go/bin/go /usr/local/bin/go

## NOTE(neoaggelos): runc needs Go 1.21 to build
## !!!IMPORTANT!!! Drop this after runc 1.1.13 is released https://github.com/opencontainers/runc/issues/4233#issuecomment-2155883159
RUN wget https://go.dev/dl/go1.21.11.linux-amd64.tar.gz \
&& mkdir -p /usr/local/go121 \
&& tar -C /usr/local/go121 -xzf go1.21.11.linux-amd64.tar.gz \
&& ln -s /usr/local/go121/go/bin/go /usr/local/bin/go_121
ADD install-go.sh
RUN install-go.sh 1.22 && ln -s /usr/local/go/bin/go /usr/local/bin/go

## Prepare build environment
ENV SNAPCRAFT_PART_INSTALL=/out
Expand Down
15 changes: 15 additions & 0 deletions templates/docker/install-go.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash -xe

# Author: Angelos Kolaitis <[email protected]>
#
# Usage:
# $ install-go.sh 1.22
#
# Description: Download latest 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"

0 comments on commit 35872fb

Please sign in to comment.