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

TARGETARCH cannot have a value set #1013

Closed
mdonkers opened this issue Jul 24, 2023 · 2 comments
Closed

TARGETARCH cannot have a value set #1013

mdonkers opened this issue Jul 24, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@mdonkers
Copy link
Contributor

Bug Report

Which version of the demo you are using? (please provide either a specific
#944

Symptom

Docker build is failing after the OTel Collector Dockerfile got updated

$ docker build --platform linux/amd64 -t otelcol -f src/otelcollector/Dockerfile .
[+] Building 0.7s (14/19)                                                                                                                                                                            docker:default
 => [internal] load .dockerignore                                                                                                                                                                              0.0s
 => => transferring context: 1.18kB                                                                                                                                                                            0.0s
 => [internal] load build definition from Dockerfile                                                                                                                                                           0.0s
 => => transferring dockerfile: 997B                                                                                                                                                                           0.0s
 => [internal] load metadata for docker.io/library/alpine:latest                                                                                                                                               0.4s
 => [internal] load metadata for docker.io/library/golang:latest                                                                                                                                               0.4s
 => [internal] load metadata for docker.io/library/alpine:3.16                                                                                                                                                 0.0s
 => [build 1/7] FROM docker.io/library/golang:latest@sha256:cfc9d1b07b1ef4f7a4571f0b60a99646a92ef76adb7d9943f4cb7b606c6554e2                                                                                   0.0s
 => [internal] load build context                                                                                                                                                                              0.0s
 => => transferring context: 294B                                                                                                                                                                              0.0s
 => [certs 1/2] FROM docker.io/library/alpine:3.16                                                                                                                                                             0.0s
 => [stage-2 1/4] FROM docker.io/library/alpine@sha256:82d1e9d7ed48a7523bdebc18cf6290bdb97b82302a8a9c27d4fe885949ea94d1                                                                                        0.0s
 => CACHED [build 2/7] RUN curl -L -o /builder https://github.com/open-telemetry/opentelemetry-collector/releases/download/cmd%2Fbuilder%2Fv0.81.0/ocb_0.81.0_linux_arm64                                      0.0s
 => CACHED [build 3/7] RUN chmod +x /builder                                                                                                                                                                   0.0s
 => CACHED [build 4/7] WORKDIR /build                                                                                                                                                                          0.0s
 => CACHED [build 5/7] COPY ./src/otelcollector/manifest.yml ./                                                                                                                                                0.0s
 => ERROR [build 6/7] RUN /builder --config ./manifest.yml --output-path /build/_build                                                                                                                         0.3s
------
 > [build 6/7] RUN /builder --config ./manifest.yml --output-path /build/_build:
0.226 /bin/sh: 1: /builder: Exec format error
------
Dockerfile:15
--------------------
  13 |     ENV GOARCH=arm64
  14 |     ENV CGO_ENABLED=0
  15 | >>> RUN /builder --config ./manifest.yml --output-path /build/_build
  16 |     RUN ls /build/_build
  17 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c /builder --config ./manifest.yml --output-path /build/_build" did not complete successfully: exit code: 126

As can be seen in the output, even though --platform=linux/amd64 is specified, the Dockerfile pulls the arm64 version of Builder.

What is the expected behavior?

Successful Docker build

What is the actual behavior?

A build failure with the above exception

Reproduce

Try to build the OTel Collector Docker image on a non-arm64 machine.

It only works fine when supplying the TARGETARCH parameter directly, as in --build-arg="TARGETARCH=amd64" Not entirely sure why it does work for you build system, perhaps because of the type of runner.

@mdonkers
Copy link
Contributor Author

Additionally, see also this blog from Docker, where they describe the use of the parameters: https://www.docker.com/blog/faster-multi-platform-builds-dockerfile-cross-compilation-guide/
There TARGETARCH is also defined without default.

@julianocosta89
Copy link
Member

I can reproduce this on Ubuntu 22.04.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants