docker / build-push-action

GitHub Action to build and push Docker images with Buildx
https://github.com/marketplace/actions/build-and-push-docker-images
Apache License 2.0
4.31k stars 552 forks source link

Docker build hangs for `linux/arm/v7` #1071

Closed Lissy93 closed 7 months ago

Lissy93 commented 7 months ago

Contributing guidelines

I've found a bug, and:

Description

Feel free to close this ticket if you don't think it's an issue with this action. But any pointers would also be much appreciated, I've been going round in circles for hours trying to get it to work.

I have the following workflow file which builds this Dockerfile, and it always used to work great.

But now it only works for linux/amd64 and linux/arm64 architectures, as soon as I add linux/arm/v7 back in under platforms, the workflow just hangs forever midway through the ARM v7 step (specifically during yarn install) - here's an example run

Expected behaviour

I expect linux/arm/v7 to complete successfully, like it does for linux/amd64 and linux/arm64

Actual behaviour

The workflow just hangs indefinabley once it starts the yarn install on the linux/arm/v7 step.

Repository URL

https://github.com/Lissy93/dashy

Workflow run URL

https://github.com/Lissy93/dashy/actions/workflows/docker-build-publish.yml

YAML workflow

Full workflow file here:
https://github.com/Lissy93/dashy/blob/HEAD/.github/workflows/docker-build-publish.yml

The relevant step is:

- name: ⚒️ Build and push
  uses: docker/build-push-action@v2
  with:
    context: .
    file: ./Dockerfile
    platforms: linux/amd64,linux/arm64,linux/arm/v7
    tags: ${{ steps.meta.outputs.tags }}
    labels: ${{ steps.meta.outputs.labels }}
    push: true

Workflow logs

logs_21336268151.zip or on GitHub at: https://github.com/Lissy93/dashy/actions/runs/8133127098/job/22224327445

Another example: here

BuildKit logs

No response

Additional info

Thank you for building and maintaining this action, it's been super useful 💙

Lissy93 commented 7 months ago

Ah, I found a workaround.

For anyone who faces something similar, issue is something to do with the newer Node containers (V18 upwards).

I believe it happens because the x86 host is building for a non-native platform, and QEMU emulation is very intensive, crashing the GitHub worker, but weirdly never exiting (I'd expect a ENOMEM failure).

Relevant issues:

Example fix, in my project: https://github.com/Lissy93/dashy/pull/1492

It's frustrating, because performance and security of Node 20+ is much better. But since this issue only happens during npm install / yarn install, it's possible to use Node 18 for the build stage, then Node 21 for the run stage (feels weird, but works well).

# Build stage
- FROM node:20.11.1-alpine AS BUILD_IMAGE
+ FROM node:18.19.1-alpine AS BUILD_IMAGE
...

# Run stage
FROM node:20.11.1-alpine3.19
...