diff --git a/.cnb.yml b/.cnb.yml index d53fa90fd..765a2b85e 100644 --- a/.cnb.yml +++ b/.cnb.yml @@ -19,6 +19,16 @@ main: - VERSION="v$(git rev-parse --short=8 HEAD)" - echo "BUILD_VERSION=${VERSION}" + # ========== 缓存Go依赖 ========== + - name: cache go modules + image: meltwater/drone-cache:latest + settings: + restore: true + mount: + - /go/pkg/mod + - /root/.cache/go-build + cache_key: '{{ .Repo.Name }}-{{ .Commit.Branch }}-{{ checksum "go.mod" }}' + # ========== 编译Logic服务 ========== - name: build logic image: golang:1.25 @@ -29,8 +39,19 @@ main: commands: - mkdir -p build - BIN_NAME="logic_${BUILD_VERSION}" + - go mod download -x - go build -v -p=4 -trimpath -buildvcs=false -ldflags "-s -w -buildid= -extldflags '-static'" -o ./build/${BIN_NAME} ./logic - ls -lh ./build/ + + # ========== 重建缓存 ========== + - name: rebuild cache + image: meltwater/drone-cache:latest + settings: + rebuild: true + mount: + - /go/pkg/mod + - /root/.cache/go-build + cache_key: '{{ .Repo.Name }}-{{ .Commit.Branch }}-{{ checksum "go.mod" }}' # ========== 拉取部署配置 ========== - name: fetch deploy config