Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 115 additions & 0 deletions .github/workflows/build-qemu-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Build and Push Qemu App Toolbox
on:
pull_request:
merge_group:
workflow_dispatch:
permissions: {}

env:
IMAGE_NAME: qemu-box
IMAGE_TAGS: latest
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }}

concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true

jobs:
push-ghcr:
name: Build and push image
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
id-token: write
strategy:
fail-fast: false
steps:
# Checkout push-to-registry action GitHub repository
- name: Checkout Push to Registry action
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Verify Ublue-OS Ubuntu toolbox
uses: EyeCantCU/cosign-action/verify@58722a084c82190b57863002d494c91eabbe9e79 # v0.3.0
with:
containers: ubuntu-toolbox:latest
pubkey: https://raw.githubusercontent.com/ublue-os/toolboxes/main/cosign.pub
registry: ghcr.io/ublue-os

# Build metadata
- name: Image Metadata
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0
id: meta
with:
images: |
${{ env.IMAGE_NAME }}
labels: |
io.artifacthub.package.readme-url=https://raw.githubusercontent.com/ublue-os/boxkit/main/README.md

# Build image using Buildah action
- name: Build Image
id: build_image
uses: redhat-actions/buildah-build@7a95fa7ee0f02d552a32753e7414641a04307056 # v2
with:
containerfiles: |
./apps/qemu/Containerfile.qemu
image: ${{ env.IMAGE_NAME }}
tags: ${{ env.IMAGE_TAGS }}
labels: ${{ steps.meta.outputs.labels }}
oci: false

# Workaround bug where capital letters in your GitHub username make it impossible to push to GHCR.
# https://github.com/macbre/push-to-ghcr/issues/12
- name: Lowercase Registry
id: registry_case
uses: ASzc/change-string-case-action@d0603cd0a7dd490be678164909f65c7737470a7f # v6
with:
string: ${{ env.IMAGE_REGISTRY }}

# Push the image to GHCR (Image Registry)
- name: Push To GHCR
uses: redhat-actions/push-to-registry@5ed88d269cf581ea9ef6dd6806d01562096bee9c # v2
if: github.event_name != 'pull_request'
id: push
env:
REGISTRY_USER: ${{ github.actor }}
REGISTRY_PASSWORD: ${{ github.token }}
with:
image: ${{ steps.build_image.outputs.image }}
tags: ${{ steps.build_image.outputs.tags }}
registry: ${{ steps.registry_case.outputs.lowercase }}
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }}
extra-args: |
--compression-format=zstd:chunked

- name: Login to GitHub Container Registry
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
if: github.event_name != 'pull_request'
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Sign container
- uses: sigstore/cosign-installer@ba7bc0a3fef59531c69a25acd34668d6d3fe6f22 # v4.1.0
if: github.event_name != 'pull_request'
with:
cosign-release: "v2.6.1"

- name: Sign container image
if: github.event_name != 'pull_request'
run: |
echo "${{ env.COSIGN_PRIVATE_KEY }}" > cosign.key
wc -c cosign.key
cosign sign -y --key cosign.key ${{ steps.registry_case.outputs.lowercase }}/${{ env.IMAGE_NAME }}@${TAGS}
env:
TAGS: ${{ steps.push.outputs.digest }}
COSIGN_EXPERIMENTAL: false
COSIGN_PRIVATE_KEY: ${{ secrets.SIGNING_SECRET }}

- name: Echo outputs
env:
BUILD_IMAGE_OUTPUTS: ${{ toJSON(steps.build_image.outputs) }}
run: |
echo "$BUILD_IMAGE_OUTPUTS"
24 changes: 24 additions & 0 deletions apps/qemu/Containerfile.qemu
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM ubuntu:resolute

RUN apt-get update && apt-get install -y \
qemu-system-x86 \
qemu-system-arm \
qemu-system-riscv \
qemu-system-modules-opengl \
qemu-system-modules-spice \
qemu-system-misc \
swtpm \
libvirt-daemon-system \
libvirt-clients \
libegl1

RUN rm -f /etc/libvirt/qemu/networks/autostart/default.xml && \
rm -f /etc/libvirt/qemu/networks/default.xml

RUN echo 'user = "root"' >> /etc/libvirt/qemu.conf && \
echo 'group = "root"' >> /etc/libvirt/qemu.conf && \
echo 'swtpm_user = "root"' >> /etc/libvirt/qemu.conf && \
echo 'swtpm_group = "root"' >> /etc/libvirt/qemu.conf

RUN echo 'unix_sock_group = "root"' >> /etc/libvirt/libvirtd.conf && \
echo 'unix_sock_rw_perms = "0770"' >> /etc/libvirt/libvirtd.conf