|
| 1 | +name: Publish kernels and runtime bases to GHCR |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: [main] |
| 7 | + paths: |
| 8 | + - 'examples/**' |
| 9 | + - 'runtimes/**' |
| 10 | + - '.github/workflows/publish-examples.yml' |
| 11 | + |
| 12 | +# Only one publish run per ref at a time. cancel-in-progress ensures a |
| 13 | +# newer commit supersedes an older publish cleanly; GHCR tags are |
| 14 | +# idempotent so the latest push always wins. |
| 15 | +concurrency: |
| 16 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 17 | + cancel-in-progress: true |
| 18 | + |
| 19 | +env: |
| 20 | + REGISTRY: ghcr.io |
| 21 | + IMAGE_BASE: ghcr.io/${{ github.repository }} |
| 22 | + |
| 23 | +jobs: |
| 24 | + # Publish base runtime images (interpreted languages) |
| 25 | + publish-bases: |
| 26 | + runs-on: ubuntu-latest |
| 27 | + permissions: |
| 28 | + contents: read |
| 29 | + packages: write |
| 30 | + strategy: |
| 31 | + fail-fast: false |
| 32 | + matrix: |
| 33 | + runtime: [python, nodejs, powershell, shell] |
| 34 | + steps: |
| 35 | + - uses: actions/checkout@v4 |
| 36 | + |
| 37 | + - name: Log in to GHCR |
| 38 | + uses: docker/login-action@v3 |
| 39 | + with: |
| 40 | + registry: ${{ env.REGISTRY }} |
| 41 | + username: ${{ github.actor }} |
| 42 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 43 | + |
| 44 | + - name: Build and push base image |
| 45 | + run: | |
| 46 | + IMAGE=${{ env.IMAGE_BASE }}/${{ matrix.runtime }}-base:latest |
| 47 | + docker build --platform linux/amd64 \ |
| 48 | + -f runtimes/${{ matrix.runtime }}.Dockerfile \ |
| 49 | + -t $IMAGE runtimes/ |
| 50 | + docker push $IMAGE |
| 51 | +
|
| 52 | + # Build and publish kernels for each example |
| 53 | + publish-kernels: |
| 54 | + runs-on: ubuntu-latest |
| 55 | + permissions: |
| 56 | + contents: read |
| 57 | + packages: write |
| 58 | + strategy: |
| 59 | + fail-fast: false |
| 60 | + matrix: |
| 61 | + example: |
| 62 | + - name: helloworld-c |
| 63 | + kernel: helloworld-hyperlight_hyperlight-x86_64 |
| 64 | + - name: hostfs-posix-c |
| 65 | + kernel: hostfs-posix-c-hyperlight_hyperlight-x86_64 |
| 66 | + - name: hostfs-posix-py |
| 67 | + kernel: hostfs-posix-py-hyperlight_hyperlight-x86_64 |
| 68 | + - name: python-agent |
| 69 | + kernel: python-agent-hyperlight_hyperlight-x86_64 |
| 70 | + - name: rust |
| 71 | + kernel: rust-hyperlight_hyperlight-x86_64 |
| 72 | + - name: go |
| 73 | + kernel: go-hyperlight_hyperlight-x86_64 |
| 74 | + - name: shell |
| 75 | + kernel: shell-hyperlight_hyperlight-x86_64 |
| 76 | + - name: python |
| 77 | + kernel: python-hyperlight_hyperlight-x86_64 |
| 78 | + - name: nodejs |
| 79 | + kernel: nodejs-hyperlight_hyperlight-x86_64 |
| 80 | + - name: dotnet |
| 81 | + kernel: dotnet-hyperlight_hyperlight-x86_64 |
| 82 | + - name: dotnet-nativeaot |
| 83 | + kernel: dotnet-nativeaot-hyperlight_hyperlight-x86_64 |
| 84 | + - name: powershell |
| 85 | + kernel: powershell-hyperlight_hyperlight-x86_64 |
| 86 | + - name: python-agent-driver |
| 87 | + kernel: python-agent-driver-hyperlight_hyperlight-x86_64 |
| 88 | + steps: |
| 89 | + - uses: actions/checkout@v4 |
| 90 | + |
| 91 | + - name: Install tools |
| 92 | + run: | |
| 93 | + # Install kraft-hyperlight |
| 94 | + git clone --branch hyperlight-platform --depth 1 https://github.com/danbugs/kraftkit.git /tmp/kraftkit |
| 95 | + cd /tmp/kraftkit && go build -o /usr/local/bin/kraft-hyperlight ./cmd/kraft |
| 96 | + # Install hyperlight-unikraft |
| 97 | + cd ${{ github.workspace }}/host && cargo build --release |
| 98 | + sudo cp target/release/hyperlight-unikraft /usr/local/bin/ |
| 99 | +
|
| 100 | + - name: Build kernel |
| 101 | + working-directory: examples/${{ matrix.example.name }} |
| 102 | + run: | |
| 103 | + kraft-hyperlight --no-prompt build --plat hyperlight --arch x86_64 || true |
| 104 | + # Fallback: manual source clone + build |
| 105 | + if [ ! -f ".unikraft/build/${{ matrix.example.kernel }}" ]; then |
| 106 | + UK_BRANCH=$(grep 'version:' kraft.yaml | head -1 | awk '{print $2}') |
| 107 | + mkdir -p .unikraft/apps .unikraft/libs |
| 108 | + rm -rf .unikraft/unikraft .unikraft/apps/elfloader |
| 109 | + git clone --branch $UK_BRANCH --depth 1 https://github.com/danbugs/unikraft.git .unikraft/unikraft |
| 110 | + git clone --branch $UK_BRANCH --depth 1 https://github.com/danbugs/app-elfloader.git .unikraft/apps/elfloader |
| 111 | + git clone --branch staging --depth 1 https://github.com/unikraft/lib-libelf.git .unikraft/libs/libelf |
| 112 | + rm -rf .unikraft/build |
| 113 | + kraft-hyperlight --no-prompt build --plat hyperlight --arch x86_64 |
| 114 | + fi |
| 115 | +
|
| 116 | + - name: Log in to GHCR |
| 117 | + uses: docker/login-action@v3 |
| 118 | + with: |
| 119 | + registry: ${{ env.REGISTRY }} |
| 120 | + username: ${{ github.actor }} |
| 121 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 122 | + |
| 123 | + - name: Publish kernel image |
| 124 | + working-directory: examples |
| 125 | + run: | |
| 126 | + IMAGE=${{ env.IMAGE_BASE }}/${{ matrix.example.name }}-kernel:latest |
| 127 | + # Package just the kernel binary in a scratch image |
| 128 | + cat > /tmp/Dockerfile.kernel << DEOF |
| 129 | + FROM scratch |
| 130 | + COPY ${{ matrix.example.name }}/.unikraft/build/${{ matrix.example.kernel }} /kernel |
| 131 | + DEOF |
| 132 | + docker build -f /tmp/Dockerfile.kernel -t $IMAGE . |
| 133 | + docker push $IMAGE |
| 134 | +
|
| 135 | + # Publish the python-agent-driver rootfs CPIO as its own image so |
| 136 | + # `pyhl setup` can pull the initrd (and kernel, above) from GHCR |
| 137 | + # without having to build the driver image locally. |
| 138 | + publish-pyhl-initrd: |
| 139 | + runs-on: ubuntu-latest |
| 140 | + permissions: |
| 141 | + contents: read |
| 142 | + packages: write |
| 143 | + steps: |
| 144 | + - uses: actions/checkout@v4 |
| 145 | + |
| 146 | + - name: Log in to GHCR |
| 147 | + uses: docker/login-action@v3 |
| 148 | + with: |
| 149 | + registry: ${{ env.REGISTRY }} |
| 150 | + username: ${{ github.actor }} |
| 151 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 152 | + |
| 153 | + # python-agent-driver's Dockerfile builds hl_pydriver against |
| 154 | + # local-python-base-dev so the glibc/libpython ABIs match the |
| 155 | + # runtime image. Materialise both locally before `just rootfs`. |
| 156 | + - name: Build local-python-base and local-python-base-dev |
| 157 | + env: |
| 158 | + DOCKER_BUILDKIT: '0' |
| 159 | + run: | |
| 160 | + # Full image with dev headers (compiles hl_pydriver.c) |
| 161 | + docker build --target base -t local-python-base-dev:latest \ |
| 162 | + -f runtimes/python.Dockerfile runtimes/ |
| 163 | + # Slim runtime image (ends up inside the guest rootfs) |
| 164 | + docker build -t local-python-base:latest \ |
| 165 | + -f runtimes/python.Dockerfile runtimes/ |
| 166 | +
|
| 167 | + - name: Install just |
| 168 | + uses: extractions/setup-just@v2 |
| 169 | + |
| 170 | + - name: Build python-agent-driver rootfs (CPIO) |
| 171 | + working-directory: examples/python-agent-driver |
| 172 | + env: |
| 173 | + DOCKER_BUILDKIT: '0' |
| 174 | + run: | |
| 175 | + just rootfs |
| 176 | +
|
| 177 | + - name: Publish initrd image |
| 178 | + working-directory: examples/python-agent-driver |
| 179 | + run: | |
| 180 | + IMAGE=${{ env.IMAGE_BASE }}/python-agent-driver-initrd:latest |
| 181 | + cat > /tmp/Dockerfile.initrd << DEOF |
| 182 | + FROM scratch |
| 183 | + COPY python-agent-driver-initrd.cpio /initrd.cpio |
| 184 | + DEOF |
| 185 | + docker build -f /tmp/Dockerfile.initrd -t $IMAGE . |
| 186 | + docker push $IMAGE |
0 commit comments