Skip to content

Commit

Permalink
Do not use go.work inside build container
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
stuggi committed Sep 17, 2024
1 parent 9444dd6 commit 4123d65
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4123d65

Please sign in to comment.