Golang build tags in fly.toml file

Hi all,

I’ve been trying to build a Go app that requires some build tags, e.g.

go build -tags "tag1" -o app

but so far I haven’t been able to pass such tags to the build command executed by the builder.

Here is the configuration I have in the fly.toml file:

# fly.toml
[build]
  builder = "paketobuildpacks/builder:base"
  buildpacks = ["gcr.io/paketo-buildpacks/go"]
  [[ build.env ]]
    name="BP_GO_BUILD_LDFLAGS"
    value="-s -w"
  [[ build.env ]]
    name="BP_GO_BUILD_FLAGS"
    value="-tags=prod"

Can someone advise on what’s the best way to pass such flags to the build command?
Thanks.

P.S.
I could deploy this app as a minimal Dockerised app, is there any performance benefit in preferring a Go app over a Dockerised app? Thanks

Try [build.args] instead of [[build.env]]. For example:

[build.args]
  BP_GO_BUILD_LDFLAGS ="-s -w"
  BP_GO_BUILD_FLAGS ="-tags=prod"

Using a dockerfile will probably make for faster builds and deployments. The buildpack images are pretty big since they include a lot of different tools, which can make them slower to download during builds and deploys.

I don’t think there will be much if any difference in the performance of the application once it is deployed.

Thanks @tvdfly! I can confirm it works!

Using a dockerfile will probably make for faster builds and deployments. The buildpack images are pretty big since they include a lot of different tools, which can make them slower to download during builds and deploys.
I don’t think there will be much if any difference in the performance of the application once it is deployed.

I think I’ll probably move to the Dockerised app then, just to shave off some time during deployments.
As you said, I noticed as well that the buildpack image for the same app is about 100MB+ while my own is ~12MB.

Thanks again.