diff --git a/org.jdrupes.vmoperator.runner.qemu/build.gradle b/org.jdrupes.vmoperator.runner.qemu/build.gradle index 0d83235..362a915 100644 --- a/org.jdrupes.vmoperator.runner.qemu/build.gradle +++ b/org.jdrupes.vmoperator.runner.qemu/build.gradle @@ -32,12 +32,46 @@ application { mainClass = 'org.jdrupes.vmoperator.runner.qemu.Runner' } -distributions { - main { - //distributionBaseName = 'runner-qemu' -// contents { -// from 'src/readme' -// } - } +task buildArchContainer(type: Exec) { + dependsOn installDist + inputs.files 'src/org/jdrupes/vmoperator/runner/qemu/Containerfile.arch' + + commandLine 'podman', 'build', '-t', "${project.name}:${project.version}",\ + '-f', 'src/org/jdrupes/vmoperator/runner/qemu/Containerfile.arch', '.' +} + +task tagArchContainer(type: Exec) { + dependsOn buildArchContainer + + commandLine 'podman', 'tag', "${project.name}:${project.version}",\ + "${project.name}:latest" +} + +task buildContainer { + dependsOn buildArchContainer + dependsOn tagArchContainer +} + +task pushArchContainer(type: Exec) { + dependsOn buildContainer + + commandLine 'podman', 'push', '--tls-verify=false', \ + "localhost/${project.name}:${project.version}", \ + "${project.rootProject.properties['docker.registry']}" \ + + "/vmoperator/${project.name}:${project.version}" +} + +task pushArchContainerAsLatest(type: Exec) { + dependsOn buildContainer + + commandLine 'podman', 'push', '--tls-verify=false', \ + "localhost/${project.name}:${project.version}", \ + "${project.rootProject.properties['docker.registry']}" \ + + "/vmoperator/${project.name}:latest" +} + +task pushContainer { + dependsOn pushArchContainer + dependsOn pushArchContainerAsLatest } diff --git a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/Containerfile.arch b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/Containerfile.arch new file mode 100644 index 0000000..965a87c --- /dev/null +++ b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/Containerfile.arch @@ -0,0 +1,24 @@ +FROM archlinux/archlinux + +RUN systemd-firstboot --setup-machine-id + +RUN pacman -Suy --noconfirm \ + && pacman -S --noconfirm which qemu-base virtiofsd \ + edk2-ovmf swtpm iproute2 bridge-utils jre17-openjdk-headless \ + && pacman -Scc --noconfirm + +# Remove all targets. +RUN (cd /lib/systemd/system/sysinit.target.wants/; \ + for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \ + rm -f /lib/systemd/system/multi-user.target.wants/*;\ + rm -f /etc/systemd/system/*.wants/*;\ + rm -f /lib/systemd/system/local-fs.target.wants/*; \ + rm -f /lib/systemd/system/sockets.target.wants/*udev*; \ + rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \ + rm -f /lib/systemd/system/basic.target.wants/*;\ + rm -f /lib/systemd/system/anaconda.target.wants/*; \ + systemctl set-default multi-user.target + +COPY build/install/vm-runner.qemu /opt/vmrunner + +CMD ["/opt/vmrunner/bin/vm-runner.qemu"]