restechnica / semverbot

A CLI which automates semver versioning.
Mozilla Public License 2.0
136 stars 7 forks source link

sbot is not M1-docker compatible #44

Closed ToneVDB closed 2 years ago

ToneVDB commented 2 years ago

Context:

I have the below dockerfile on an M1 mac:

FROM node:16
ARG SEMVERBOT_VERSION=1.1.0
# install sbot 
RUN curl -o /usr/local/bin/sbot https://github.com/restechnica/semverbot/releases/download/v$SEMVERBOT_VERSION/sbot-linux-amd64 && \
    chmod +x /usr/local/bin/sbot

CMD ["/bin/bash"]

I build the image with the command docker build . --tag testimage We enter it via docker run --user 0 -it testimage /bin/bash

Behaviour:

Running the command sbot --help renders the following output: qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory

Expected behaviour:

sbot --help should output the help options

Temporary solution:

Build the dockerfile using the command: docker build . --tag testimage --platform linux/x86_64 Run the image using the command: docker run --platform linux/x86_64 --user 0 -it testimage /bin/bash sbot --help now outputs the correct information

Is this by design or a bug in docker or sbot?

shiouen commented 2 years ago

@ToneVDB at first glance I'm confused as to why a docker image wouldn't be able to run an executable due to its host architecture. The only thing we could change is providing binaries for arm, which might be a good thing to do anyway.

shiouen commented 2 years ago

@ToneVDB and I investigated together and concluded that his docker engine was configured to use linux/arm64, which leads to incompatibility with the amd64 binary.

For future reference, if anyone experiences docker issues with their arm chips, have a look at https://stackoverflow.com/a/69636473/1498043. You can configure Docker to make use of the linux/amd64 platform instead of linux/arm64. This can be configured in multiple ways: an environment variable, a Dockerfile FROM option, a docker compose platform property and possibly there are other ways as well.