open-telemetry / opentelemetry-demo

This repository contains the OpenTelemetry Astronomy Shop, a microservice-based distributed system intended to illustrate the implementation of OpenTelemetry in a near real-world environment.
https://opentelemetry.io/docs/demo/
Apache License 2.0
1.88k stars 1.25k forks source link

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

Open sergiohinojosa opened 5 days ago

sergiohinojosa commented 5 days ago

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

julianocosta89 commented 1 day ago

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 commented 18 hours ago

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

julianocosta89 commented 10 hours ago

I'll ask for help here 😅 @puckpuck any ideas?