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

How can I crosscompile with a MAC M1 for a linux target platform? #1801

Open
sergiohinojosa opened this issue Nov 29, 2024 · 2 comments
Open
Labels
question Further information is requested

Comments

@sergiohinojosa
Copy link

sergiohinojosa commented Nov 29, 2024

Question

When I deploy the images/pods built without changing any configuration to a linux system I get an error like the following:

exec ./build/install/opentelemetry-demo-ad-service/bin/AdService: exec format error

If I set as a global environment the default platform to be linux/amd64

DOCKER_DEFAULT_PLATFORM=linux/amd64

then I get an error in the shipping service since this is C++ and has more plattform dependencies.

`

[shippingservice builder 3/8] RUN if [ "linux/amd64" = "linux/arm64" ] ; then apt-get update && apt-get install --no-install-recommends -y g++ libc6-dev libprotobuf-dev protobuf-compiler ca-certificates; elif [ "linux/amd64" = "linux/arm64" ] ; then apt-get update && apt-get install --no-install-recommends -y g++-aarch64-linux-gnu libc6-dev-arm64-cross libprotobuf-dev protobuf-compiler ca-certificates && rustup target add aarch64-unknown-linux-gnu && rustup toolchain install stable-aarch64-unknown-linux-gnu; else echo "linux/amd64 is not supported"; exit 1; fi:
0.520 linux/amd64 is not supported
failed to solve: process "/bin/sh -c if [ "${TARGETPLATFORM}" = "${BUILDPLATFORM}" ] ; then apt-get update && apt-get install --no-install-recommends -y g++ libc6-dev libprotobuf-dev protobuf-compiler ca-certificates; elif [ "${TARGETPLATFORM}" = "linux/arm64" ] ; then apt-get update && apt-get install --no-install-recommends -y g++-aarch64-linux-gnu libc6-dev-arm64-cross libprotobuf-dev protobuf-compiler ca-certificates && rustup target add aarch64-unknown-linux-gnu && rustup toolchain install stable-aarch64-unknown-linux-gnu; else echo "${TARGETPLATFORM} is not supported"; exit 1; fi" did not complete successfully: exit code: 1
make: *** [build-and-push-dockerhub] Error 17
`

then I tried to live without the shipping service by taking the build out from docker compose but the next svc fails

`

[frauddetectionservice] importing cache manifest from docker.io/shinojosa/astroshop:1.12.0-frauddetectionservice:
failed to solve: process "/bin/sh -c chmod +x /usr/local/bin/install-php-extensions && install-php-extensions opcache pcntl protobuf opentelemetry" did not complete successfully: exit code: 100
make: *** [build-and-push-dockerhub] Error 17
`

Any hints would be greately appretiated

Sergio

@sergiohinojosa sergiohinojosa added the question Further information is requested label Nov 29, 2024
@julianocosta89
Copy link
Member

Hey @sergiohinojosa 👋🏽
Nice to see you here!

You can use the following to cross-compile:

make create-multiplatform-builder
make build-multiplatform

That will use docker buildx to compile for platform=linux/amd64,linux/arm64.

@sergiohinojosa
Copy link
Author

Hi @julianocosta89 nice to see you! long time no see!
I hope you are doing great!

hey, thanks for your reply. I was working with a version that did not have the multiplatform builder in the Makefile. I just pulled everything and gave it a try, but unfortunately I'm getting a docker error that does not support exporting manifest lists. See below. Any hints?

make create-multiplatform-builder
docker buildx create --name otel-demo-builder --bootstrap --use --driver docker-container --config ./buildkitd.toml
[+] Building 2.3s (1/1) FINISHED
 => [internal] booting buildkit                                                                                                                                                                                                                           2.3s
 => => pulling image moby/buildkit:buildx-stable-1                                                                                                                                                                                                        1.8s
 => => creating container buildx_buildkit_otel-demo-builder0                                                                                                                                                                                              0.4s
otel-demo-builder
❯ make build-multiplatform
# Because buildx bake does not support --env-file yet, we need to load it into the environment first.
set -a; . ./.env.override; set +a && docker buildx bake -f docker-compose.yml --load --set "*.platform=linux/amd64,linux/arm64"
[+] Building 0.2s (1/1) FINISHED                                                                                                                                                                                            docker-container:otel-demo-builder
 => [internal] load local bake definitions                                                                                                                                                                                                                0.0s
 => => reading docker-compose.yml 22.31kB / 22.31kB                                                                                                                                                                                                       0.0s
ERROR: docker exporter does not currently support exporting manifest lists
make: *** [build-multiplatform] Error 1

Thanks and best

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants