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

Feature/ocu 184 allow binaries and containers to be built for architectures different than amd #343

Conversation

andream16
Copy link
Contributor

As per title, allow to customise the built images and binaries for 🍎 people and documenting the utilisation.

We basically use --platform when building to specify for which platform we want to build an image. At the same time we can customise for which architecture the Go binaries should be built for.


Based on the supplied ARCH and OS, a binary is created in a self-documented sub-folder, as follows:

Screenshot 2024-09-09 at 15 04 16


It would be nice to collapse the different Dockerfiles and Makefiles in components into a single one, so such customisation can be centralised. I'll start a thread in the chat about it.


Tested locally:

  • make components -> builds with linux/amd64 by default. Running the containers works fine.
  • make GOOS=linux GOARCH=arm64 CONTAINER_OS_ARCH=linux/arm64 components -> builds with linux/arm64. Running the containers work.
  • make GOOS=darwin GOARCH=arm64 component-binaries -> build with darwin/arm64 and I can exec the binaries fine on my machine.

I would appreciate if you can try these commands yourself and if you have other pointers to what to test.


Minor: bumping remark-cli to v12.0.1 to suppress formatting errors.

…or better compatibility on different machines. Defaulting to linux/amd64 and allowing for customization.
…RCH for building binaries. Bumping remark-cli to suppress errors and warnings on linting markdown files.
executable_src_path=$(dirname "${1}")
executable_path=$(dirname "${1}")/"${executable}"
executable_src_path=$(dirname $dir_name)
executable_path=$(dirname $dir_name)/${build_architecture}/"${executable}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can you encapsulate please the BASH variables in curly brackets here and here: eea4040#diff-e886250d151c99b2b701ddeab8e0e58bcac8f434e02ead4aafaab12462fa8e86R25 for consistency?

$$([ "${SOURCE_CODE_REPO}" != "" ] && echo "--label=org.opencontainers.image.source=${SOURCE_CODE_REPO}" ) \
-f containers/Dockerfile.draconctl .
-f containers/Dockerfile.draconctl . \
--platform=$(CONTAINER_OS_ARCH)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as far as I can see this is the only point where the CONTAINER_OS_ARCH is used. can we replace it with just $(GOOS)/$(GOARCH)

@ptzianos ptzianos marked this pull request as draft September 12, 2024 17:07
@andream16 andream16 closed this Sep 15, 2024
@andream16
Copy link
Contributor Author

Closed in favour of https://github.com/ocurity/dracon/pull/350/files

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

Successfully merging this pull request may close these issues.

2 participants