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

build: Build docker without open telemetry collector #228

Merged
merged 2 commits into from Jun 19, 2021

Conversation

pingleig
Copy link
Member

Description of the issue

We were using deb when building image from source, i.e. source -> deb -> docker image. But we have composite agent, which is not used when running as image.

Description of changes

  • Add two new targets (x86_64 and arm64) to only build binary required for docker image
  • Make amd64 the default target
  • Use the new target in Dockerfile

License

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Tests

Run the new commands (in a place that does not block go mod proxy)

docker buildx build --platform linux/amd64,linux/arm64 -f amazon-cloudwatch-container-insights/cloudwatch-agent-dockerfile/Dockerfile .

@pingleig pingleig added area/build Build and release binary/docker image size/xs 1-2 line code change or fixing typo labels Jun 14, 2021
@epf
Copy link

epf commented Jun 17, 2021

Note that this produces dynamically linked arm64 binaries (which ultimately fail to execute because the container doesn't contain the required libraries).

Adding CGO_ENABLED=0 to LINUX_ARM64_BUILD in the Makefile fixes this.

@pingleig
Copy link
Member Author

Actually things has been working fine (for our internal build) because we are not using dockerized build . We build arm64 binary on x86_64 host using cross compile, and cgo is is disabled by default when cross-compiling But we should set it explicitly.

pingleig added a commit to pingleig/amazon-cloudwatch-agent that referenced this pull request Jun 18, 2021
From aws#228 (comment)
We were assuming the arm binary is build on x86 using cross compile.
This is case for our internal build and has been working fine for
arm docker image, but if user build the binary on arm machines,
then cgo is enabled and the binary no longer runs in scratch container.
pingleig added a commit that referenced this pull request Jun 18, 2021
From #228 (comment)
We were assuming the arm binary is build on x86 using cross compile.
This is case for our internal build and has been working fine for
arm docker image, but if user build the binary on arm machines,
then cgo is enabled and the binary no longer runs in scratch container.
@pingleig
Copy link
Member Author

Fixed the arm cgo problem in #235

@pingleig pingleig requested a review from pxaws June 18, 2021 22:45
@pingleig pingleig merged commit ae7730c into aws:master Jun 19, 2021
sky333999 pushed a commit that referenced this pull request Jul 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/build Build and release binary/docker image size/xs 1-2 line code change or fixing typo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants