Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix CGO-related Docker build issues (#19)
I'm seeing cgo-related errors on the `main` branch: https://github.com/peterldowns/pgmigrate/actions/runs/13402236158/job/37435471414 ``` #41 [linux/arm64 builder 13/13] RUN go build -ldflags "-X github.com/peterldowns/pgmigrate/cmd/pgmigrate/shared.Version=v0.2.0 -X github.com/peterldowns/pgmigrate/cmd/pgmigrate/shared.Commit=639e8e5" -o /dist/pgmigrate ./cmd/pgmigrate #41 35.55 # runtime/cgo #41 35.55 gcc: error: unrecognized command-line option '-fno-caret-diagnostics' #41 ERROR: process "/dev/.buildkit_qemu_emulator /bin/sh -c go build -ldflags \"-X github.com/peterldowns/pgmigrate/cmd/pgmigrate/shared.Version=${PGM_VERSION} -X github.com/peterldowns/pgmigrate/cmd/pgmigrate/shared.Commit=${PGM_COMMIT_SHA}\" -o /dist/pgmigrate ./cmd/pgmigrate" did not complete successfully: exit code: 1 ------ > [linux/arm64 builder 13/13] RUN go build -ldflags "-X github.com/peterldowns/pgmigrate/cmd/pgmigrate/shared.Version=v0.2.0 -X github.com/peterldowns/pgmigrate/cmd/pgmigrate/shared.Commit=639e8e5" -o /dist/pgmigrate ./cmd/pgmigrate: 35.55 # runtime/cgo 35.55 gcc: error: unrecognized command-line option '-fno-caret-diagnostics' ------ ``` This is absolutely terrible. I have no idea why gcc is failing. But, here's how I'm trying to fix it: - Update the development shell and the nix build to use go1.24 - also update golangci-lint in CI to match the version used in development - we have to update it in CI for it to be able to work with code built with go1.24, anyway - Update CI to use go1.24, both for the golang workflows and the docker workflows - Update the Dockerfile to use go1.24 and alpine 3.21 - Update the Dockerfile to set `CGO_ENABLED=0` - I don't know why it was set to `CGO_ENABLED=1` - The local development shell sets `CGO_ENABLED=0` and pgmigrate still seems to work fine - The [release binaries](https://github.com/peterldowns/pgmigrate/blob/639e8e59790156246175300c271ed5c807f57821/.github/workflows/release.yaml#L25) are built with `CGO_ENABLED=0`, and those are what people are `brew` installing, and everything seems to work fine. I tested this change by running `just docker-build` and then running `docker run --rm -it local-pgmigrate:latest pgmigrate version` and it seemed to work correctly, so hopefully everything is cool.
- Loading branch information