Update documentation for Rust workspace approach

- Update README.md to reflect git subtree + workspace architecture
- Document unified build process with 'cargo build --workspace'
- Add component update instructions using git subtree pull
- Remove references to git submodules and setup-submodules.sh
- Update development workflow with workspace commands
- Document new directory structure with Cargo.toml at root
This commit is contained in:
2025-08-16 21:20:26 +02:00
parent eca0cca470
commit 446eb02fb3

View File

@@ -6,8 +6,8 @@ Modern Alpine Linux based approach to building Zero-OS initramfs with source com
This system uses:
- **Alpine Linux 3.22** as base system with latest packages
- **Git submodules** for Zero-OS components (zinit, mycelium, rfs, corex)
- **Source compilation** for Zero-OS components (Rust/Go with musl static linking)
- **Rust workspace** with git subtrees for Zero-OS Rust components (zinit, mycelium, rfs)
- **Unified compilation** via `cargo build --workspace` for all Rust components
- **Alpine packages** for system tools (busybox, openssh, btrfs-progs, etc.)
- **Smart caching** with Docker layers and volumes
- **Same init flow** as original Zero-OS
@@ -16,15 +16,15 @@ This system uses:
```
alpine-initramfs/
├── Cargo.toml # Rust workspace configuration
├── build/ # Build orchestration
│ ├── Dockerfile.alpine # Alpine build environment
│ ├── Dockerfile.cached # Multi-stage cached build
│ └── docker-compose.yml # Build orchestration with caching
├── components/ # Git submodules
│ ├── zinit/ # Init system (Rust)
│ ├── mycelium/ # Networking layer (Rust)
── rfs/ # Filesystem (Rust)
│ └── corex/ # Container control (static binary)
├── components/ # Git subtrees (Rust workspace members)
│ ├── zinit/ # Init system (Rust subtree)
│ ├── mycelium/ # Networking layer (Rust subtree)
── rfs/ # Filesystem (Rust subtree)
├── configs/ # Configuration files
│ ├── packages-alpine.txt # Alpine packages to install
│ ├── kernel-version # Kernel version to build
@@ -33,14 +33,15 @@ alpine-initramfs/
│ └── zinit/ # Zinit service configurations
├── scripts/ # Build scripts
│ ├── build-initramfs.sh # Main build orchestrator
│ ├── compile-components.sh # Compile Zero-OS components from source
│ ├── compile-components.sh # Compile Rust workspace
│ ├── fetch-github.sh # Download CoreX binary
│ ├── install-packages.sh # Install Alpine packages
│ ├── setup-initramfs.sh # Create initramfs structure
│ ├── build-kernel.sh # Build kernel with embedded initramfs
│ ├── build-smart.sh # Smart build with caching
│ ├── setup-submodules.sh # Initialize git submodules
│ └── cleanup.sh # Clean build artifacts
├── output/ # Build artifacts
├── target/ # Rust workspace build artifacts
├── output/ # Final build outputs
│ ├── vmlinuz.efi # Final bootable kernel
│ ├── initramfs.cpio.xz # Generated initramfs
│ └── version.txt # Build information
@@ -52,12 +53,13 @@ alpine-initramfs/
## Build Flow
1. **Environment Setup**: Alpine Docker container with Rust, Go, and build tools
2. **Component Compilation**: Build zinit, mycelium, rfs from source (musl static)
3. **Package Installation**: Install Alpine packages to initramfs root
4. **Initramfs Assembly**: Create filesystem structure with compiled binaries
5. **Kernel Build**: Compile kernel with embedded initramfs
6. **Output**: Generate bootable vmlinuz.efi
1. **Environment Setup**: Alpine Docker container with Rust and build tools
2. **Workspace Compilation**: Single `cargo build --workspace` for all Rust components
3. **Binary Downloads**: Download CoreX (Go binary) from GitHub releases
4. **Package Installation**: Install Alpine packages to initramfs root
5. **Initramfs Assembly**: Create filesystem structure with compiled binaries
6. **Kernel Build**: Compile kernel with embedded initramfs
7. **Output**: Generate bootable vmlinuz.efi
## Quick Start
@@ -77,9 +79,13 @@ cd build/
# Interactive development shell
docker-compose run dev-shell
# Build specific component (e.g., mycelium)
cd /build/components/mycelium/myceliumd
cargo build --release --target x86_64-unknown-linux-musl
# Build entire workspace
cargo build --workspace --release --target x86_64-unknown-linux-musl
# Build specific component
cargo build -p zinit --release --target x86_64-unknown-linux-musl
cargo build -p mycelium --release --target x86_64-unknown-linux-musl
cargo build -p rfs --release --target x86_64-unknown-linux-musl
```
### Smart Build (with caching)
@@ -90,13 +96,14 @@ docker-compose run builder # Uses build-smart.sh automatically
## Key Features
-**Source compilation** - Latest Zero-OS components with static linking
-**Rust workspace** - Unified build system for all Rust components
-**Git subtrees** - Source code included, no submodule complexity
-**Single build command** - `cargo build --workspace` builds everything
-**Shared dependencies** - Consistent versions across all components
-**Smart caching** - Docker layer and volume caching for fast rebuilds
-**Alpine packages** - System tools from Alpine repositories
-**Multi-stage builds** - Efficient Docker builds with minimal layers
-**Development mode** - Interactive shell for component development
-**Development mode** - Full IDE support and integrated tooling
-**Same functionality** - 100% compatible with original Zero-OS
-**Modern toolchain** - Rust 1.x, Go latest, Alpine 3.22
## Development
@@ -105,10 +112,13 @@ docker-compose run builder # Uses build-smart.sh automatically
cd build/
docker-compose run dev-shell
# Inside container:
cd /build/components/mycelium/myceliumd && cargo build --release --target x86_64-unknown-linux-musl
cd /build/components/zinit && cargo build --release --target x86_64-unknown-linux-musl
cd /build/components/rfs && cargo build --release --target x86_64-unknown-linux-musl
# Inside container - workspace build:
cargo build --workspace --release --target x86_64-unknown-linux-musl
# Or build specific packages:
cargo build -p zinit --release --target x86_64-unknown-linux-musl
cargo build -p mycelium --release --target x86_64-unknown-linux-musl
cargo build -p rfs --release --target x86_64-unknown-linux-musl
```
### Cleanup
@@ -122,4 +132,17 @@ Smart build uses Docker volumes for caching:
- `build-cache`: Build state markers
- `source-cache`: Downloaded sources
- `kernel-cache`: Kernel builds
- `target-cache`: Rust build artifacts
- `target-cache`: Rust workspace build artifacts
### Updating Components
Update git subtree components:
```bash
# Update zinit to latest
git subtree pull --prefix=components/zinit https://github.com/threefoldtech/zinit.git master --squash
# Update mycelium to latest
git subtree pull --prefix=components/mycelium https://github.com/threefoldtech/mycelium.git master --squash
# Update rfs to latest
git subtree pull --prefix=components/rfs https://github.com/threefoldtech/rfs.git master --squash
```