Compiling & Hosting The OCI Image¶
Overview¶
This section explains how to:
- Cross-compile applications (using
muslfor staticlibcbindings) - Build OCI images
- Publish to container registries
Cross Compilation¶
Example Targets¶
| Architecture | Target Triple (using musl) |
Cross-Compiler | Env Variable |
|---|---|---|---|
arm64 |
aarch64-unknown-linux-musl |
sudo apt-get install -y gcc-aarch64-linux-gnu |
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=aarch64-linux-gnu-gcc |
armv7 |
armv7-unknown-linux-musleabihf |
sudo apt-get install -y gcc-arm-linux-gnueabihf |
export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_MUSLEABIHF_LINKER=arm-linux-gnueabihf-gcc |
amd64 |
x86_64-unknown-linux-musl |
sudo apt-get install -y musl-tools |
export CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc |
Rust Build Example¶
This uses the target triple for the target arch:
CI/CD Workflow (GitHub Actions)¶
Key Stages¶
flowchart TD;
A["1. Checkout code"] --> B["2. Install dependencies"];
B --> C["3. Build application"];
C --> D["4. Run tests"];
D --> E["5. Build OCI image"];
E --> F["6. Push to registry"];
Build & Push Example¶
Using Buildx for Multi-Arch¶
Registry: GitHub Container Registry (GHCR)¶
Login¶
Push Image¶
Tagging Strategy¶
| Tag | Purpose |
|---|---|
latest |
Most recent stable |
1.2.3 |
Release version |
arm64 |
Architecture |
arm64-1.2.3 |
Arch + version |
Automation Options¶
| Option | Pros |
|---|---|
| GitHub Actions (Recommended) | - Native integration - Easy secrets management |
| Jenkins | - More customizable pipelines |
| Python Scripts | - Lightweight automation - Useful for local builds |
Image Labels in CI¶
--label "org.opencontainers.image.version=${APP_VERSION}"
--label "org.opencontainers.image.revision=${SHORT_SHA}"
Key Takeaways¶
- Cross-compilation is essential for RDK targets
- Automate everything via CI/CD
- Use semantic version tags
- Always push versioned + latest images