Skip to content

[build] Cross-arch builds: components - #932

Merged
Andrei Kvapil (kvaps) merged 22 commits into
mainfrom
519-cross-arch-components
May 17, 2025
Merged

[build] Cross-arch builds: components#932
Andrei Kvapil (kvaps) merged 22 commits into
mainfrom
519-cross-arch-components

Conversation

@nbykov0

@nbykov0 Nikita (nbykov0) commented May 9, 2025

Copy link
Copy Markdown
Collaborator

Components with existing dockerfiles will be updated in this PR.

Part of #519

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added support for multi-architecture and cross-platform Docker image builds across various components, enabling builds for different operating systems and CPU architectures.
  • Chores

    • Updated Docker build commands in multiple Makefiles to use configurable builder and platform variables, improving build flexibility.
    • Standardized Dockerfile build arguments and environment variables for cross-compilation.
    • Improved package installation commands for quieter and more minimal installs in Dockerfiles.
    • Changed the default bucket name configuration to "cozystack" in system bucket settings.
    • Updated some maintenance targets and manual update reminders in Makefiles.

@nbykov0 Nikita (nbykov0) self-assigned this May 9, 2025
@coderabbitai

coderabbitai Bot commented May 9, 2025

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

Walkthrough

This change updates multiple Makefiles and Dockerfiles across the repository to support configurable, multi-architecture Docker builds. Hardcoded architecture and platform flags are replaced with variables ($(BUILDER), $(PLATFORM), TARGETOS, TARGETARCH), and Dockerfiles are updated for cross-compilation and dynamic binary downloads based on target architecture and OS.

Changes

Files/Paths (Grouped) Change Summary
packages/apps/clickhouse/Makefile, packages/apps/http-cache/Makefile, packages/apps/kubernetes/Makefile, packages/apps/mysql/Makefile, packages/apps/postgres/Makefile, packages/core/testing/Makefile, packages/extra/monitoring/Makefile, packages/system/bucket/Makefile, packages/system/cilium/Makefile, packages/system/cozystack-api/Makefile, packages/system/dashboard/Makefile, packages/system/kamaji/Makefile, packages/system/kubeovn-webhook/Makefile, packages/system/kubeovn/Makefile Makefile Docker build commands now use --builder=$(BUILDER) and --platform=$(PLATFORM) instead of hardcoded architecture/platform flags, enabling dynamic multi-architecture builds. No logic or exported entity changes.
packages/apps/http-cache/images/nginx-cache/Dockerfile, packages/apps/kubernetes/images/cluster-autoscaler/Dockerfile, packages/apps/kubernetes/images/kubevirt-cloud-provider/Dockerfile, packages/apps/kubernetes/images/kubevirt-csi-driver/Dockerfile, packages/apps/kubernetes/images/ubuntu-container-disk/Dockerfile, packages/core/testing/images/e2e-sandbox/Dockerfile, packages/system/bucket/images/s3manager/Dockerfile, packages/system/cozystack-api/images/cozystack-api/Dockerfile, packages/system/cozystack-controller/images/cozystack-controller/Dockerfile, packages/system/dashboard/images/kubeapps-apis/Dockerfile, packages/system/kamaji/images/kamaji/Dockerfile, packages/system/kubeovn-webhook/images/kubeovn-webhook/Dockerfile Dockerfiles updated to support cross-compilation via TARGETOS and TARGETARCH build arguments. Binary downloads and build steps now use these variables for dynamic OS/architecture targeting. Some package installation commands are optimized for quieter/minimal installs.
packages/system/bucket/values.yaml Default value of bucketName changed from empty string to "cozystack".
packages/system/bucket/Makefile update target simplified to a no-op echo statement.
packages/system/dashboard/Makefile update-dockerfiles target now displays a manual update reminder instead of fetching tags automatically.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Makefile
    participant Docker Buildx
    participant Dockerfile

    User->>Makefile: make image (with BUILDER, PLATFORM)
    Makefile->>Docker Buildx: buildx build --builder=$(BUILDER) --platform=$(PLATFORM)
    Docker Buildx->>Dockerfile: Passes TARGETOS, TARGETARCH as build args
    Dockerfile->>Dockerfile: Use TARGETOS, TARGETARCH in build/install steps
    Dockerfile->>Docker Buildx: Outputs multi-arch image
    Docker Buildx->>Makefile: Build complete
    Makefile->>User: Build result (multi-arch image)
Loading

Possibly related PRs

Suggested labels

ok-to-test

Poem

In the warren where Docker bunnies dwell,
We swapped hardcoded flags—oh, what a tale to tell!
Now builds hop nimbly from arch to arch,
Guided by variables, onward they march.
🐇 With TARGETOS and TARGETARCH in our paws,
We build for every burrow—applause, applause!

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 15d7b6d and d550a67.

📒 Files selected for processing (1)
  • packages/system/kamaji/images/kamaji/Dockerfile (3 hunks)

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@nbykov0 Nikita (nbykov0) linked an issue May 10, 2025 that may be closed by this pull request
Signed-off-by: nbykov0 <166552198+nbykov0@users.noreply.github.com>
Signed-off-by: nbykov0 <166552198+nbykov0@users.noreply.github.com>
Signed-off-by: nbykov0 <166552198+nbykov0@users.noreply.github.com>
Signed-off-by: nbykov0 <166552198+nbykov0@users.noreply.github.com>
Signed-off-by: nbykov0 <166552198+nbykov0@users.noreply.github.com>
Signed-off-by: nbykov0 <166552198+nbykov0@users.noreply.github.com>
Signed-off-by: nbykov0 <166552198+nbykov0@users.noreply.github.com>
Signed-off-by: nbykov0 <166552198+nbykov0@users.noreply.github.com>
Signed-off-by: nbykov0 <166552198+nbykov0@users.noreply.github.com>
Signed-off-by: nbykov0 <166552198+nbykov0@users.noreply.github.com>
Signed-off-by: nbykov0 <166552198+nbykov0@users.noreply.github.com>
Signed-off-by: nbykov0 <166552198+nbykov0@users.noreply.github.com>
Signed-off-by: nbykov0 <166552198+nbykov0@users.noreply.github.com>
Signed-off-by: nbykov0 <166552198+nbykov0@users.noreply.github.com>
Signed-off-by: nbykov0 <166552198+nbykov0@users.noreply.github.com>
Signed-off-by: nbykov0 <166552198+nbykov0@users.noreply.github.com>
Signed-off-by: nbykov0 <166552198+nbykov0@users.noreply.github.com>
Signed-off-by: nbykov0 <166552198+nbykov0@users.noreply.github.com>
Signed-off-by: nbykov0 <166552198+nbykov0@users.noreply.github.com>
@nbykov0
Nikita (nbykov0) force-pushed the 519-cross-arch-components branch from 382a0f8 to 4a2c67e Compare May 11, 2025 23:50
@nbykov0

Nikita (nbykov0) commented May 11, 2025

Copy link
Copy Markdown
Collaborator Author

All modified Dockerfiles were successfully built on amd64 and arm64.
I haven't done any functional testing, however.

Signed-off-by: nbykov0 <166552198+nbykov0@users.noreply.github.com>
Signed-off-by: nbykov0 <166552198+nbykov0@users.noreply.github.com>
@nbykov0
Nikita (nbykov0) marked this pull request as ready for review May 14, 2025 16:34
@nbykov0
Nikita (nbykov0) requested a review from klinch0 as a code owner May 14, 2025 16:34

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 10

♻️ Duplicate comments (3)
packages/apps/kubernetes/Makefile (3)

35-38: Build context ordering issue repeated. See the comment on lines 17-20 for the correct placement of the build context.


52-55: Build context ordering issue repeated. See the comment on lines 17-20 for the correct placement of the build context.


70-73: Build context ordering issue repeated. See the comment on lines 17-20 for the correct placement of the build context.

🧹 Nitpick comments (25)
packages/system/dashboard/Makefile (1)

20-21: Switched off automatic Dockerfile updates—consider enforcing manual update
Printing a reminder (@echo Update dockerfiles manually) is helpful, but the target still succeeds even if Dockerfiles are stale. Consider failing the update-dockerfiles target (e.g., exit 1) or adding precise instructions to prevent drift.

packages/system/dashboard/images/kubeapps-apis/Dockerfile (2)

6-6: Introduce a dedicated 'source' stage—pin Alpine for reproducibility
Pulling from the generic alpine image can introduce breakages over time.
Consider specifying a fixed version (e.g., alpine:3.18) to ensure consistent downloads and caching.


74-74: Cross‐compile plugin builds—consider DRY refactor
The GOOS/GOARCH flags repeat across each plugin build block. You could DRY this by defining a GOENV="GOOS=$TARGETOS GOARCH=$TARGETARCH GOPROXY=..." variable and reusing it:

ARG GOENV="GOOS=$TARGETOS GOARCH=$TARGETARCH GOPROXY=... "
RUN --mount=... $GOENV go build ...

Also applies to: 83-83, 93-93

packages/core/testing/images/e2e-sandbox/Dockerfile (3)

10-11: Combine apt update and apt install into one layer
Merging these into a single RUN reduces image layers and ensures package lists stay in sync:

RUN apt update -q && apt install -yq --no-install-recommends ... && rm -rf /var/lib/apt/lists/*

18-18: Dynamic yq download—good approach
Fetching yq_${TARGETOS}_${TARGETARCH} ensures the correct binary.
Consider adding checksum validation as well.


19-19: Pin FluxCD installer version for reproducibility
Curling the latest install script always fetches the bleeding edge.
Pin to a specific FluxCD release or include a version argument to avoid unpredictable changes.

packages/system/kubeovn-webhook/Makefile (1)

10-11: Ensure BUILDER and PLATFORM variables are defined and documented

Introducing --builder=$(BUILDER) and --platform=$(PLATFORM) flags assumes these variables are set (e.g., via CI environment or common-envs.mk). Please verify that:

  1. $(BUILDER) and $(PLATFORM) have sensible defaults or error clearly if undefined.
  2. The required values and examples are documented in scripts/common-envs.mk or the repository’s contributing guidelines.
packages/system/kamaji/Makefile (1)

17-18: Verify cross-architecture variables in build target

The added --builder=$(BUILDER) and --platform=$(PLATFORM) flags enable multi-arch builds. Ensure that:

  • BUILDER and PLATFORM are exported or defaulted in common-envs.mk.
  • Downstream CI or make invocations supply these variables correctly.

Optionally, add a fallback in the Makefile for local development, e.g.:

BUILDER?=default
PLATFORM?=linux/amd64
packages/apps/kubernetes/images/kubevirt-csi-driver/Dockerfile (1)

8-11: Approve cross-compilation build args; consider static linking

Good use of BuildKit’s automatic TARGETOS and TARGETARCH args to parameterize GOOS/GOARCH for multi-arch builds. As an enhancement, consider disabling cgo to produce statically linked binaries by adding:

ENV CGO_ENABLED=0

before RUN make build.

packages/system/kubeovn-webhook/images/kubeovn-webhook/Dockerfile (1)

3-4: Consider specifying default values for TARGETOS and TARGETARCH.

Without defaults, a plain docker build (without --build-arg) may produce empty GOOS/GOARCH, leading to unpredictable builds. You can set defaults for backward compatibility, e.g.:

ARG TARGETOS=linux
ARG TARGETARCH=amd64
packages/system/kamaji/images/kamaji/Dockerfile (1)

5-6: Add default values for architecture build arguments.

To ensure builds still work without explicit --build-arg, consider:

ARG TARGETOS=linux
ARG TARGETARCH=amd64
packages/system/bucket/images/s3manager/Dockerfile (1)

5-6: Introduce TARGETOS and TARGETARCH build args.

Running go build with GOOS/GOARCH now enables cross-compilation. Consider setting defaults (linux/amd64) to preserve behavior when args are omitted.

packages/system/cozystack-controller/images/cozystack-controller/Dockerfile (1)

3-4: Default values for build arguments.

For environments that omit build-args, add:

ARG TARGETOS=linux
ARG TARGETARCH=amd64
packages/system/bucket/Makefile (1)

16-17: Ensure default values for BUILDER and PLATFORM.

If these variables are not set externally, the build will fail. Consider adding at the top of the Makefile:

BUILDER ?= default
PLATFORM ?= linux/amd64
packages/apps/kubernetes/images/kubevirt-cloud-provider/Dockerfile (2)

4-7: Add default values for build arguments. To improve local development and maintain backward compatibility when arguments are omitted, consider specifying defaults:

ARG TARGETOS=linux
ARG TARGETARCH=amd64

This ensures the build still succeeds in environments where these args aren’t explicitly passed.


22-22: Cross-compilation build flags look solid. Using CGO_ENABLED=0 with dynamic GOOS/GOARCH enables static, multi-arch binaries. For enhanced reproducibility, you might also include -trimpath in the -ldflags.

packages/system/cozystack-api/images/cozystack-api/Dockerfile (2)

3-4: Consider defaulting build args. Adding defaults like:

ARG TARGETOS=linux
ARG TARGETARCH=amd64

can help local builds and avoid failures if args are omitted.


16-16: Static build flags are appropriate. Using -extldflags=-static along with CGO_ENABLED=0 produces a static binary. For reproducibility, consider adding -trimpath to the -ldflags.

packages/apps/kubernetes/Makefile (1)

14-15: Consolidate repeated flags. The build commands for each image repeat identical flags (--provenance, --builder, --platform, cache and metadata options). Extract these into a variable (e.g., DOCKER_BUILD_OPTS) to DRY up the Makefile:

DOCKER_BUILD_OPTS := --provenance false --builder=$(BUILDER) --platform=$(PLATFORM) \
                     --cache-from type=registry,ref=$(REGISTRY)/$(IMAGE):latest \
                     --cache-to type=inline --metadata-file $(IMAGE).json \
                     --push=$(PUSH) --label "org.opencontainers.image.source=…" \
                     --load=$(LOAD)

Then reference $(DOCKER_BUILD_OPTS) in each target.

packages/apps/http-cache/images/nginx-cache/Dockerfile (2)

12-13: Introduce build args for cross-arch support. TARGETOS and TARGETARCH are now available. Consider defaulting them (linux/amd64) for improved local builds:

ARG TARGETOS=linux
ARG TARGETARCH=amd64

16-18: Optimize package installation. Switching to apt with --no-install-recommends reduces image size. For consistency, add --no-install-suggests here and ensure removal of /var/lib/apt/lists/* in this stage to slim the builder image.

packages/apps/kubernetes/images/cluster-autoscaler/Dockerfile (1)

7-10: Provide sensible defaults for build arguments.
ARG TARGETOS and ARG TARGETARCH currently have no default values. Omitting these at build time will result in empty GOOS/GOARCH, causing cross-compilation to fail. Consider adding defaults, for example:

- ARG TARGETOS
- ARG TARGETARCH
+ ARG TARGETOS=linux
+ ARG TARGETARCH=amd64
packages/apps/kubernetes/images/ubuntu-container-disk/Dockerfile (3)

11-11: Review necessity of bash-completion package.
Adding bash-completion increases image size and may not be required in a non-interactive build. If it's only for debugging, consider moving it to a dev-only stage or removing it altogether.


17-18: Consider providing defaults for TARGETOS and TARGETARCH.
Without defaults (for example, ARG TARGETOS=linux and ARG TARGETARCH=amd64), omitting these flags will break the build. Adding defaults guards against missing build-args.


40-41: Combine update and install into one transaction.
Merging apt-get update -q and apt-get install -yq containerd.io into a single command can reduce image layers and improve cache efficiency:

- && guestfish --remote command "apt-get update -q" \
- && guestfish --remote command "apt-get install -yq containerd.io" \
+ && guestfish --remote sh "apt-get update -q && apt-get install -yq containerd.io" \
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 557ffa5 and 15d7b6d.

📒 Files selected for processing (27)
  • packages/apps/clickhouse/Makefile (1 hunks)
  • packages/apps/http-cache/Makefile (1 hunks)
  • packages/apps/http-cache/images/nginx-cache/Dockerfile (6 hunks)
  • packages/apps/kubernetes/Makefile (4 hunks)
  • packages/apps/kubernetes/images/cluster-autoscaler/Dockerfile (2 hunks)
  • packages/apps/kubernetes/images/kubevirt-cloud-provider/Dockerfile (2 hunks)
  • packages/apps/kubernetes/images/kubevirt-csi-driver/Dockerfile (1 hunks)
  • packages/apps/kubernetes/images/ubuntu-container-disk/Dockerfile (3 hunks)
  • packages/apps/mysql/Makefile (1 hunks)
  • packages/apps/postgres/Makefile (1 hunks)
  • packages/core/testing/Makefile (1 hunks)
  • packages/core/testing/images/e2e-sandbox/Dockerfile (1 hunks)
  • packages/extra/monitoring/Makefile (1 hunks)
  • packages/system/bucket/Makefile (1 hunks)
  • packages/system/bucket/images/s3manager/Dockerfile (1 hunks)
  • packages/system/bucket/values.yaml (1 hunks)
  • packages/system/cilium/Makefile (1 hunks)
  • packages/system/cozystack-api/Makefile (1 hunks)
  • packages/system/cozystack-api/images/cozystack-api/Dockerfile (1 hunks)
  • packages/system/cozystack-controller/images/cozystack-controller/Dockerfile (1 hunks)
  • packages/system/dashboard/Makefile (3 hunks)
  • packages/system/dashboard/images/kubeapps-apis/Dockerfile (7 hunks)
  • packages/system/kamaji/Makefile (1 hunks)
  • packages/system/kamaji/images/kamaji/Dockerfile (2 hunks)
  • packages/system/kubeovn-webhook/Makefile (1 hunks)
  • packages/system/kubeovn-webhook/images/kubeovn-webhook/Dockerfile (1 hunks)
  • packages/system/kubeovn/Makefile (1 hunks)
🧰 Additional context used
🪛 Hadolint (2.12.0)
packages/system/bucket/images/s3manager/Dockerfile

[error] 10-10: Use COPY instead of ADD for files and folders

(DL3020)

🔇 Additional comments (39)
packages/system/kubeovn/Makefile (1)

22-23: Approve dynamic builder and platform usage
The flags --builder=$(BUILDER) and --platform=$(PLATFORM) correctly replace hardcoded values and align with the repository's multi-arch build approach.

packages/core/testing/Makefile (1)

20-21: Approve multi-arch build enhancements
The new --builder=$(BUILDER) and --platform=$(PLATFORM) flags enable flexible, cross-architecture builds for the end-to-end sandbox image.

packages/extra/monitoring/Makefile (1)

18-19: Approve parameterized build flags
Replacing the fixed platform with --builder=$(BUILDER) and --platform=$(PLATFORM) is consistent and improves build flexibility across architectures.

packages/apps/postgres/Makefile (1)

12-13: Approve dynamic multi-arch flags
Using --builder=$(BUILDER) and --platform=$(PLATFORM) instead of hardcoded values aligns with the cross-architecture build strategy and ensures consistency.

packages/apps/mysql/Makefile (1)

10-13: Parameterize Docker build for multi-architecture—good improvement
Replacing hardcoded --platform linux/amd64 and --build-arg ARCH=amd64 with --builder=$(BUILDER) and --platform=$(PLATFORM) makes the build flexible across architectures.
Ensure that $(BUILDER) and $(PLATFORM) are documented and have sensible defaults (e.g., in common-envs.mk) to avoid build failures when not set.

packages/apps/clickhouse/Makefile (1)

10-13: Parameterize Docker build for multi-architecture—good improvement
As with other packages, removing hardcoded flags in favor of $(BUILDER) and $(PLATFORM) enables cross-arch builds.
Please verify that these variables are defined by default or documented in common-envs.mk to prevent undefined-variable errors.

packages/system/dashboard/Makefile (2)

32-33: Parameterize dashboard build for multi-arch—solid enhancement
Adding --builder=$(BUILDER) and --platform=$(PLATFORM) aligns this target with others.
Confirm that common-envs.mk or CI injects these variables consistently.


54-55: Parameterize kubeapps-apis build for multi-arch—solid enhancement
Using $(BUILDER) and $(PLATFORM) here too standardizes the process.
Ensure that downstream CI/Makefiles pass valid values or default fallbacks.

packages/system/dashboard/images/kubeapps-apis/Dockerfile (3)

33-33: Cross‐compile lint installation—good use of GOOS/GOARCH
Applying GOOS=$TARGETOS GOARCH=$TARGETARCH to the golangci-lint install is correct.
Ensure TARGETOS/TARGETARCH are validated upstream.


47-47: Cross‐compile go mod download—looks correct
Using GOOS/GOARCH here ensures module caching is arch‐aware.
All good, assuming defaults are set.


65-65: Cross‐compile main server build—approved
Embedding GOOS and GOARCH into the build command aligns with the multi-arch goal.

packages/core/testing/images/e2e-sandbox/Dockerfile (1)

17-17: Helm installer script—verify multi-arch support
The official Helm install script infers OS/ARCH; please confirm it selects the correct $TARGETOS/$TARGETARCH or pin a versioned binary for deterministic builds.

packages/system/bucket/values.yaml (1)

1-1: Validate default bucketName change for backward compatibility

Setting the default bucketName to "cozystack" will apply a non-empty name in environments that rely on the Helm chart’s defaults. Confirm that this won’t break existing deployments that assume an empty default (or document the new required override). Consider allowing an environment variable override or documenting the change in the chart’s README.md.

packages/system/cozystack-api/Makefile (1)

12-13: Align builder/platform flags in image-cozystack-api target

The replacement of hardcoded platform with --builder=$(BUILDER) and --platform=$(PLATFORM) is consistent with other packages. Please confirm that:

  • Environment variables BUILDER and PLATFORM are centrally defined.
  • There is documentation or an example invocation to illustrate their expected values.
packages/system/kubeovn-webhook/images/kubeovn-webhook/Dockerfile (2)

8-8: Good cache layer for module dependencies.

The separate go mod download step, scoped by GOOS/GOARCH, efficiently caches dependencies across architectures. Looks solid.


11-11: Cross-compilation build command is correct.

Explicitly setting CGO_ENABLED=0 alongside GOOS/GOARCH ensures a static binary compatible with the target platform. Nice.

packages/system/kamaji/images/kamaji/Dockerfile (2)

2-2: Standardize AS keyword casing.

The change from lowercase to uppercase AS follows Dockerfile best practices and improves readability. Good catch.


15-15: Build step correctly uses cross-compile flags.

The RUN GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 go build invocation is aligned with other Dockerfiles and supports multi-arch output. Nice.

packages/system/bucket/images/s3manager/Dockerfile (1)

12-12: Cross-compilation flags applied correctly.

Using CGO_ENABLED=0 and static linking flags is consistent with other components and ensures portable binaries.

packages/system/cozystack-controller/images/cozystack-controller/Dockerfile (3)

1-1: Align builder stage with Go Alpine variant.

Switching to golang:1.23-alpine reduces image size while retaining the Go toolchain. Approved.


9-9: Dependency download step is well-placed.

Using GOOS/GOARCH during go mod download pre-populates the module cache for the correct target. Approved.


16-16: Static build flags are correct.

The -extldflags=-static option plus CGO_ENABLED=0 ensures a fully static binary. Looks good.

packages/system/bucket/Makefile (2)

9-9: No-op update target is intentional.

Replacing the old chart update commands with a no-op avoids unnecessary operations. Approved.


14-14: Parameterized build command.

Switching to buildx build with --builder and --platform options aligns with multi-arch requirements. Good.

packages/apps/kubernetes/images/kubevirt-cloud-provider/Dockerfile (1)

2-2: Ensure consistent builder stage aliasing. The AS builder keyword is correctly capitalized, aligning with other Dockerfiles.

packages/system/cozystack-api/images/cozystack-api/Dockerfile (2)

1-1: Builder stage declaration is correct. The AS builder alias is well‐placed on the Alpine base for a lean build.


9-9: Cross-platform module download. Prefixing go mod download with dynamic GOOS/GOARCH is valid; just confirm it doesn’t inadvertently affect other tool invocations in subsequent steps.

packages/apps/http-cache/images/nginx-cache/Dockerfile (5)

1-1: Multi-stage build alias is correct. Using AS stage on Ubuntu base aligns with the repository’s pattern for builder stages.


75-75: Dynamic package architecture for IP2Location. Replacing hardcoded amd64 with ${TARGETARCH} in checkinstall ensures correct package naming per architecture.


104-104: Dynamic package architecture for IP2Proxy. --pkgarch=${TARGETARCH} is correctly applied for the second library.


151-151: Dynamic package architecture for Nginx. ${TARGETARCH} ensures the Nginx package matches the target architecture.


172-173: Minimal final stage dependencies. The final stage uses apt with both --no-install-recommends and --no-install-suggests and cleans up apt lists—best practice for minimal images.

packages/apps/kubernetes/images/cluster-autoscaler/Dockerfile (1)

24-27: Confirm final-stage ARG and copy semantics.
You’ve reintroduced ARG TARGETARCH in the final stage so COPY --from=builder .../cluster-autoscaler-${TARGETARCH} works correctly. Verify this matches your build output naming, and note that TARGETOS isn’t used here—if future multi-OS builds are desired, you may need a corresponding ARG TARGETOS and adjust the binary naming accordingly.

packages/apps/kubernetes/images/ubuntu-container-disk/Dockerfile (6)

2-2: Specify explicit image version for reproducibility.
Pinning to ubuntu:22.04 is valid given guestfish compatibility, but please document this choice (e.g., in a README or central build guide) so future maintainers understand the rationale.


15-15: Approve multi-stage build introduction.
Splitting into a guestfish stage and a builder stage improves isolation and keeps the final image minimal—this follows Docker best practices.


21-21: Verify dynamic image URL works across architectures.
Switching to noble-server-cloudimg-${TARGETARCH}.img relies on the Ubuntu cloud-images endpoint supporting each ${TARGETARCH}. Please confirm and handle download failures gracefully.


34-34: Remove arch= filter in Docker apt source.
Dropping arch=amd64 correctly enables multi-arch package retrieval from the Docker repository.


38-38: Validate apt repository integrity before installs.
Running apt-get check -q after adding new sources is an excellent sanity check for package-index consistency.


46-46: Ensure containerd configuration is valid.
containerd config dump >/dev/null is an effective smoke test to verify the generated /etc/containerd/config.toml is syntactically correct.

Comment thread packages/system/cilium/Makefile
Comment thread packages/system/dashboard/images/kubeapps-apis/Dockerfile
Comment thread packages/system/dashboard/images/kubeapps-apis/Dockerfile
Comment thread packages/core/testing/images/e2e-sandbox/Dockerfile
Comment thread packages/core/testing/images/e2e-sandbox/Dockerfile
Comment thread packages/core/testing/images/e2e-sandbox/Dockerfile
Comment thread packages/apps/http-cache/Makefile
Comment thread packages/apps/kubernetes/Makefile
Comment thread packages/apps/kubernetes/images/cluster-autoscaler/Dockerfile
Comment thread packages/apps/kubernetes/images/ubuntu-container-disk/Dockerfile
@nbykov0 Nikita (nbykov0) linked an issue May 14, 2025 that may be closed by this pull request
Comment thread packages/apps/http-cache/images/nginx-cache/Dockerfile
Comment thread packages/apps/kubernetes/Makefile
@NickVolynkin

Copy link
Copy Markdown
Contributor

Nikita (@nbykov0) I see no changes in CI. Will it still work with these changes?

@nbykov0

Copy link
Copy Markdown
Collaborator Author

Nikita (@nbykov0) I see no changes in CI. Will it still work with these changes?

Yes, as #907 is merged. By default everything will be built only for the platform supported by a builder (amd64).
When a builder with arm64 will be added, stuff will get built for both architectures.

@NickVolynkin Nick Volynkin (NickVolynkin) changed the title [519] Cross-arch builds: components [build] Cross-arch builds: components May 15, 2025
@kvaps
Andrei Kvapil (kvaps) merged commit 4f78b13 into main May 17, 2025
@kvaps
Andrei Kvapil (kvaps) deleted the 519-cross-arch-components branch May 17, 2025 10:17
Timofei Larkin (lllamnyp) pushed a commit that referenced this pull request May 20, 2025
Components with existing dockerfiles will be updated in this PR.

Part of #519

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Added support for multi-architecture and cross-platform Docker image
builds across various components, enabling builds for different
operating systems and CPU architectures.

- **Chores**
- Updated Docker build commands in multiple Makefiles to use
configurable builder and platform variables, improving build
flexibility.
- Standardized Dockerfile build arguments and environment variables for
cross-compilation.
- Improved package installation commands for quieter and more minimal
installs in Dockerfiles.
- Changed the default bucket name configuration to "cozystack" in system
bucket settings.
- Updated some maintenance targets and manual update reminders in
Makefiles.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

(cherry picked from commit 4f78b13)
Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
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.

Cross arch build for images

4 participants