参考如下,基于golang:1.14-alpine构建

  - name: build
    image: golang:1.14-alpine
    commands:
      - go build -v -tags "" -ldflags "-extldflags "-static"  -s -w -X 'main.DroneBuildNumber=${DRONE_BUILD_NUMBER}' "  -o api
    volumes:
      - name: gopath
        path: /go