Sb docker #9
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build PVE CT ICO Image | ||
| on: | ||
| push: | ||
| branches: | ||
| - sb-docker | ||
| paths: | ||
| - 'Dockerfile' | ||
| - '.github/workflows/build-pve-ico.yml' | ||
| pull_request: | ||
| branches: | ||
| - sb-docker | ||
| workflow_dispatch: | ||
| env: | ||
| ICO_VERSION: 1.0 | ||
| jobs: | ||
| create-ico-image: | ||
| runs-on: ubuntu-latest | ||
| if: github.event_name == 'push' && github.ref == 'refs/heads/sb-docker' | ||
| steps: | ||
| - name: Checkout code | ||
| run: | | ||
| git clone --depth 1 https://github.com/${{ github.repository }} . | ||
| git checkout ${{ github.ref_name }} | ||
| - name: Install dependencies | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y --no-install-recommends \ | ||
| qemu-utils debootstrap curl wget jq zstd git docker.io | ||
| - name: Login to GHCR | ||
| run: | | ||
| echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | ||
| - name: Build Docker image | ||
| run: | | ||
| docker buildx create --use | ||
| docker buildx build \ | ||
| --platform linux/amd64,linux/arm64 \ | ||
| --tag ghcr.io/${{ github.repository }}:latest \ | ||
| --push \ | ||
| . | ||
| - name: Create workspace | ||
| run: | | ||
| mkdir -p workspace/{root,output} | ||
| cd workspace | ||
| echo "Workspace created" | ||
| - name: Download base ICO image | ||
| run: | | ||
| cd workspace/root | ||
| echo "Downloading Debian 12 base image..." | ||
| wget -q --timeout=300 --tries=3 -O debian-12-base.tar.zst \ | ||
| https://download.proxmox.com/images/system/debian-12-standard_12.2-1_amd64.tar.zst || \ | ||
| wget -q --timeout=300 --tries=3 -O debian-12-base.tar.zst \ | ||
| http://download.proxmox.com/images/system/debian-12-standard_12.2-1_amd64.tar.zst || \ | ||
| echo "Download failed, will use debootstrap" | ||
| echo "status=debootstrap" >> $GITHUB_STEP_SUMMARY | ||
| - name: Prepare container rootfs | ||
| run: | | ||
| cd workspace/root | ||
| ROOTFS="rootfs" | ||
| mkdir -p "$ROOTFS" | ||
| echo "Creating rootfs with debootstrap..." | ||
| sudo debootstrap --variant=minbase --no-check-gpg \ | ||
| bookworm "$ROOTFS" http://deb.debian.org/debian | ||
| echo "✅ Rootfs prepared" | ||
| sudo ls -la "$ROOTFS" | head -10 | ||
| - name: Customize container | ||
| run: | | ||
| ROOTFS="workspace/root/rootfs" | ||
| echo "Customizing container..." | ||
| sudo chroot "$ROOTFS" bash -c ' | ||
| export DEBIAN_FRONTEND=noninteractive | ||
| apt-get update -qq | ||
| apt-get install -y --no-install-recommends \ | ||
| ca-certificates curl wget procps systemd openssh-server | ||
| apt-get clean | ||
| rm -rf /var/lib/apt/lists/* | ||
| ' | ||
| echo "✅ Container customization completed" | ||
| - name: Create TAR archive for PVE | ||
| run: | | ||
| OUTPUT_DIR="workspace/output" | ||
| ROOTFS="workspace/root/rootfs" | ||
| mkdir -p "$OUTPUT_DIR" | ||
| cd "$ROOTFS" | ||
| echo "Creating TAR.ZST archive..." | ||
| sudo tar --numeric-owner --xattrs -cf - . | \ | ||
| zstd -10 -o "$OUTPUT_DIR/sing-box-subscribe-ct.tar.zst" | ||
| echo "✅ Archive created: $(ls -lh "$OUTPUT_DIR/")" | ||
| - name: Create metadata | ||
| run: | | ||
| OUTPUT_DIR="workspace/output" | ||
| cd "$OUTPUT_DIR" | ||
| BUILD_TIME=$(date -u +%Y-%m-%dT%H:%M:%SZ) | ||
| CONTENT_HASH=$(sha256sum sing-box-subscribe-ct.tar.zst | cut -d' ' -f1) | ||
| FILE_SIZE=$(du -b sing-box-subscribe-ct.tar.zst | cut -f1) | ||
| cat > metadata.json << EOF | ||
| { | ||
| "name": "sing-box-subscribe", | ||
| "version": "1.0", | ||
| "type": "lxc", | ||
| "arch": "amd64", | ||
| "created": "$BUILD_TIME", | ||
| "description": "Sing-Box Subscription Container for Proxmox VE" | ||
| } | ||
| EOF | ||
| echo "✅ Metadata created" | ||
| - name: Upload artifacts | ||
| uses: actions/upload-artifact@v3 | ||
| with: | ||
| name: pve-ico-image-${{ github.sha }} | ||
| path: workspace/output/* | ||
| retention-days: 30 | ||
| - name: Summary | ||
| if: always() | ||
| run: | | ||
| echo "## PVE CT Image Build Complete" | ||
| echo "- Download: [Actions Artifacts]" | ||
| echo "- Import to PVE: `pct restore <ID> sing-box-subscribe-ct.tar.zst`" | ||