kukymbr / goose-docker

Docker configuration for the goose migration tool
MIT License
14 stars 6 forks source link

The GitHub workflow doesn't build the Docker image correctly. #7

Open chekist32 opened 3 days ago

chekist32 commented 3 days ago

In your .github/workflows/push_ghcr.yml you are actually building two AMD64 Docker images, but with different binaries.

- name: Build image
  run: docker build . --file Dockerfile --tag $IMAGE_NAME --build-arg TARGETARCH=${{ matrix.target_arch }} --label "runnumber=${GITHUB_RUN_ID}"

You should change it to something like this:

- --build-arg TARGETARCH=${{ matrix.target_arch }}"
+ --platform linux/${{ matrix.target_arch }}"

Additionally, you need to add these stages before the actual build stage in your workflow:

- name: Set up QEMU
  uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
  uses: docker/setup-buildx-action@v3

Btw, I don’t really understand why you're using two different workflows for basically the same task, because the only thing that differs between these workflows is the Docker registry.

And another remark, you can have an image with the different platforms/archs under a single tag. You don`t need to create a separate tag for each arch. https://docs.docker.com/build/building/multi-platform/#difference-between-single-platform-and-multi-platform-images

chekist32 commented 3 days ago

Here is an example GitHub workflow that builds a multi-platform image and pushes it to different registries. https://docs.docker.com/build/ci/github-actions/push-multi-registries/