-
Notifications
You must be signed in to change notification settings - Fork 22
ci(feat): add mkosi os image building #780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
16ccabf
ci(feat): add mkosi os image building
pendo324 ba43c11
address comments
pendo324 9bc3991
integrate into workflows
pendo324 7268cf5
update submodule
pendo324 ab70b37
install aws package
pendo324 9a65dae
use the proper aws cli package
pendo324 afb5a38
Changes:
Swapnanil-Gupta d37435e
increase timeout and use sha512sum
Swapnanil-Gupta 958c18f
test mkosi images in ci
Swapnanil-Gupta 4f12e98
e2e-vm print lima logs
Swapnanil-Gupta 548bd98
disable ssh over vsock for vz driver
Swapnanil-Gupta bb1a469
move cosign conf to a separate file
Swapnanil-Gupta bb7712e
Changes:
Swapnanil-Gupta 5044f4f
test latest images in CI
Swapnanil-Gupta 4138f81
fix qemu file copies and path rewrites
Swapnanil-Gupta 6e658ec
test latest images in CI
Swapnanil-Gupta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,216 @@ | ||
| name: Build OS | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: '0 16 * * *' # Daily at 8am PST / 4pm UTC | ||
| push: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - 'deps/mkosi/**' | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - 'deps/mkosi/**' | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
|
|
||
| jobs: | ||
| build-os-image: | ||
| runs-on: | ||
| - ${{ matrix.os }} | ||
| container: | ||
| image: public.ecr.aws/docker/library/fedora:43 | ||
| options: --privileged | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| os: [ubuntu-24.04, ubuntu-24.04-arm] | ||
| timeout-minutes: 60 | ||
| steps: | ||
| - name: Install packages | ||
| run: | | ||
| dnf install -y git \ | ||
| systemd-boot \ | ||
| systemd-repart \ | ||
| systemd-ukify \ | ||
| qemu-img \ | ||
| docker \ | ||
| jq \ | ||
| e2fsprogs \ | ||
| dosfstools \ | ||
| cpio \ | ||
| zstd \ | ||
| procps-ng \ | ||
| distribution-gpg-keys \ | ||
| openssl \ | ||
| mtools \ | ||
| skopeo \ | ||
| awscli2 | ||
| - name: Checkout repo | ||
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | ||
| with: | ||
| submodules: true | ||
| - name: Configure AWS credentials | ||
| uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a # v4.3.1 | ||
| with: | ||
| role-to-assume: ${{ secrets.ROLE }} | ||
| aws-region: ${{ secrets.REGION }} | ||
| role-session-name: rootfs-ecr-image-upload-session | ||
| - name: Login to Amazon ECR | ||
| uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1 | ||
| - name: Install mkosi | ||
| run: | | ||
| mkdir -p "$HOME/.local/bin/" | ||
| export PATH="/root/.local/bin/:$PATH" | ||
| ./deps/mkosi/install-mkosi.sh | ||
| - name: mkosi arch | ||
| id: mkosi-arch | ||
| shell: bash | ||
| run: | | ||
| arch="" | ||
| if [ "$(uname -m)" == "aarch64" ]; then | ||
| arch="arm64" | ||
| else | ||
| arch="x86-64" | ||
| fi | ||
| echo "arch=${arch}" >> $GITHUB_OUTPUT | ||
| - name: Fix git permissions | ||
| run: | | ||
| git config --global --add safe.directory "${GITHUB_WORKSPACE}" | ||
| - name: Build QEMU | ||
| run: | | ||
| ln -s "$HOME/.docker" /root/.docker | ||
|
Swapnanil-Gupta marked this conversation as resolved.
|
||
| export ECR_CACHE_REPO="${{ secrets.ECR_CACHE_REPO }}" | ||
| ./deps/mkosi/scripts/build-qemu.sh | ||
| - name: Setup binary packages | ||
| run: | | ||
| ./deps/mkosi/scripts/bin-packages.sh | ||
| - name: Build custom AL packages | ||
| run: | | ||
| ln -s "$HOME/.docker" /root/.docker | ||
| ./deps/mkosi/scripts/al2023-package-build.sh | ||
| - name: Build OS image | ||
| run: | | ||
| arch="${{ steps.mkosi-arch.outputs.arch }}" | ||
| export PATH="$HOME/.local/bin/:$PATH" | ||
| ./deps/mkosi/mkosi.sh --arch "${arch}" -- --image-id os-image | ||
| - name: Convert OS image | ||
| run: | | ||
| arch="${{ steps.mkosi-arch.outputs.arch }}" | ||
| sudo qemu-img convert -f raw -c -O qcow2 "./deps/mkosi/out/${arch}/os-image.raw" \ | ||
| "./deps/mkosi/out/${arch}/os-image.qcow2" | ||
| - name: Calculate SHA512 checksum for OS image | ||
| run: | | ||
| arch="${{ steps.mkosi-arch.outputs.arch }}" | ||
| cd "./deps/mkosi/out/${arch}" | ||
| sha512sum os-image.qcow2 | cut -d ' ' -f 1 > os-image.qcow2.sha512sum | ||
| - name: Upload OS image to S3 | ||
| run: | | ||
| arch="${{ steps.mkosi-arch.outputs.arch }}" | ||
| filename="finch-al2023-os-image-${arch}-${{ github.run_id }}.qcow2" | ||
| aws s3 cp "./deps/mkosi/out/${arch}/os-image.qcow2" \ | ||
| "s3://${{ secrets.DEPENDENCY_BUCKET_NAME }}/${filename}" \ | ||
| --region "${{ secrets.DEPENDENCY_BUCKET_REGION }}" | ||
| aws s3 cp "./deps/mkosi/out/${arch}/os-image.qcow2.sha512sum" \ | ||
| "s3://${{ secrets.DEPENDENCY_BUCKET_NAME }}/${filename}.sha512sum" \ | ||
| --region "${{ secrets.DEPENDENCY_BUCKET_REGION }}" | ||
| - name: Push OS image | ||
| run: | | ||
| arch="${{ steps.mkosi-arch.outputs.arch }}" | ||
| tar -cvf "./deps/mkosi/out/${arch}/container-with-kernel-image.tar" -C "./deps/mkosi/out/${arch}/container-with-kernel" . | ||
| skopeo copy \ | ||
| "oci-archive:./deps/mkosi/out/${arch}/container-with-kernel-image.tar" \ | ||
| docker://"${{ secrets.ROOTFS_IMAGE_ECR_REPOSITORY_NAME }}:${{ steps.mkosi-arch.outputs.arch }}-with-kernel-${{github.run_id}}" | ||
| - name: Run wsl rootfs build | ||
| if: steps.mkosi-arch.outputs.arch == 'x86-64' | ||
| run: | | ||
| export PATH="$HOME/.local/bin/:$PATH" | ||
| ./deps/mkosi/mkosi.sh --arch x86-64 -- --image-id wsl-rootfs | ||
| - name: Remove init -> systemd symlink and delete efi directory | ||
| if: steps.mkosi-arch.outputs.arch == 'x86-64' | ||
| run: | | ||
| arch="${{ steps.mkosi-arch.outputs.arch }}" | ||
| cd "./deps/mkosi/out/${arch}/wsl-rootfs/" | ||
| rm -f init | ||
| rm -rf efi | ||
| - name: Compress rootfs for S3 | ||
| if: steps.mkosi-arch.outputs.arch == 'x86-64' | ||
| run: | | ||
| arch="${{ steps.mkosi-arch.outputs.arch }}" | ||
| cd "./deps/mkosi/out/${arch}" | ||
| tar -czvf wsl-rootfs.tar.gz -C wsl-rootfs . | ||
| - name: Calculate SHA512 checksum for rootfs | ||
| if: steps.mkosi-arch.outputs.arch == 'x86-64' | ||
| run: | | ||
| arch="${{ steps.mkosi-arch.outputs.arch }}" | ||
| cd "./deps/mkosi/out/${arch}" | ||
| sha512sum wsl-rootfs.tar.gz | cut -d ' ' -f 1 > wsl-rootfs.tar.gz.sha512sum | ||
| - name: Upload rootfs to S3 | ||
| if: steps.mkosi-arch.outputs.arch == 'x86-64' | ||
| run: | | ||
| arch="${{ steps.mkosi-arch.outputs.arch }}" | ||
| filename="finch-al2023-rootfs-${arch}-${{ github.run_id }}.tar.gz" | ||
| aws s3 cp "./deps/mkosi/out/${arch}/wsl-rootfs.tar.gz" \ | ||
| "s3://${{ secrets.DEPENDENCY_BUCKET_NAME }}/common/${arch}/${filename}" \ | ||
| --region "${{ secrets.DEPENDENCY_BUCKET_REGION }}" | ||
| aws s3 cp "./deps/mkosi/out/${arch}/wsl-rootfs.tar.gz.sha512sum" \ | ||
| "s3://${{ secrets.DEPENDENCY_BUCKET_NAME }}/common/${arch}/${filename}.sha512sum" \ | ||
| --region "${{ secrets.DEPENDENCY_BUCKET_REGION }}" | ||
| - name: Upload container image artifacts | ||
| if: steps.mkosi-arch.outputs.arch == 'x86-64' | ||
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | ||
| with: | ||
| name: image-oci-${{ steps.mkosi-arch.outputs.arch }}-${{github.run_id}}.tar.gz | ||
| path: ./deps/mkosi/out/${{ steps.mkosi-arch.outputs.arch }}/wsl-rootfs.tar.gz | ||
| if-no-files-found: error | ||
| - name: Upload OS image artifacts | ||
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | ||
| with: | ||
| name: image-${{ steps.mkosi-arch.outputs.arch }}-${{github.run_id}}.qcow2 | ||
| path: ./deps/mkosi/out/${{ steps.mkosi-arch.outputs.arch }}/os-image.qcow2 | ||
| if-no-files-found: error | ||
|
|
||
| update-deps-config: | ||
| needs: build-os-image | ||
| runs-on: ubuntu-latest | ||
| if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' | ||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
| steps: | ||
| - name: Checkout repo | ||
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | ||
| - name: Configure AWS credentials | ||
| uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a # v4.3.1 | ||
| with: | ||
| role-to-assume: ${{ secrets.ROLE }} | ||
| aws-region: ${{ secrets.REGION }} | ||
| role-session-name: update-deps-config-session | ||
| - name: Run update-os-image script | ||
| run: | | ||
| bash bin/update-os-image.sh \ | ||
| -d "${{ secrets.DEPENDENCY_BUCKET_NAME }}" | ||
| - name: Run update-rootfs script | ||
| run: | | ||
| bash bin/update-rootfs.sh \ | ||
| -d "${{ secrets.DEPENDENCY_BUCKET_NAME }}" | ||
| - name: Create Pull Request | ||
| uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7.0.5 | ||
| if: github.event_name != 'pull_request' | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| commit-message: "deps(os): update OS image to run ${{ github.run_id }}" | ||
| title: "deps(os): update OS image" | ||
| body: | | ||
| This PR was automatically created by the [build-os workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}). | ||
|
|
||
| Updates the OS image and rootfs artifacts in: | ||
| - `deps/full-os.conf` (OS images for both architectures) | ||
| - `deps/rootfs.conf` (rootfs for x86-64) | ||
| branch: deps/update-os-image-${{ github.run_id }} | ||
| delete-branch: true | ||
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Cosign binary for image signing | ||
| COSIGN_VERSION=2.6.2-1 | ||
| COSIGN_RELEASE=2.6.2 | ||
| COSIGN_AARCH64_RPM_SHA256_DIGEST=0d7f20ae4edc713e72ad7b1d0b580b41c72c0fa2b1079ecbbf108268f80fc288 | ||
| COSIGN_X86_64_RPM_SHA256_DIGEST=9e7a0f324e2603315349a367d7822c59ba66e228f60abb9d887988118bd08632 |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,9 @@ | ||
| ARTIFACT_BASE_URL=https://deps.runfinch.com | ||
|
|
||
| # From https://dl.fedoraproject.org/pub/fedora/linux/releases/42/Cloud/aarch64/images/ | ||
| AARCH64_ARTIFACT=Fedora-Cloud-Base-Generic-42-1.1.aarch64-20260217220711.qcow2 | ||
| AARCH64_512_DIGEST=dd1d74b0a97ef77ce07981c2b8f415b98a45a3cd206694100df2daa9261db9487425339f55848eec65a6b1657f72cf6012dfdcd80246e61c94d11573d9a8d1a1 | ||
| # built with mkosi | ||
| AARCH64_ARTIFACT=finch-al2023-os-image-arm64-22922664487.qcow2 | ||
| AARCH64_512_DIGEST=49429e07332c79df6cf822d16a10047076db9e8e128601e3730ca5f258f96d44a307aae46466d8cc0d2906b7a61edd4aed5ef5fd7c865164e567e14b85a56dac | ||
|
|
||
| # From https://dl.fedoraproject.org/pub/fedora/linux/releases/42/Cloud/x86_64/images/ | ||
| X86_64_ARTIFACT=Fedora-Cloud-Base-Generic-42-1.1.x86_64-20260217221823.qcow2 | ||
| X86_64_512_DIGEST=4e2da044cb7b1a04c5c25ffd1c62fb07ec352ee1edf4dda64a4f1c3ff08661024df57b4187ea819504885afbfe888b61fbd71d28d75c41ba168b7b691e206f1b | ||
| # built with mkosi | ||
| X86_64_ARTIFACT=finch-al2023-os-image-x86-64-22922664487.qcow2 | ||
| X86_64_512_DIGEST=850fc4677e0974667be5ae8f5a25b0a507e9babf2aac4c25c57747f2cb555d85ffbe475e3069dac62025aa9201aa4cbba44d848d91d867373c0ebc04deb99316 |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [submodule "binfmt"] | ||
| path = binfmt | ||
| url = https://github.com/tonistiigi/binfmt |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.