Add composefs CI workflow and Dockerfile
- Create Dockerfile for building composefs with meson/ninja - Add comprehensive CI workflow based on bootupd-sdboot - Includes apt-cacher-ng support for faster builds - Builds composefs from source with FUSE support - Creates Debian package with proper dependencies - Uploads to Forgejo Debian Registry - Uses docker cp to transfer files from container to host
This commit is contained in:
commit
112081ce1d
2 changed files with 253 additions and 0 deletions
235
.forgejo/workflows/ci.yml
Normal file
235
.forgejo/workflows/ci.yml
Normal file
|
|
@ -0,0 +1,235 @@
|
|||
---
|
||||
name: Build composefs with Debian packaging
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
env:
|
||||
MESON_COLOR: always
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
run: |
|
||||
echo "Cloning repository..."
|
||||
git clone https://git.raines.xyz/particle-os/composefs.git /tmp/composefs
|
||||
cd /tmp/composefs
|
||||
git fetch --all
|
||||
git checkout ${{ github.sha || gitea.sha || 'main' }}
|
||||
|
||||
- name: Setup apt-cacher-ng
|
||||
run: |
|
||||
echo "Setting up apt-cacher-ng for faster builds..."
|
||||
|
||||
# Try apt-cacher-ng first, fallback to standard mirrors
|
||||
echo "Checking for apt-cacher-ng availability..."
|
||||
|
||||
# Quick check with timeout to avoid hanging
|
||||
if timeout 10 curl -s --connect-timeout 5 \
|
||||
http://192.168.1.101:3142/acng-report.html > /dev/null 2>&1; then
|
||||
echo "✅ apt-cacher-ng is available, configuring Docker proxy..."
|
||||
|
||||
# Create Docker daemon configuration for apt-cacher-ng
|
||||
sudo mkdir -p /etc/docker
|
||||
echo '{
|
||||
"proxies": {
|
||||
"default": {
|
||||
"httpProxy": "http://192.168.1.101:3142",
|
||||
"httpsProxy": "http://192.168.1.101:3142",
|
||||
"noProxy": "localhost,127.0.0.1"
|
||||
}
|
||||
}
|
||||
}' | sudo tee /etc/docker/daemon.json
|
||||
|
||||
# Note: Docker daemon restart requires systemd, which isn't available in CI
|
||||
# The proxy configuration will be used by Docker builds
|
||||
echo "Docker proxy configuration created (restart not possible in CI)"
|
||||
else
|
||||
echo "⚠️ apt-cacher-ng not available, using standard mirrors..."
|
||||
echo "Using standard Debian mirrors for Docker builds"
|
||||
fi
|
||||
|
||||
- name: Build Docker image
|
||||
run: |
|
||||
cd /tmp/composefs
|
||||
docker build --build-arg release_name=unstable -f Dockerfile \
|
||||
-t composefs-build:latest .
|
||||
|
||||
- name: Build composefs inside container
|
||||
run: |
|
||||
cd /tmp/composefs
|
||||
echo "Current directory before Docker run: $(pwd)"
|
||||
echo "Files in current directory before Docker run:"
|
||||
ls -la
|
||||
|
||||
# Run Docker container and capture container ID
|
||||
CONTAINER_ID=$(docker run -d -v $(pwd):/workspace composefs-build:latest bash -c "
|
||||
# Setup apt-cacher-ng inside container if available
|
||||
if timeout 5 curl -s --connect-timeout 3 \
|
||||
http://192.168.1.101:3142/acng-report.html > /dev/null 2>&1; then
|
||||
echo '✅ Using apt-cacher-ng for package downloads...'
|
||||
echo 'deb http://192.168.1.101:3142/ftp.us.debian.org/debian unstable main' > /etc/apt/sources.list
|
||||
echo 'deb-src http://192.168.1.101:3142/ftp.us.debian.org/debian unstable main' >> /etc/apt/sources.list
|
||||
else
|
||||
echo '⚠️ Using standard Debian mirrors...'
|
||||
echo 'deb http://deb.debian.org/debian unstable main' > /etc/apt/sources.list
|
||||
echo 'deb-src http://deb.debian.org/debian unstable main' >> /etc/apt/sources.list
|
||||
fi
|
||||
|
||||
# Update package lists
|
||||
apt update -y
|
||||
|
||||
# Clone and build composefs
|
||||
git clone https://github.com/containers/composefs.git composefs && \
|
||||
cd composefs && \
|
||||
git fetch --all && \
|
||||
meson setup build --prefix=/usr --default-library=shared -Dfuse=enabled && \
|
||||
ninja -C build && \
|
||||
ninja -C build install && \
|
||||
echo 'Creating Debian package...' && \
|
||||
cd /workspace && \
|
||||
BUILD_NUMBER=\"${FORGEJO_RUN_NUMBER:-${GITEA_RUN_NUMBER:-$(date +%Y%m%d%H%M%S)}}\" && \
|
||||
COMMIT_HASH=\"$(git rev-parse HEAD 2>/dev/null || echo unknown)\" && \
|
||||
SHORT_COMMIT=\"$(echo \"$COMMIT_HASH\" | cut -c1-10)\" && \
|
||||
mkdir -p composefs-package/usr/bin composefs-package/usr/lib composefs-package/usr/share/man/man1 composefs-package/DEBIAN && \
|
||||
cp /usr/bin/composefs-* composefs-package/usr/bin/ 2>/dev/null || true && \
|
||||
cp /usr/lib/libcomposefs.so.* composefs-package/usr/lib/ 2>/dev/null || true && \
|
||||
cp /usr/share/man/man1/composefs-*.1 composefs-package/usr/share/man/man1/ 2>/dev/null || true && \
|
||||
chmod +x composefs-package/usr/bin/* 2>/dev/null || true && \
|
||||
printf 'Package: composefs\\nVersion: 0.1.0+%s+%s\\nSection: admin\\n' \"$BUILD_NUMBER\" \"$SHORT_COMMIT\" > composefs-package/DEBIAN/control && \
|
||||
printf 'Priority: optional\\nArchitecture: amd64\\n' >> composefs-package/DEBIAN/control && \
|
||||
printf 'Maintainer: CI Build <ci@example.com>\\n' >> composefs-package/DEBIAN/control && \
|
||||
printf 'Depends: libc6 (>= 2.39), libfuse3-3 (>= 3.10.0)\\n' >> composefs-package/DEBIAN/control && \
|
||||
printf 'Description: Content-addressable filesystem for containers\\n' >> composefs-package/DEBIAN/control && \
|
||||
printf ' Composefs is a content-addressable filesystem designed for\\n' >> composefs-package/DEBIAN/control && \
|
||||
printf ' efficient container image management.\\n' >> composefs-package/DEBIAN/control && \
|
||||
printf ' .\\n' >> composefs-package/DEBIAN/control && \
|
||||
printf ' Features:\\n' >> composefs-package/DEBIAN/control && \
|
||||
printf ' - Content-addressable storage\\n' >> composefs-package/DEBIAN/control && \
|
||||
printf ' - FUSE-based filesystem\\n' >> composefs-package/DEBIAN/control && \
|
||||
printf ' - Container image optimization\\n' >> composefs-package/DEBIAN/control && \
|
||||
printf ' - OSTree integration\\n' >> composefs-package/DEBIAN/control && \
|
||||
dpkg-deb --build composefs-package composefs_0.1.0+${BUILD_NUMBER}+${SHORT_COMMIT}_amd64.deb && \
|
||||
echo \"✅ Debian package created: composefs_0.1.0+${BUILD_NUMBER}+${SHORT_COMMIT}_amd64.deb\" && \
|
||||
echo \"Files in /workspace after package creation:\" && \
|
||||
ls -la /workspace/ && \
|
||||
echo \"Looking for .deb files in /workspace:\" && \
|
||||
ls -la /workspace/*.deb 2>/dev/null || echo \"No .deb files found in /workspace\"
|
||||
")
|
||||
|
||||
# Wait for container to complete
|
||||
echo "Waiting for container to complete..."
|
||||
docker wait $CONTAINER_ID
|
||||
|
||||
# Copy .deb file from container to host
|
||||
echo "Copying .deb file from container to host..."
|
||||
docker cp $CONTAINER_ID:/workspace/composefs_0.1.0++_amd64.deb .
|
||||
|
||||
# Clean up container
|
||||
docker rm $CONTAINER_ID
|
||||
|
||||
echo "Current directory after Docker run: $(pwd)"
|
||||
echo "Files in current directory after Docker run:"
|
||||
ls -la
|
||||
|
||||
- name: Upload to Forgejo Debian Registry
|
||||
run: |
|
||||
cd /tmp/composefs
|
||||
echo "Uploading to Forgejo Debian Registry..."
|
||||
|
||||
# Debug: List files in current directory
|
||||
echo "Files in current directory:"
|
||||
ls -la
|
||||
echo "Looking for .deb files:"
|
||||
ls -la *.deb 2>/dev/null || echo "No .deb files found"
|
||||
|
||||
# Set Forgejo configuration
|
||||
FORGEJO_OWNER="particle-os"
|
||||
FORGEJO_DISTRIBUTION="trixie"
|
||||
FORGEJO_COMPONENT="main"
|
||||
|
||||
# Find the .deb file (it should be in the current directory from Docker mount)
|
||||
DEB_FILE=$(ls composefs_*.deb 2>/dev/null | head -1)
|
||||
|
||||
if [ -z "$DEB_FILE" ]; then
|
||||
echo "❌ No .deb file found for upload"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "📦 Uploading package: $DEB_FILE"
|
||||
|
||||
# Extract package info
|
||||
PKG_NAME=$(dpkg-deb -f "$DEB_FILE" Package 2>/dev/null || echo "composefs")
|
||||
PKG_VERSION=$(dpkg-deb -f "$DEB_FILE" Version 2>/dev/null || echo "unknown")
|
||||
PKG_ARCH=$(dpkg-deb -f "$DEB_FILE" Architecture 2>/dev/null || echo "amd64")
|
||||
|
||||
echo " Package: $PKG_NAME"
|
||||
echo " Version: $PKG_VERSION"
|
||||
echo " Architecture: $PKG_ARCH"
|
||||
|
||||
# Forgejo Debian Registry upload URL
|
||||
UPLOAD_URL="https://git.raines.xyz/api/packages/${FORGEJO_OWNER}/debian/pool/${FORGEJO_DISTRIBUTION}/${FORGEJO_COMPONENT}/upload"
|
||||
|
||||
echo " Upload URL: $UPLOAD_URL"
|
||||
|
||||
# Upload to Forgejo Debian Registry
|
||||
if [ -n "${{ secrets.ACCESS_TOKEN }}" ]; then
|
||||
echo " 🔐 Using authentication token..."
|
||||
UPLOAD_RESULT=$(curl -s -w "%{http_code}" \
|
||||
--user "${FORGEJO_OWNER}:${{ secrets.ACCESS_TOKEN }}" \
|
||||
--upload-file "$DEB_FILE" \
|
||||
"$UPLOAD_URL" 2>/dev/null)
|
||||
|
||||
# Extract HTTP status code (last 3 characters)
|
||||
HTTP_CODE=$(echo "$UPLOAD_RESULT" | tail -c 4)
|
||||
# Extract response body (everything except last 3 characters)
|
||||
RESPONSE_BODY=$(echo "$UPLOAD_RESULT" | head -c -4)
|
||||
|
||||
case $HTTP_CODE in
|
||||
201)
|
||||
echo " ✅ Successfully published to Forgejo Debian Registry!"
|
||||
echo " 📥 Install with: apt install $PKG_NAME"
|
||||
;;
|
||||
409)
|
||||
echo " ⚠️ Package already exists (version conflict)"
|
||||
echo " 💡 Consider deleting old version first"
|
||||
;;
|
||||
400)
|
||||
echo " ❌ Bad request - package validation failed"
|
||||
;;
|
||||
*)
|
||||
echo " ❌ Upload failed with HTTP $HTTP_CODE"
|
||||
echo " Response: $RESPONSE_BODY"
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo " ⚠️ No ACCESS_TOKEN secret available - skipping upload"
|
||||
echo " 💡 Set ACCESS_TOKEN secret in repository settings to enable automatic publishing"
|
||||
echo " 📋 Manual upload command:"
|
||||
echo " curl --user your_username:your_token \\"
|
||||
echo " --upload-file $DEB_FILE \\"
|
||||
echo " $UPLOAD_URL"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "🎯 Debian package publishing complete!"
|
||||
echo "📦 Package is now available in Forgejo Debian Registry"
|
||||
echo "🔧 To install: apt install composefs"
|
||||
|
||||
- name: Upload artifacts
|
||||
run: |
|
||||
cd /tmp/composefs
|
||||
echo "Creating artifact directory..."
|
||||
mkdir -p /tmp/artifacts
|
||||
cp composefs_*.deb /tmp/artifacts/ 2>/dev/null || true
|
||||
echo "Artifacts created in /tmp/artifacts/"
|
||||
ls -la /tmp/artifacts/
|
||||
18
Dockerfile
Normal file
18
Dockerfile
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# Dockerfile for building composefs
|
||||
ARG release_name=unstable
|
||||
FROM buildpack-deps:${release_name}
|
||||
|
||||
# Install build dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
meson \
|
||||
ninja-build \
|
||||
libfuse3-dev \
|
||||
pkg-config \
|
||||
git \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /workspace
|
||||
|
||||
# Default command
|
||||
CMD ["bash"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue