From 061aa7ac2d1ba7804fb60a5baecde8ce357359a4 Mon Sep 17 00:00:00 2001 From: Andrew Slotin Date: Mon, 21 Mar 2022 01:25:57 +0100 Subject: [PATCH 1/3] Initialize a new dummy module before downloading the package Since go1.18 the behavior of `go get` has changed to operate within module context only. In case there is no `go.mod` present in the current directory, command returns with a non-zero status, which terminates the execution and fails the action. To address this issue we're going to init a dummy module before running `go get`, which will add the target package to the `go.mod` and download it via proxy. The change should be backward-compatible with older Go versions that have module support. Closes #5 --- entrypoint.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index fafc13f..24b553d 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -17,4 +17,5 @@ fi export GO111MODULE=on export GOPROXY="$INPUT_GOPROXY" -go get -d "$PACKAGE@$VERSION" +go mod init dummy +go get "$PACKAGE@$VERSION" From 7c20a6f35deeee38e7c0ff1aa2aa84a59dbe3550 Mon Sep 17 00:00:00 2001 From: Andrew Slotin Date: Mon, 21 Mar 2022 01:56:47 +0100 Subject: [PATCH 2/3] Create module directory before initializing dummy module --- entrypoint.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/entrypoint.sh b/entrypoint.sh index 24b553d..1b198ad 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -17,5 +17,7 @@ fi export GO111MODULE=on export GOPROXY="$INPUT_GOPROXY" +mkdir dummy +cd dummy go mod init dummy go get "$PACKAGE@$VERSION" From 1b508024444cceb44c985e5e86af4af34fcf323d Mon Sep 17 00:00:00 2001 From: Andrew Slotin Date: Mon, 21 Mar 2022 01:57:24 +0100 Subject: [PATCH 3/3] Lock Go version --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 9ea7e87..b3918f3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:alpine +FROM golang:1.18-alpine COPY entrypoint.sh /entrypoint.sh