flyctl no longer uses buildpacks for Golang

tl;dr When you run fly launch on a Golang app, we no longer use Buildpack

Instead we generate a Dockerfile for you.

why? We’ve seen users hit errors with the Go buildpack, and thought it was time to setup something a bit more opinionated for Fly. Your opinions are also welcome as well [pr here].

tweaking the Setup The good news if that if our opinions aren’t what you want, you can pretty easily change it (maybe you need CGO_ENABLED=1 or want to include ldflags).

The fly launch command will read your go.mod file and use the Go version set there. You can over-ride that in your fly.toml by adding build args:

# fly.toml
  GO_VERSION = "1.21.5"

As I’m writing this, the Dockerfile created looks something like this:

FROM golang:${GO_VERSION}-alpine as builder

WORKDIR /usr/src/app
COPY go.mod go.sum ./
RUN go mod download && go mod verify
COPY . .
RUN go build -v -o /run-app .

FROM alpine:latest

COPY --from=builder /run-app /usr/local/bin/
CMD ["run-app"]

Is there a way to customize the build target, like there used to be with the BP_GO_TARGETS variable?

You should be able to edit the RUN go build -v -o /run-app . line in the generated Dockerfile to customize the build target.