Repository navigation
[519] Cross-arch builds: builders variables - #907
Conversation
WalkthroughThe changes introduce dynamic detection of the Docker buildx builder and supported platforms in a shared Makefile snippet. These new variables are then used in the Docker build command for the CozyStack controller, ensuring explicit specification of builder and platform during image builds. Changes
Sequence Diagram(s)sequenceDiagram
participant Developer
participant Makefile
participant Docker Buildx
Developer->>Makefile: Invoke build target
Makefile->>Makefile: Set BUILDER and PLATFORM variables (dynamic detection)
Makefile->>Docker Buildx: Build image with --builder and --platform options
Docker Buildx-->>Makefile: Build process completes
Makefile-->>Developer: Build result
Poem
Tip ⚡️ Faster reviews with caching
Enjoy the performance boost—your workflow just got faster. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Timofei Larkin (lllamnyp)
left a comment
There was a problem hiding this comment.
The general direction I want to go in is that the GitHub actions for building Cozystack don't change too much, but any developer, who doesn't have access to our cloud runners can also just set up a buildx builder, pass in the right values for PLATFORMS and/or BUILDER and also get good results.
Now it works like this:
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/system/cozystack-controller/Makefile (1)
12-13: Cross-arch build support correctly implementedThese changes correctly implement the cross-architecture build support by using the dynamically determined builder and platform variables from common-envs.mk.
Consider adding a comment above these new options explaining the cross-architecture build functionality, for example:
docker buildx build -f images/cozystack-controller/Dockerfile ../../.. \ --provenance false \ + # Use specified or detected buildx builder and platforms for cross-architecture builds --builder=$(BUILDER) \ --platform=$(PLATFORM) \
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/system/cozystack-controller/Makefile(1 hunks)scripts/common-envs.mk(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Build and Test
🔇 Additional comments (1)
scripts/common-envs.mk (1)
18-23:Details
❓ Verification inconclusive
Solid approach for dynamically determining builder and platforms
The implementation for determining the Docker buildx builder and supported platforms is well thought out. Using the buildx inspect command to extract platform information is a practical approach.
A few considerations:
- The parsing of command output (
egrep,sort,sed) is functional but potentially brittle if Docker CLI output formats change- The commented-out JSON parsing alternative could be more stable long-term, as previously discussed in the PR comments
🏁 Script executed:
#!/bin/bash # Verify that the platform detection works correctly with various builder setups echo "Testing platform detection..." BUILDER=$(jq -r '.Name' ~/.docker/buildx/current 2>/dev/null || echo "default") echo "Current builder: $BUILDER" # Verify the platform detection works PLATFORMS=$(docker buildx inspect --bootstrap $BUILDER 2>/dev/null | egrep '^Platforms:' | egrep -o 'linux/amd64|linux/arm64' | sort -u | xargs | sed 's/ /,/g') echo "Detected platforms: $PLATFORMS" # Verify that the command doesn't break with different builders docker buildx ls | awk '{print $1}' | grep -v "^NAME" | while read builder; do echo "Testing with builder: $builder" PLATFORMS=$(docker buildx inspect --bootstrap $builder 2>/dev/null | egrep '^Platforms:' | egrep -o 'linux/amd64|linux/arm64' | sort -u | xargs | sed 's/ /,/g') echo " - Detected platforms: $PLATFORMS" doneLength of output: 590
Manual verification required for Docker Buildx platform detection
The sandbox environment doesn’t include Docker or Buildx, so the verification script couldn’t produce any platforms. Please test this locally in an environment with Docker Buildx installed:
- Run
and confirm it outputs the expected comma-separated platforms.BUILDER=$(jq -r '.Name' ~/.docker/buildx/current) docker buildx inspect --bootstrap "$BUILDER" \ | egrep '^Platforms:' \ | egrep -o 'linux/amd64|linux/arm64' \ | sort -u \ | xargs | sed 's/ /,/g'- Repeat for each builder returned by
docker buildx ls.- Evaluate the commented JSON-parsing alternative:
to see if it yields more stable results over future Docker CLI changes.PLATFORM ?= $(shell jq -r '.Nodes[] | .Platforms | map(.os + "/" + .architecture) | join(",")' \ ~/.docker/buildx/instances/$(BUILDER))
|
Nikita (@nbykov0) DCO check failed, please do |
796b74d to
8d36753
Compare
|
I've messed a bit while rebasing, commit |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/core/platform/bundles/paas-full.yaml (1)
137-141: EnsurecpuAllocationRatiois documented and validated in the Helm chart.The bundle correctly pulls
cpu-allocation-ratiofrom thecozystackConfigMap into thekubevirtrelease values when present. As a follow-up:
- Confirm that the
cozy-kubevirtchart’svalues.yamldeclarescpuAllocationRatio(with a default, type, and description) so it’s discoverable in docs.- Run
helm lint packages/core/platform/bundles/paas-full.yamlandhelm templateon your bundle to verify rendering.Optionally, add to
packages/system/kubevirt/values.yaml:cpuAllocationRatio: null # CPU overcommit ratio for KubeVirt (e.g. 1.5, 2.0)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
packages/core/platform/bundles/paas-full.yaml(1 hunks)packages/system/cozystack-controller/Makefile(1 hunks)packages/system/kubevirt/templates/kubevirt-cr.yaml(1 hunks)scripts/common-envs.mk(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/system/cozystack-controller/Makefile
- scripts/common-envs.mk
🧰 Additional context used
🪛 YAMLlint (1.35.1)
packages/system/kubevirt/templates/kubevirt-cr.yaml
[warning] 14-14: wrong indentation: expected 4 but found 6
(indentation)
[error] 13-13: syntax error: expected the node content, but found '-'
(syntax)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Build and Test
🔇 Additional comments (1)
packages/system/kubevirt/templates/kubevirt-cr.yaml (1)
13-15: Conditional inclusion of cpuAllocationRatio is correct; ignore YAMLlint false positives.The Helm snippet properly wraps
cpuAllocationRatiounderdeveloperConfigurationonly when.Values.cpuAllocationRatiois set. The indentation (6 spaces underdeveloperConfiguration) aligns with sibling keys likefeatureGates. The YAMLlint errors here are false positives caused by Helm directives and can be safely ignored.Please validate via Helm:
helm lint packages/system/kubevirt helm template test-release packages/system/kubevirt🧰 Tools
🪛 YAMLlint (1.35.1)
[warning] 14-14: wrong indentation: expected 4 but found 6
(indentation)
[error] 13-13: syntax error: expected the node content, but found '-'
(syntax)
7fbe18b to
3067bd1
Compare
Signed-off-by: nbykov0 <[email protected]>
Signed-off-by: nbykov0 <[email protected]>
Signed-off-by: nbykov0 <[email protected]>
Signed-off-by: nbykov0 <[email protected]>
…kefile Signed-off-by: nbykov0 <[email protected]>
Signed-off-by: nbykov0 <[email protected]>
Signed-off-by: nbykov0 <[email protected]>
Signed-off-by: nbykov0 <[email protected]>
This reverts commit 8d36753. The check it introduced is not needed. Signed-off-by: nbykov0 <[email protected]>
Signed-off-by: nbykov0 <[email protected]>
3067bd1 to
2349ff6
Compare
Added PLATFORM variable to `common-envs.mk`: if not defined, it is calculated based on docker daemon arch. May be overridden by e.g. `make -e PLATFORM='linux/arm64' ...` Added the variable to a single Dockerfile for now. (cherry picked from commit 653e2bc) Signed-off-by: Timofei Larkin <[email protected]>
Added PLATFORM variable to
common-envs.mk: if not defined, it is calculated based on docker daemon arch.May be overridden by e.g.
make -e PLATFORM='linux/arm64' ...Added the variable to a single Dockerfile for now.
Summary by CodeRabbit