Home > Blockchain >  Cloud foundry downloading wrong go version when binary file pushed to cf
Cloud foundry downloading wrong go version when binary file pushed to cf

Time:10-07

Hi we are seeing wrong go version is downloaded when i push my binary file to cf

Steps followed to push code

  1. run go build command

GOOS="linux" GOARCH=amd64 go build ${LDFLAGS} -o localdeploy/some-app main.go

  1. cd localdeploy
  2. cf push -f manifest.yml

Note: localdeploy folder contains manifest.yml and some-app binary file

Go.mod file


go 1.16

require (
    github.com/cloudfoundry-community/go-cfenv v1.18.0
    github.com/gin-gonic/gin v1.8.1
    github.com/google/uuid v1.3.0
    github.com/rs/zerolog v1.28.0
    github.com/stretchr/testify v1.8.0
)

manifest file.yml

 applications:
      - name: some-app-1000-snapshot
        command: ./some-app
        stack: cflinuxfs3
        buildpacks:
          - https://github.com/cloudfoundry/binary-buildpack.git

Then i see following logs downloading go 1.15.5 instead of go 1.16


Below are the logs getting when pushed to cf --- application is working but why it is downloading 1.15 instead of 1.16 which is present in my mod file

Staging app and tracing logs...
   -----> Download go 1.15.5
   -----> Running go build supply
   /tmp/buildpackdownloads/d612ac0e3047b21e80ecfeae72c39f81 ~
   ~
   -----> Binary Buildpack version 1.0.46
   -----> Download go 1.15.5
   -----> Running go build finalize
   /tmp/buildpackdownloads/d612ac0e3047b21e80ecfeae72c39f81 ~```

CodePudding user response:

The binary buildpack doesn't install anything for your application. It is effectively a no-op buildpack.

Since you have compiled your application locally, the version of Go that is used for your binary is the version installed locally on your computer. You control that version based on what you have installed locally.


The output of the binary buildpack is confusing here, because you do see it downloading an older Go version. The reason this happens is because the buildpack itself is written in Go and you have the buildpack definition in your manifest.yml pointing to the source code of the buildpack. Thus to run the buildpack, it has to compile itself first. It needs Go to do that, so it downloads Go, builds itself, then runs itself. That's what you're seeing where it says Download go 1.15.5.

Most (all?) CloudFoundry installations are going to have the binary buildpack by default, so you don't need to reference the source. Run cf buildpacks and get the name of the binary buildpack from the list. It'll be something like binary-buildpack or binary_buildpack. Edit your manifest.yml and replace https://github.com/cloudfoundry/binary-buildpack.git with that value.

Now when you push, it'll use the existing buildpack which is already compiled and you shouldn't see those messages about Go being downloaded.

  • Related