From 4123d6542bec6a0fff46e8c8ed8a9381fa3bb3c1 Mon Sep 17 00:00:00 2001 From: Martin Schuppert Date: Tue, 17 Sep 2024 17:29:12 +0200 Subject: [PATCH] Do not use go.work inside build container When the golang version does not match the version used inside the build container, dowloading the modules can fail with: ~~~ go: go.work requires go >= 1.21.13 (running go 1.21.11; GOTOOLCHAIN=local) ~~~ This PR makes sure the go.work file created outside gets removed after the source was copied into the build container. Signed-off-by: Martin Schuppert --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8ce64783..205000a4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,7 +25,7 @@ RUN mkdir -p ${DEST_ROOT}/usr/local/bin/ # cache deps before building and copying source so that we don't need to re-download as much # and so that source changes don't invalidate our downloaded layer -RUN if [ ! -f $CACHITO_ENV_FILE ]; then go mod download ; fi +RUN if [ ! -f $CACHITO_ENV_FILE ]; then rm -f go.work go.work.sum; go mod download ; fi # Build manager RUN if [ -f $CACHITO_ENV_FILE ] ; then source $CACHITO_ENV_FILE ; fi ; env ${GO_BUILD_EXTRA_ENV_ARGS} go build ${GO_BUILD_EXTRA_ARGS} -a -o ${DEST_ROOT}/manager main.go