mirror of
https://github.com/johndoe6345789/SparkOS.git
synced 2026-04-24 13:34:56 +00:00
Add Docker-based release tooling for easier releases
Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
This commit is contained in:
19
Makefile
19
Makefile
@@ -7,7 +7,7 @@ DESTDIR = rootfs
|
|||||||
IMAGE = sparkos.img
|
IMAGE = sparkos.img
|
||||||
IMAGE_SIZE = 512M
|
IMAGE_SIZE = 512M
|
||||||
|
|
||||||
.PHONY: all clean init image help install
|
.PHONY: all clean init image help install docker-release
|
||||||
|
|
||||||
all: init
|
all: init
|
||||||
|
|
||||||
@@ -15,13 +15,17 @@ help:
|
|||||||
@echo "SparkOS Build System"
|
@echo "SparkOS Build System"
|
||||||
@echo "===================="
|
@echo "===================="
|
||||||
@echo "Targets:"
|
@echo "Targets:"
|
||||||
@echo " make init - Build the init system"
|
@echo " make init - Build the init system"
|
||||||
@echo " make install - Install init to rootfs"
|
@echo " make install - Install init to rootfs"
|
||||||
@echo " make image - Create bootable dd-able image (requires root)"
|
@echo " make image - Create bootable dd-able image (requires root)"
|
||||||
@echo " make clean - Clean build artifacts"
|
@echo " make docker-release - Build release package using Docker (no root required)"
|
||||||
|
@echo " make clean - Clean build artifacts"
|
||||||
@echo ""
|
@echo ""
|
||||||
@echo "Note: Creating a bootable image requires root privileges"
|
@echo "Note: Creating a bootable image requires root privileges"
|
||||||
@echo " and various tools (debootstrap, syslinux, etc.)"
|
@echo " and various tools (debootstrap, syslinux, etc.)"
|
||||||
|
@echo ""
|
||||||
|
@echo "For easier release building, use Docker:"
|
||||||
|
@echo " ./scripts/docker-release.sh v1.0.0"
|
||||||
|
|
||||||
init: src/init.c
|
init: src/init.c
|
||||||
@echo "Building SparkOS init system..."
|
@echo "Building SparkOS init system..."
|
||||||
@@ -42,9 +46,14 @@ image: install
|
|||||||
fi
|
fi
|
||||||
@./scripts/create_image.sh
|
@./scripts/create_image.sh
|
||||||
|
|
||||||
|
docker-release:
|
||||||
|
@echo "Building release package using Docker..."
|
||||||
|
@./scripts/docker-release.sh
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@echo "Cleaning build artifacts..."
|
@echo "Cleaning build artifacts..."
|
||||||
rm -f init
|
rm -f init
|
||||||
rm -f $(IMAGE)
|
rm -f $(IMAGE)
|
||||||
rm -rf build/
|
rm -rf build/
|
||||||
|
rm -rf release/
|
||||||
@echo "Clean complete"
|
@echo "Clean complete"
|
||||||
|
|||||||
60
README.md
60
README.md
@@ -84,6 +84,9 @@ docker run --rm ghcr.io/johndoe6345789/sparkos:latest
|
|||||||
docker build -t sparkos:local .
|
docker build -t sparkos:local .
|
||||||
docker run --rm sparkos:local
|
docker run --rm sparkos:local
|
||||||
|
|
||||||
|
# Or use Docker Compose for even simpler testing
|
||||||
|
docker-compose up
|
||||||
|
|
||||||
# Build for specific architecture
|
# Build for specific architecture
|
||||||
docker buildx build --platform linux/amd64 -t sparkos:amd64 --load .
|
docker buildx build --platform linux/amd64 -t sparkos:amd64 --load .
|
||||||
docker buildx build --platform linux/arm64 -t sparkos:arm64 --load .
|
docker buildx build --platform linux/arm64 -t sparkos:arm64 --load .
|
||||||
@@ -97,6 +100,18 @@ The Docker image includes:
|
|||||||
|
|
||||||
Images are automatically built and published to [GitHub Container Registry](https://github.com/johndoe6345789/SparkOS/pkgs/container/sparkos) on every push to main branch.
|
Images are automatically built and published to [GitHub Container Registry](https://github.com/johndoe6345789/SparkOS/pkgs/container/sparkos) on every push to main branch.
|
||||||
|
|
||||||
|
**Building Releases with Docker (No Root Required):**
|
||||||
|
|
||||||
|
Create release packages easily using Docker without needing root privileges or special tools:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Build a release package for version v1.0.0
|
||||||
|
./scripts/docker-release.sh v1.0.0
|
||||||
|
|
||||||
|
# The release ZIP will be created in release/sparkos-release.zip
|
||||||
|
# This is the same artifact that GitHub Actions creates
|
||||||
|
```
|
||||||
|
|
||||||
### Building the Init System
|
### Building the Init System
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -243,10 +258,55 @@ docker buildx build --platform linux/amd64,linux/arm64 -t sparkos:multiarch .
|
|||||||
# Test the image
|
# Test the image
|
||||||
docker run --rm sparkos:dev
|
docker run --rm sparkos:dev
|
||||||
|
|
||||||
|
# Or use Docker Compose
|
||||||
|
docker-compose up
|
||||||
|
|
||||||
# Inspect the init binary
|
# Inspect the init binary
|
||||||
docker run --rm sparkos:dev sh -c "ls -lh /sparkos/rootfs/sbin/init"
|
docker run --rm sparkos:dev sh -c "ls -lh /sparkos/rootfs/sbin/init"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Creating Releases
|
||||||
|
|
||||||
|
**Using Docker (Recommended - No Root Required):**
|
||||||
|
|
||||||
|
Build release packages locally using Docker without needing root privileges:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Build a release package
|
||||||
|
./scripts/docker-release.sh v1.0.0
|
||||||
|
|
||||||
|
# The release ZIP will be in release/sparkos-release.zip
|
||||||
|
# This is identical to what GitHub Actions creates
|
||||||
|
```
|
||||||
|
|
||||||
|
**Creating a GitHub Release:**
|
||||||
|
|
||||||
|
1. **Commit and push your changes** to the main branch
|
||||||
|
2. **Create and push a version tag:**
|
||||||
|
```bash
|
||||||
|
git tag v1.0.0
|
||||||
|
git push origin v1.0.0
|
||||||
|
```
|
||||||
|
3. **GitHub Actions will automatically:**
|
||||||
|
- Build the init binary
|
||||||
|
- Create the release package ZIP
|
||||||
|
- Build and publish Docker images (AMD64 + ARM64)
|
||||||
|
- Create a GitHub Release with the artifacts
|
||||||
|
- Publish to GitHub Container Registry
|
||||||
|
|
||||||
|
The release will be available at:
|
||||||
|
- **GitHub Releases:** https://github.com/johndoe6345789/SparkOS/releases
|
||||||
|
- **Docker Images:** `ghcr.io/johndoe6345789/sparkos:v1.0.0`
|
||||||
|
|
||||||
|
**Manual Release Creation:**
|
||||||
|
|
||||||
|
You can also create a release manually:
|
||||||
|
1. Go to https://github.com/johndoe6345789/SparkOS/releases/new
|
||||||
|
2. Choose or create a tag (e.g., `v1.0.0`)
|
||||||
|
3. Fill in the release title and description
|
||||||
|
4. Upload the `sparkos-release.zip` (built locally with `docker-release.sh`)
|
||||||
|
5. Publish the release
|
||||||
|
|
||||||
### Building Components
|
### Building Components
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
11
docker-compose.yml
Normal file
11
docker-compose.yml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
services:
|
||||||
|
sparkos:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
image: sparkos:local
|
||||||
|
container_name: sparkos-test
|
||||||
|
# The container will run the test script and exit
|
||||||
|
# Use 'docker-compose up' to test the build
|
||||||
183
scripts/docker-release.sh
Executable file
183
scripts/docker-release.sh
Executable file
@@ -0,0 +1,183 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# SparkOS Docker-based Release Builder
|
||||||
|
# Build release artifacts using Docker (no root required)
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||||
|
RELEASE_DIR="$PROJECT_ROOT/release"
|
||||||
|
VERSION="${1:-dev}"
|
||||||
|
|
||||||
|
echo "SparkOS Docker Release Builder"
|
||||||
|
echo "=============================="
|
||||||
|
echo ""
|
||||||
|
echo "Version: $VERSION"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Clean previous release
|
||||||
|
if [ -d "$RELEASE_DIR" ]; then
|
||||||
|
echo "Cleaning previous release..."
|
||||||
|
rm -rf "$RELEASE_DIR"
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p "$RELEASE_DIR"
|
||||||
|
|
||||||
|
# Build using Docker (multi-stage build)
|
||||||
|
echo "Building init binary using Docker..."
|
||||||
|
docker build -t sparkos:build-temp --target builder "$PROJECT_ROOT"
|
||||||
|
|
||||||
|
# Extract the built binary
|
||||||
|
echo "Extracting init binary..."
|
||||||
|
CONTAINER_ID=$(docker create sparkos:build-temp)
|
||||||
|
docker cp "$CONTAINER_ID:/build/init" "$RELEASE_DIR/init"
|
||||||
|
docker rm "$CONTAINER_ID" > /dev/null
|
||||||
|
|
||||||
|
# Verify the binary
|
||||||
|
echo ""
|
||||||
|
echo "Verifying init binary..."
|
||||||
|
if [ ! -f "$RELEASE_DIR/init" ]; then
|
||||||
|
echo "ERROR: Failed to extract init binary"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
ls -lh "$RELEASE_DIR/init"
|
||||||
|
file "$RELEASE_DIR/init"
|
||||||
|
|
||||||
|
# Create release package structure
|
||||||
|
echo ""
|
||||||
|
echo "Creating release package..."
|
||||||
|
mkdir -p "$RELEASE_DIR/sparkos"
|
||||||
|
|
||||||
|
# Copy compiled binary
|
||||||
|
cp "$RELEASE_DIR/init" "$RELEASE_DIR/sparkos/"
|
||||||
|
|
||||||
|
# Copy essential files
|
||||||
|
cp "$PROJECT_ROOT/README.md" "$RELEASE_DIR/sparkos/"
|
||||||
|
cp "$PROJECT_ROOT/LICENSE" "$RELEASE_DIR/sparkos/"
|
||||||
|
cp "$PROJECT_ROOT/ARCHITECTURE.md" "$RELEASE_DIR/sparkos/"
|
||||||
|
cp "$PROJECT_ROOT/CONTRIBUTING.md" "$RELEASE_DIR/sparkos/"
|
||||||
|
cp "$PROJECT_ROOT/Makefile" "$RELEASE_DIR/sparkos/"
|
||||||
|
cp "$PROJECT_ROOT/Dockerfile" "$RELEASE_DIR/sparkos/"
|
||||||
|
|
||||||
|
# Copy source for reference
|
||||||
|
cp -r "$PROJECT_ROOT/src" "$RELEASE_DIR/sparkos/"
|
||||||
|
|
||||||
|
# Copy scripts
|
||||||
|
cp -r "$PROJECT_ROOT/scripts" "$RELEASE_DIR/sparkos/"
|
||||||
|
|
||||||
|
# Copy config
|
||||||
|
cp -r "$PROJECT_ROOT/config" "$RELEASE_DIR/sparkos/"
|
||||||
|
|
||||||
|
# Copy rootfs structure (without generated content)
|
||||||
|
mkdir -p "$RELEASE_DIR/sparkos/rootfs"
|
||||||
|
for dir in etc root home; do
|
||||||
|
if [ -d "$PROJECT_ROOT/rootfs/$dir" ]; then
|
||||||
|
cp -r "$PROJECT_ROOT/rootfs/$dir" "$RELEASE_DIR/sparkos/rootfs/"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Create README for the release
|
||||||
|
cat > "$RELEASE_DIR/sparkos/RELEASE_README.md" << 'EOF'
|
||||||
|
# SparkOS Release Package
|
||||||
|
|
||||||
|
This package contains the compiled SparkOS init system and all necessary files to run or build SparkOS.
|
||||||
|
|
||||||
|
## Contents
|
||||||
|
|
||||||
|
- `init` - The compiled init binary (statically linked)
|
||||||
|
- `src/` - Source code for the init system
|
||||||
|
- `scripts/` - Build and setup scripts
|
||||||
|
- `config/` - Configuration files
|
||||||
|
- `rootfs/` - Root filesystem structure
|
||||||
|
- `Dockerfile` - Docker image definition
|
||||||
|
- `Makefile` - Build system
|
||||||
|
- Documentation files (README.md, ARCHITECTURE.md, etc.)
|
||||||
|
|
||||||
|
## Quick Start
|
||||||
|
|
||||||
|
### Using the Pre-built Binary
|
||||||
|
|
||||||
|
The `init` binary is already compiled and ready to use:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Copy to your rootfs
|
||||||
|
cp init /path/to/your/rootfs/sbin/init
|
||||||
|
chmod 755 /path/to/your/rootfs/sbin/init
|
||||||
|
```
|
||||||
|
|
||||||
|
### Using Docker
|
||||||
|
|
||||||
|
The easiest way to test SparkOS:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Build the Docker image
|
||||||
|
docker build -t sparkos .
|
||||||
|
|
||||||
|
# Run the test environment
|
||||||
|
docker run --rm sparkos
|
||||||
|
```
|
||||||
|
|
||||||
|
### Rebuilding from Source
|
||||||
|
|
||||||
|
If you need to rebuild:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Build the init system
|
||||||
|
make init
|
||||||
|
|
||||||
|
# Install to rootfs
|
||||||
|
make install
|
||||||
|
```
|
||||||
|
|
||||||
|
## Using Docker for Releases
|
||||||
|
|
||||||
|
Build release artifacts without needing root or special tools:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Build release package
|
||||||
|
./scripts/docker-release.sh v1.0.0
|
||||||
|
|
||||||
|
# The release package will be in release/sparkos-release.zip
|
||||||
|
```
|
||||||
|
|
||||||
|
## System Requirements
|
||||||
|
|
||||||
|
- Linux system with kernel 3.x or later
|
||||||
|
- Busybox for shell and utilities
|
||||||
|
- For building: Docker or GCC compiler and Make
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
See README.md for complete documentation, including:
|
||||||
|
- Building instructions
|
||||||
|
- Docker usage
|
||||||
|
- Network configuration
|
||||||
|
- Development guidelines
|
||||||
|
|
||||||
|
## Support
|
||||||
|
|
||||||
|
For issues and questions, visit: https://github.com/johndoe6345789/SparkOS
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Create release archive
|
||||||
|
echo ""
|
||||||
|
echo "Creating release archive..."
|
||||||
|
cd "$RELEASE_DIR"
|
||||||
|
zip -q -r "sparkos-release.zip" sparkos/
|
||||||
|
cd "$PROJECT_ROOT"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "SUCCESS! Release package created:"
|
||||||
|
echo " Location: $RELEASE_DIR/sparkos-release.zip"
|
||||||
|
echo " Size: $(du -h "$RELEASE_DIR/sparkos-release.zip" | cut -f1)"
|
||||||
|
echo ""
|
||||||
|
echo "Contents:"
|
||||||
|
ls -lh "$RELEASE_DIR/sparkos-release.zip"
|
||||||
|
echo ""
|
||||||
|
echo "To verify the contents:"
|
||||||
|
echo " unzip -l $RELEASE_DIR/sparkos-release.zip | head -40"
|
||||||
|
echo ""
|
||||||
|
echo "To test the Docker image:"
|
||||||
|
echo " docker build -t sparkos:$VERSION ."
|
||||||
|
echo " docker run --rm sparkos:$VERSION"
|
||||||
Reference in New Issue
Block a user