Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Docker image build fails on M1 macOS running in Docker via colima #4351

Closed
Bobronium opened this issue Mar 9, 2024 · 1 comment
Closed
Assignees
Labels
Bug Something isn't working iroha2-dev The re-implementation of a BFT hyperledger in RUST

Comments

@Bobronium
Copy link

OS and Environment

M1, macOS 14.2.1 (23C71), Ubuntu 23.10 aarch64 ran via macOS Virtualization.Framework

GIT commit hash

2ffcd00

Minimum working example / Steps to reproduce

Setup:

brew install colima docker docker-buildx
colima start --profile rosetta --cpu 4 --disk 40 --memory 8 --arch aarch64 --vm-type=vz --vz-rosetta --mount-type virtiofs
docker context use colima-rosetta
~
$ docker version
Client: Docker Engine - Community
 Version:           24.0.6
 API version:       1.43
 Go version:        go1.21.0
 Git commit:        ed223bc820
 Built:             Thu Aug 31 17:24:32 2023
 OS/Arch:           darwin/arm64
 Context:           colima-rosetta

Server: Docker Engine - Community
 Engine:
  Version:          24.0.9
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.13
  Git commit:       fca702d
  Built:            Thu Feb  1 00:48:55 2024
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.6.28
  GitCommit:        ae07eda36dd25f8a1b98dfbf587313b99c0190bb
 runc:
  Version:          1.1.12
  GitCommit:        v1.1.12-0-g51d5e94
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Reproduction:

docker build -t iroha_builder --target builder --platform linux/amd64 --progress plain .

or

docker compose -f docker-compose.dev.local.yml up

Actual result

302.0   error occurred: Command ZERO_AR_DATE="1" "/x86_64-linux-musl-native/bin/x86_64-linux-musl-ar" "cq" "/iroha/target/x86_64-unknown-linux-musl/deploy/build/secp256k1-sys-339b725278eb88a1/out/libsecp256k1.a" "/iroha/target/x86_64-unknown-linux-musl/deploy/build/secp256k1-sys-339b725278eb88a1/out/depend/secp256k1/contrib/lax_der_parsing.o" "/iroha/target/x86_64-unknown-linux-musl/deploy/build/secp256k1-sys-339b725278eb88a1/out/depend/secp256k1/src/secp256k1.o" with args "/x86_64-linux-musl-native/bin/x86_64-linux-musl-ar" did not execute successfully (status code exit status: 127).

...

failed to solve: process "/bin/sh -c cargo build --target x86_64-unknown-linux-musl --features vendored --profile deploy" did not complete successfully: exit code: 101

Full logs are quite large even to be displayed under spoiler, so I've uploaded them here: https://pastes.io/vodrxxuvnm

Expected result

Expected docker image to be built without issues (see more in Notes)

Logs in JSON format

Not applicable — application didn't start

Who can help to reproduce?

No response

Notes

After some digging, I've discovered that while /x86_64-linux-musl-native/bin/x86_64-linux-musl-ar was absent, there was /x86_64-linux-musl-native/bin/x86_64-linux-musl-gcc-ar.

So I've made the following addition to Dockerfile and it worked!

# Fix build on macOS via colima
RUN ln -s /x86_64-linux-musl-native/bin/x86_64-linux-musl-gcc /x86_64-linux-musl-native/bin/x86_64-linux-musl
RUN ln -s /x86_64-linux-musl-native/bin/x86_64-linux-musl-gcc-11.2.1 /x86_64-linux-musl-native/bin/x86_64-linux-musl-11.2.1
RUN ln -s /x86_64-linux-musl-native/bin/x86_64-linux-musl-gcc-ar /x86_64-linux-musl-native/bin/x86_64-linux-musl-ar
RUN ln -s /x86_64-linux-musl-native/bin/x86_64-linux-musl-gcc-nm /x86_64-linux-musl-native/bin/x86_64-linux-musl-nm
RUN ln -s /x86_64-linux-musl-native/bin/x86_64-linux-musl-gcc-ranlib /x86_64-linux-musl-native/bin/x86_64-linux-musl-ranlib
Successful build log
$ docker compose -f docker-compose.dev.local.yml up
[+] Building 1585.2s (45/60)                                                                                                                docker:colima-rosetta
=> [iroha2 internal] load .dockerignore                                                                                                                     0.0s
=> => transferring context: 62B                                                                                                                             0.0s
=> [iroha2 internal] load build definition from Dockerfile                                                                                                  0.0s
=> => transferring dockerfile: 3.09kB                                                                                                                       0.0s
=> [iroha0 internal] load .dockerignore                                                                                                                     0.0s
=> => transferring context: 62B                                                                                                                             0.0s
=> [iroha0 internal] load build definition from Dockerfile                                                                                                  0.0s
=> => transferring dockerfile: 3.09kB                                                                                                                       0.0s
=> [iroha3 internal] load .dockerignore                                                                                                                     0.0s
=> => transferring context: 62B                                                                                                                             0.0s
=> [iroha3 internal] load build definition from Dockerfile                                                                                                  0.0s
=> => transferring dockerfile: 3.09kB                                                                                                                       0.0s
=> [iroha1 internal] load metadata for docker.io/library/alpine:3.18                                                                                        0.7s
=> [iroha1 internal] load metadata for docker.io/library/archlinux:base-devel                                                                               0.8s
=> [iroha1 internal] load build definition from Dockerfile                                                                                                  0.0s
=> => transferring dockerfile: 3.09kB                                                                                                                       0.0s
=> [iroha1 internal] load .dockerignore                                                                                                                     0.0s
=> => transferring context: 62B                                                                                                                             0.0s
=> [iroha1 stage-1 1/5] FROM docker.io/library/alpine:3.18@sha256:11e21d7b981a59554b3f822c49f6e9f57b6068bb74f49c4cd5cc4c663c7e5160                          0.0s
=> [iroha2 builder  1/22] FROM docker.io/library/archlinux:base-devel@sha256:10d05806f5ab14b5630ca80951e291bfc840c5989ce011594f387b08263a6fbb               0.0s
=> [iroha1 internal] load build context                                                                                                                     0.1s
=> => transferring context: 117.92kB                                                                                                                        0.1s
=> CACHED [iroha2 stage-1 2/5] RUN  set -ex &&      apk add --no-cache curl ca-certificates &&      addgroup -g 1001 iroha &&      adduser      --disabled  0.0s
=> [iroha3 internal] load build context                                                                                                                     0.0s
=> => transferring context: 117.92kB                                                                                                                        0.0s
=> [iroha2 internal] load build context                                                                                                                     0.1s
=> => transferring context: 117.92kB                                                                                                                        0.1s
=> [iroha0 internal] load build context                                                                                                                     0.1s
=> => transferring context: 117.92kB                                                                                                                        0.1s
=> CACHED [iroha0 builder  2/22] RUN pacman -Syy                                                                                                            0.0s
=> CACHED [iroha0 builder  3/22] RUN pacman -S archlinux-keyring --noconfirm --disable-download-timeout                                                     0.0s
=> CACHED [iroha0 builder  4/22] RUN rm -rf /etc/pacman.d/gnupg/* && pacman-key --init && pacman-key --populate archlinux                                   0.0s
=> CACHED [iroha0 builder  5/22] RUN pacman -Syu --noconfirm --disable-download-timeout                                                                     0.0s
=> CACHED [iroha0 builder  6/22] RUN pacman -S rustup mold musl rust-musl wget --noconfirm --disable-download-timeout                                       0.0s
=> CACHED [iroha0 builder  7/22] RUN rustup toolchain install nightly-2023-06-25                                                                            0.0s
=> CACHED [iroha0 builder  8/22] RUN rustup default nightly-2023-06-25                                                                                      0.0s
=> CACHED [iroha0 builder  9/22] RUN rustup target add x86_64-unknown-linux-musl wasm32-unknown-unknown                                                     0.0s
=> CACHED [iroha0 builder 10/22] RUN rustup component add rust-src                                                                                          0.0s
=> CACHED [iroha0 builder 11/22] RUN wget -c http://musl.cc/x86_64-linux-musl-native.tgz -O - | tar -xz                                                     0.0s
=> CACHED [iroha0 builder 12/22] RUN ln -s /x86_64-linux-musl-native/bin/x86_64-linux-musl-g++ /x86_64-linux-musl-native/bin/musl-g++                       0.0s
=> CACHED [iroha0 builder 13/22] RUN ln -s /x86_64-linux-musl-native/bin/x86_64-linux-musl-gcc-ar /x86_64-linux-musl-native/bin/musl-ar                     0.0s
=> CACHED [iroha0 builder 14/22] RUN ln -s /x86_64-linux-musl-native/bin/x86_64-linux-musl-gcc-ranlib /x86_64-linux-musl-native/bin/musl-ranlib             0.0s
=> CACHED [iroha0 builder 15/22] RUN ln -s /x86_64-linux-musl-native/bin/x86_64-linux-musl-gcc /x86_64-linux-musl-native/bin/x86_64-linux-musl              0.0s
=> CACHED [iroha0 builder 16/22] RUN ln -s /x86_64-linux-musl-native/bin/x86_64-linux-musl-gcc-11.2.1 /x86_64-linux-musl-native/bin/x86_64-linux-musl-11.2  0.0s
=> CACHED [iroha0 builder 17/22] RUN ln -s /x86_64-linux-musl-native/bin/x86_64-linux-musl-gcc-ar /x86_64-linux-musl-native/bin/x86_64-linux-musl-ar        0.0s
=> CACHED [iroha0 builder 18/22] RUN ln -s /x86_64-linux-musl-native/bin/x86_64-linux-musl-gcc-nm /x86_64-linux-musl-native/bin/x86_64-linux-musl-nm        0.0s
=> CACHED [iroha0 builder 19/22] RUN ln -s /x86_64-linux-musl-native/bin/x86_64-linux-musl-gcc-ranlib /x86_64-linux-musl-native/bin/x86_64-linux-musl-ranl  0.0s
=> CACHED [iroha0 builder 20/22] WORKDIR /iroha                                                                                                             0.0s
=> [iroha3 builder 21/22] COPY . .                                                                                                                          0.3s
=> [iroha3 builder 22/22] RUN cargo build --target x86_64-unknown-linux-musl --features vendored --profile deploy                                        1583.5s
=> [iroha3 stage-1 3/5] COPY --from=builder /iroha/target/x86_64-unknown-linux-musl/deploy/iroha /usr/local/bin/                                            0.1s
=> [iroha3 stage-1 4/5] COPY --from=builder /iroha/target/x86_64-unknown-linux-musl/deploy/iroha_client_cli /usr/local/bin/                                 0.0s
=> [iroha3 stage-1 5/5] COPY --from=builder /iroha/target/x86_64-unknown-linux-musl/deploy/kagami /usr/local/bin/                                           0.0s
=> [iroha1] exporting to image                                                                                                                              0.1s
=> => exporting layers                                                                                                                                      0.1s
=> => writing image sha256:7f914bf4ab00e69cb64b7efbc9b1f9ddf9e33e512b55d61a8b5626484803dff0                                                                 0.0s
=> => naming to docker.io/library/iroha-iroha1                                                                                                              0.0s
=> [iroha3] exporting to image                                                                                                                              0.1s
=> => exporting layers                                                                                                                                      0.1s
=> => writing image sha256:e7421f470289cc7b9a8a32fbc8d823f6705426c9ecefb3dffaa2050b9c58efc3                                                                 0.0s
=> => naming to docker.io/library/iroha-iroha3                                                                                                              0.0s
=> [iroha2] exporting to image                                                                                                                              0.1s
=> => exporting layers                                                                                                                                      0.1s
=> => writing image sha256:0fde52b8830206a56d4aee4faa642109a6645a2fa40bb6034279a4edda2263fe                                                                 0.0s
=> => naming to docker.io/library/iroha-iroha2                                                                                                              0.0s
=> [iroha0] exporting to image                                                                                                                              0.1s
=> => exporting layers                                                                                                                                      0.1s
=> => writing image sha256:d3aa92632ca13cd747e5ba25068b88a6f50b55a1d5215624a9b35396a4118401                                                                 0.0s
=> => naming to docker.io/library/iroha-iroha0                                                                                                              0.0s
[+] Running 5/1
✔ Network iroha_default     Created                                                                                                                         0.0s
✔ Container iroha-iroha2-1  Created                                                                                                                         0.0s
✔ Container iroha-iroha3-1  Created                                                                                                                         0.0s
✔ Container iroha-iroha1-1  Created                                                                                                                         0.0s
✔ Container iroha-iroha0-1  Created                                                                                                                         0.0s
Attaching to iroha-iroha0-1, iroha-iroha1-1, iroha-iroha2-1, iroha-iroha3-1

I'll submit PR with these additions shortly, though I wasn't able to understand why this problem appears in the first place, hence this issue.

@Bobronium Bobronium added Bug Something isn't working iroha2-dev The re-implementation of a BFT hyperledger in RUST labels Mar 9, 2024
@Bobronium
Copy link
Author

This seems related: #3451

And there seems to be existing issue, already fixed on iroha2-dev: #4192 (fix: #4193)

I'm not sure whether I should close this issue as a duplicate since it's still present on iroha2-stable at the moment.

@AlexStroke AlexStroke self-assigned this May 2, 2024
@alexstroke1 alexstroke1 assigned alexstroke1 and unassigned AlexStroke Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working iroha2-dev The re-implementation of a BFT hyperledger in RUST
Projects
None yet
Development

No branches or pull requests

3 participants