build: persist Go build cache across Docker release builds
Mount .gocache/ from the host into the builder container so --rm container removal no longer wipes GOCACHE between runs.
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
# Build outputs
|
# Build outputs
|
||||||
dist/
|
dist/
|
||||||
|
|
||||||
|
# Persistent Go build cache for Docker-based release builds.
|
||||||
|
.gocache/
|
||||||
|
|
||||||
# Generated Windows resource compiled from packaging/windows/gosentry.rc.
|
# Generated Windows resource compiled from packaging/windows/gosentry.rc.
|
||||||
cmd/gosentry/*.syso
|
cmd/gosentry/*.syso
|
||||||
|
|
||||||
|
|||||||
@@ -18,12 +18,14 @@ fi
|
|||||||
docker build -f Dockerfile -t "$tag" .
|
docker build -f Dockerfile -t "$tag" .
|
||||||
|
|
||||||
mkdir -p "$(dirname "$output")"
|
mkdir -p "$(dirname "$output")"
|
||||||
|
mkdir -p "$(pwd)/.gocache"
|
||||||
docker run --rm \
|
docker run --rm \
|
||||||
"${docker_user_args[@]}" \
|
"${docker_user_args[@]}" \
|
||||||
-e "VERSION=${version}" \
|
-e "VERSION=${version}" \
|
||||||
-e "OUTPUT=${output}" \
|
-e "OUTPUT=${output}" \
|
||||||
-e "GOCACHE=/tmp/go-build-cache" \
|
-e "GOCACHE=/tmp/go-build-cache" \
|
||||||
-v "$(pwd):/src" \
|
-v "$(pwd):/src" \
|
||||||
|
-v "$(pwd)/.gocache:/tmp/go-build-cache" \
|
||||||
-w /src \
|
-w /src \
|
||||||
"$tag" \
|
"$tag" \
|
||||||
bash -c 'CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -buildvcs=false -trimpath -ldflags "-s -w -X gitea.mixdep.ru/mix/gosentry/src/app.Version=${VERSION}" -o "${OUTPUT}" ./cmd/gosentry'
|
bash -c 'CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -buildvcs=false -trimpath -ldflags "-s -w -X gitea.mixdep.ru/mix/gosentry/src/app.Version=${VERSION}" -o "${OUTPUT}" ./cmd/gosentry'
|
||||||
|
|||||||
@@ -88,11 +88,13 @@ normalize_targets() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
run_in_builder() {
|
run_in_builder() {
|
||||||
|
mkdir -p "${repo_root}/.gocache"
|
||||||
docker run --rm \
|
docker run --rm \
|
||||||
"${docker_user_args[@]}" \
|
"${docker_user_args[@]}" \
|
||||||
-e "VERSION=${version}" \
|
-e "VERSION=${version}" \
|
||||||
-e "GOCACHE=/tmp/go-build-cache" \
|
-e "GOCACHE=/tmp/go-build-cache" \
|
||||||
-v "${repo_root}:/src" \
|
-v "${repo_root}:/src" \
|
||||||
|
-v "${repo_root}/.gocache:/tmp/go-build-cache" \
|
||||||
-w /src \
|
-w /src \
|
||||||
"$tag" \
|
"$tag" \
|
||||||
bash -c "$1"
|
bash -c "$1"
|
||||||
|
|||||||
Reference in New Issue
Block a user