Skip to content

Conversation

@lexfrei
Copy link
Contributor

@lexfrei lexfrei commented Feb 2, 2026

Note

Merge after #13

Summary

Enable ARM64 cross-compilation support by respecting TARGETARCH environment variable in the install script.

Problem

When building Docker images with docker buildx for a different architecture (e.g., building linux/arm64 on an amd64 host), uname -m returns the build host architecture, not the target architecture.

This causes the install script to download the wrong binary during cross-compilation.

Solution

Check for TARGETARCH (automatically set by Docker buildx) or ARCH environment variables before falling back to uname -m:

if [ -n "$TARGETARCH" ]; then
  ARCH="$TARGETARCH"
elif [ -n "$ARCH" ]; then
  :
else
  ARCH=$(uname -m)
fi

Usage

Works automatically with Docker buildx:

ARG TARGETARCH
RUN wget -O- https://github.com/cozystack/cozyhr/raw/refs/heads/main/hack/install.sh | sh

Or manually:

TARGETARCH=arm64 ./install.sh -v 1.6.1

Related

The install script now checks for TARGETARCH (set by Docker buildx)
or ARCH environment variables before falling back to `uname -m`.

This fixes cross-compilation scenarios where `uname -m` returns the
build host architecture instead of the target architecture, causing
the wrong binary to be downloaded.

Example usage in Dockerfile:
```dockerfile
ARG TARGETARCH
RUN wget -O- .../install.sh | sh
```

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Aleksei Sviridkin <f@lex.la>
@coderabbitai
Copy link

coderabbitai bot commented Feb 2, 2026

📝 Walkthrough

Walkthrough

The installation script's architecture detection mechanism was enhanced to support a layered environment variable override pattern (TARGETARCHARCH → system default), with corresponding documentation added to the usage output.

Changes

Cohort / File(s) Summary
Environment Variable Override Pattern
hack/install.sh
Added TARGETARCH environment variable support with layered fallback logic; updated usage documentation to reference TARGETARCH and ARCH environment variables for architecture configuration.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A script that once asked the system with care,
Now listens to whispers from variables in air,
TARGETARCH first, then ARCH takes its place,
Before asking the machine about its face!
More flexible installation, we declare! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(install): Respect TARGETARCH env var for cross-compilation' directly and concisely summarizes the main change: modifying the install script to respect and prioritize the TARGETARCH environment variable for cross-compilation support.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @lexfrei, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the install.sh script to correctly identify the target architecture during cross-compilation scenarios, particularly when using tools like Docker buildx. By prioritizing TARGETARCH and ARCH environment variables, the script ensures that the appropriate binaries are downloaded for the intended platform, resolving issues where uname -m would incorrectly report the build host's architecture.

Highlights

  • Cross-compilation support: The install.sh script now correctly identifies the target architecture during cross-compilation, particularly for Docker buildx workflows, by respecting TARGETARCH and ARCH environment variables.
  • Architecture detection logic: The script's architecture detection has been updated to prioritize TARGETARCH, then ARCH, before falling back to the output of uname -m.
  • Documentation update: The help message for install.sh has been extended to document the new TARGETARCH and ARCH environment variables and their purpose.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request enhances the install.sh script to support cross-compilation for different architectures, which is particularly useful for docker buildx. The changes correctly prioritize TARGETARCH and ARCH environment variables over uname -m for architecture detection. The documentation in the script's help message has also been updated accordingly. I've provided one suggestion to simplify the architecture detection logic using a more concise and idiomatic shell scripting pattern. The overall implementation is sound and effectively addresses the problem.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Aleksei Sviridkin <3811295@gmail.com>
@lexfrei lexfrei self-assigned this Feb 6, 2026
@kvaps kvaps merged commit ac094b6 into cozystack:main Feb 9, 2026
2 of 3 checks passed
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