From eeb60b350d08044e33f3e980f0b054bd4c6ba3c8 Mon Sep 17 00:00:00 2001 From: Martin Schuppert Date: Tue, 17 Sep 2024 17:31:52 +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 864a19e8..06d356db 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,7 +23,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