rpi-ws281x / rpi-ws281x-go

Go library wrapping for the rpi-ws281x library
Apache License 2.0
66 stars 15 forks source link

problems building docker image #19

Closed aaaaargZombies closed 2 years ago

aaaaargZombies commented 2 years ago

I'm trying to compile for a rpi 4 but I'm getting stuck building the docker image.

When running $docker buildx build --platform linux/arm64 --tag ws2811-builder --file docker/app-builder/Dockerfile . I get the following.

#8 300.7 Setting up libalgorithm-merge-perl (0.08-3) ...
#8 300.7 Processing triggers for libc-bin (2.31-13+deb11u2) ...
#8 300.8 qemu: uncaught target signal 11 (Segmentation fault) - core dumped
#8 300.9 Segmentation fault (core dumped)
#8 300.9 qemu: uncaught target signal 11 (Segmentation fault) - core dumped
#8 301.0 Segmentation fault (core dumped)
#8 301.0 dpkg: error processing package libc-bin (--configure):
#8 301.0  installed libc-bin package post-installation script subprocess returned error exit status 139
#8 301.0 Processing triggers for ca-certificates (20210119) ...
#8 301.3 Updating certificates in /etc/ssl/certs...
#8 329.5 0 added, 0 removed; done.
#8 329.5 Running hooks in /etc/ca-certificates/update.d...
#8 329.5 done.
#8 329.7 Errors were encountered while processing:
#8 329.7  libc-bin
#8 330.0 E: Sub-process /usr/bin/dpkg returned an error code (1)
------
Dockerfile:7
--------------------
   6 |     
   7 | >>> RUN apt-get update -y && apt-get install -y \
   8 | >>>   build-essential \
   9 | >>>   cmake \
  10 | >>>   git
  11 |     
--------------------
error: failed to solve: process "/bin/sh -c apt-get update -y && apt-get install -y   build-essential   cmake   git" did not complete successfully: exit code: 100

It seems to crash when trying any apt-get install so I thought that might be the issue but when I tried building for arm/v7 it makes it past this stage and I get the following.

 => [stage-1 3/4] COPY --from=lib_builder /usr/local/include/ws2811 /usr/local/include/ws2811                                                                        0.0s 
 => ERROR [stage-1 4/4] RUN go get github.com/rpi-ws281x/rpi-ws281x-go                                                                                               1.2s 
------                                                                                                                                                                    
 > [stage-1 4/4] RUN go get github.com/rpi-ws281x/rpi-ws281x-go:                                                                                                          
#12 0.817 qemu: uncaught target signal 11 (Segmentation fault) - core dumped                                                                                              
#12 1.044 Segmentation fault (core dumped)
------
Dockerfile:26
--------------------
  24 |     COPY --from=lib_builder /usr/local/include/ws2811 /usr/local/include/ws2811
  25 |     
  26 | >>> RUN go get github.com/rpi-ws281x/rpi-ws281x-go
  27 |     
--------------------
error: failed to solve: process "/bin/sh -c go get github.com/rpi-ws281x/rpi-ws281x-go" did not complete successfully: exit code: 139

So perhaps qemu (segmentation fault) is the real issue?

Any suggestions about how to get it working would be greatly appreciated.

aaaaargZombies commented 2 years ago

Seems to be related to this bug

https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1928075

I changed to debian buster and now both arm/v7 and arm64 fail on go get

supcik commented 2 years ago

Thank you for opening this issue. I will check.

aaaaargZombies commented 2 years ago

@supcik Thanks for your response, I think I have made some progress.

It looks like I had a slightly older version of qemu arm64 registered with docker, i needed to get the latest from here

docker run --rm --privileged docker/binfmt:a7996909642ee92942dcd6cff44b9b95f08dad64

I also needed to add --load to the build command to make use of the image.

docker buildx build --platform linux/arm64 --tag ws2811-builder --file docker/app-builder/Dockerfile --load .

which now takes me to this point

> cd examples/swiss
> APP="swiss"
> docker run --rm -v "$PWD":/usr/src/$APP --platform linux/arm64 \  -w /usr/src/$APP ws2811-builder:latest go build -o "$APP-arm64" -v

go: go.mod file not found in current directory or any parent directory; see 'go help modules'
aaaaargZombies commented 2 years ago

Just following up in case someone else is in a similar situation.

I resolved the issue by running

go mod init example.com/m
go mod tidy

Before running

docker run --rm -v "$PWD":/usr/src/$APP --platform linux/arm64 \\n  -w /usr/src/$APP ws2811-builder:latest go build -o "$APP-arm64" -v\n
scp swiss-arm64 ubuntu@pi4:ledTest/go

Maybe this is obvious to most but I'e not really used Go so followed the readme to the letter.