Caching go modules

I’m using go mod, and I want to use S3 cache plugin to speed up the build step. I’ve tried to use go mod vendor command after finishing the build to make a vendor dir in the workdir, so i can mount and cache the vendor dir using the cache plugin. But it seems have to download dependency every time when i execute the go mod vendor. I can’t find anyone is discussing related topic, am I going the wrong direction?

Hi Luis, it may be helpful to provide a copy of your yaml so that people can see what you are doing and advise according.

Copying folders into the workspace for caching purposes is not longer required as of drone 1.0. Instead, you can mount a temporary volume outside of the workspace at the go module path. Example mounting a temporary volume here https://docs.drone.io/examples/language/golang/#dependencies

Hi Brad, here is my yaml. The cache plugin is similar to the s3 cache plugin, china can’t use aws, the oss is the same as aws s3.

kind: pipeline
name: default

platform:
  os: linux
  arch: amd64

steps:
  - name: restore
    image: luischan/drone-oss-cache
    pull: always
    settings:
      endpoint: ENDPOINT
      debug: true
      access_key:
        from_secret: oss_ak
      secret_key:
        from_secret: oss_sk
      restore: true
      bucket: drone-build-cache

  - name: build
    image: golang:1.12.4-alpine3.9
    commands:
      - "go build -o sever main.go"
      - go mod vendor
    environment:
      CGO_ENABLED: 0
      GOPROXY: https://someproxy.com

  - name: rebuild
    image: luischan/drone-oss-cache
    pull: always
    settings:
      endpoint: ENDPOINT
      access_key:
        from_secret: oss_ak
      secret_key:
        from_secret: oss_sk
      rebuild: true
      bucket: drone-build-cache
      debug: true
      mount:
        - vendor

  - name: docker
    image: plugins/docker
    settings:
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password
      registry: REGISTRY
      repo: REGISTRY/some
      tags:
        - dev

I look the link you gave, it looks good for docker compose. I have a three instance k8s cluster, and it don’t know which node will spin up and do the job, any ideas?