From 28691b64439588de1201f460760b1428e2c19399 Mon Sep 17 00:00:00 2001 From: "Michael N. Lipp" Date: Sat, 22 Jun 2024 16:06:31 +0200 Subject: [PATCH 1/8] Make dependencies branch specific. --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a8673aa..740fd8f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,7 +12,7 @@ stages: extends: .any-job image: registry.mnl.de/org/jgrapes/jdk21-builder:v2 cache: - - key: dependencies + - key: dependencies-CI_COMMIT_BRANCH policy: pull-push paths: - .gradle From e830815400fbff6ab0e6558eaaf813b9ff41fd0f Mon Sep 17 00:00:00 2001 From: "Michael N. Lipp" Date: Sat, 22 Jun 2024 23:03:28 +0200 Subject: [PATCH 2/8] Add dependency. --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 740fd8f..62a51fb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -37,6 +37,8 @@ build-jars: publish-images: stage: publish extends: .gradle-job + dependencies: + - build-jars script: - ./gradlew -Pdocker.registry=$CI_REGISTRY_IMAGE pushImage From 12ca211fdba91a625cbc69402672864cef8cb1e2 Mon Sep 17 00:00:00 2001 From: "Michael N. Lipp" Date: Sun, 23 Jun 2024 11:25:19 +0200 Subject: [PATCH 3/8] Fix env reference. --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 62a51fb..13b12fd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,7 +12,7 @@ stages: extends: .any-job image: registry.mnl.de/org/jgrapes/jdk21-builder:v2 cache: - - key: dependencies-CI_COMMIT_BRANCH + - key: dependencies-${CI_COMMIT_BRANCH} policy: pull-push paths: - .gradle From 7df0cc386ccdc0960e55ca5782bfbe98b722685c Mon Sep 17 00:00:00 2001 From: "Michael N. Lipp" Date: Sun, 23 Jun 2024 12:52:18 +0200 Subject: [PATCH 4/8] Fix image building. --- .github/workflows/release.yml | 2 +- .gitlab-ci.yml | 2 +- org.jdrupes.vmoperator.manager/build.gradle | 35 +++++---- .../build.gradle | 75 ++++++++++--------- spice-squid/build.gradle | 56 ++++++-------- 5 files changed, 86 insertions(+), 84 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 161b7c8..beab0c4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,4 +37,4 @@ jobs: java-version: '21' distribution: 'temurin' - name: Push with Gradle - run: ./gradlew -Pwebsite.push.token=${{ secrets.WEBSITE_PUSH_TOKEN }} -Pdocker.registry=ghcr.io/${{ github.actor }} stage pushImages + run: ./gradlew -Pwebsite.push.token=${{ secrets.WEBSITE_PUSH_TOKEN }} -Pdocker.registry=ghcr.io/${{ github.actor }} stage publishImage diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 13b12fd..04acdec 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -40,7 +40,7 @@ publish-images: dependencies: - build-jars script: - - ./gradlew -Pdocker.registry=$CI_REGISTRY_IMAGE pushImage + - ./gradlew -Pdocker.registry=$CI_REGISTRY_IMAGE publishImage .pages-job: extends: .any-job diff --git a/org.jdrupes.vmoperator.manager/build.gradle b/org.jdrupes.vmoperator.manager/build.gradle index a956a00..45d9494 100644 --- a/org.jdrupes.vmoperator.manager/build.gradle +++ b/org.jdrupes.vmoperator.manager/build.gradle @@ -46,6 +46,7 @@ application { } project.ext.gitBranch = grgit.branch.current.name.replace('/', '-') +def registry = "${project.rootProject.properties['docker.registry']}" task buildImage(type: Exec) { dependsOn installDist @@ -61,20 +62,23 @@ task pushImage(type: Exec) { // Don't push without testing first dependsOn test - def registry = "${project.rootProject.properties['docker.registry']}" commandLine 'podman', 'push', '--tls-verify=false', \ - "localhost/${project.name}:${project.gitBranch}", \ + "${project.name}:${project.gitBranch}", \ "${registry}/${project.name}:${project.gitBranch}" - - if (!project.version.contains("SNAPSHOT")) { - commandLine 'podman', 'tag', \ - "${registry}/${project.name}:${project.gitBranch}",\ - "${registry}/${project.name}:${project.version}" - } +} + +task tagWithVersion(type: Exec) { + dependsOn pushImage + + enabled = !project.version.contains("SNAPSHOT") + + commandLine 'podman', 'push', \ + "${project.name}:${project.gitBranch}",\ + "${registry}/${project.name}:${project.version}" } task tagAsLatest(type: Exec) { - dependsOn pushImage + dependsOn tagWithVersion enabled = !project.version.contains("SNAPSHOT") && !project.version.contains("alpha") \ @@ -83,17 +87,22 @@ task tagAsLatest(type: Exec) { && project.rootProject.properties['docker.registry'] \ == project.rootProject.properties['docker.testRegistry'] - def registry = "${project.rootProject.properties['docker.registry']}" - commandLine 'podman', 'tag', \ - "${registry}/${project.name}:${project.version}",\ + commandLine 'podman', 'push', \ + "${project.name}:${project.gitBranch}",\ "${registry}/${project.name}:latest" } +task publishImage { + dependsOn pushImage + dependsOn tagWithVersion + dependsOn tagAsLatest +} + task pushForTest(type: Exec) { dependsOn buildImage commandLine 'podman', 'push', '--tls-verify=false', \ - "localhost/${project.name}:${project.gitBranch}", \ + "${project.name}:${project.gitBranch}", \ "${project.rootProject.properties['docker.testRegistry']}" \ + "/${project.name}:test" } diff --git a/org.jdrupes.vmoperator.runner.qemu/build.gradle b/org.jdrupes.vmoperator.runner.qemu/build.gradle index 00bf7ea..8cea1ae 100644 --- a/org.jdrupes.vmoperator.runner.qemu/build.gradle +++ b/org.jdrupes.vmoperator.runner.qemu/build.gradle @@ -32,8 +32,9 @@ application { } project.ext.gitBranch = grgit.branch.current.name.replace('/', '-') +def registry = "${project.rootProject.properties['docker.registry']}" -task buildArchImage(type: Exec) { +task buildImageArch(type: Exec) { dependsOn installDist inputs.files 'src/org/jdrupes/vmoperator/runner/qemu/Containerfile.arch' @@ -42,23 +43,26 @@ task buildArchImage(type: Exec) { '-f', 'src/org/jdrupes/vmoperator/runner/qemu/Containerfile.arch', '.' } -task pushArchImage(type: Exec) { - dependsOn buildArchImage +task pushImageArch(type: Exec) { + dependsOn buildImageArch - def registry = "${project.rootProject.properties['docker.registry']}" commandLine 'podman', 'push', '--tls-verify=false', \ - "localhost/${project.name}-arch:${project.gitBranch}", \ + "${project.name}-arch:${project.gitBranch}", \ "${registry}/${project.name}-arch:${project.gitBranch}" - - if (!project.version.contains("SNAPSHOT")) { - commandLine 'podman', 'tag', \ - "${registry}/${project.name}-arch:${project.gitBranch}",\ - "${registry}/${project.name}-arch:${project.version}" - } +} + +task tagWithVersionArch(type: Exec) { + dependsOn pushImageArch + + enabled = !project.version.contains("SNAPSHOT") + + commandLine 'podman', 'push', \ + "${project.name}-arch:${project.gitBranch}",\ + "${registry}/${project.name}-arch:${project.version}" } task tagAsLatestArch(type: Exec) { - dependsOn pushArchImage + dependsOn tagWithVersionArch enabled = !project.version.contains("SNAPSHOT") && !project.version.contains("alpha") \ @@ -67,13 +71,12 @@ task tagAsLatestArch(type: Exec) { && project.rootProject.properties['docker.registry'] \ == project.rootProject.properties['docker.testRegistry'] - def registry = "${project.rootProject.properties['docker.registry']}" - commandLine 'podman', 'tag', \ - "${registry}/${project.name}-arch:${project.version}",\ + commandLine 'podman', 'push', \ + "${project.name}-arch:${project.gitBranch}",\ "${registry}/${project.name}-arch:latest" } -task buildAlpineImage(type: Exec) { +task buildImageAlpine(type: Exec) { dependsOn installDist inputs.files 'src/org/jdrupes/vmoperator/runner/qemu/Containerfile.alpine' @@ -82,23 +85,26 @@ task buildAlpineImage(type: Exec) { '-f', 'src/org/jdrupes/vmoperator/runner/qemu/Containerfile.alpine', '.' } -task pushAlpineImage(type: Exec) { - dependsOn buildAlpineImage +task pushImageAlpine(type: Exec) { + dependsOn buildImageAlpine - def registry = "${project.rootProject.properties['docker.registry']}" commandLine 'podman', 'push', '--tls-verify=false', \ "localhost/${project.name}-alpine:${project.gitBranch}", \ "${registry}/${project.name}-alpine:${project.gitBranch}" - - if (!project.version.contains("SNAPSHOT")) { - commandLine 'podman', 'tag', \ - "${registry}/${project.name}-alpine:${project.gitBranch}",\ - "${registry}/${project.name}-alpine:${project.version}" - } +} + +task tagWithVersionAlpine(type: Exec) { + dependsOn pushImageAlpine + + enabled = !project.version.contains("SNAPSHOT") + + commandLine 'podman', 'push', \ + "${project.name}-alpine:${project.gitBranch}",\ + "${registry}/${project.name}-alpine:${project.version}" } task tagAsLatestAlpine(type: Exec) { - dependsOn pushAlpineImage + dependsOn tagWithVersionAlpine enabled = !project.version.contains("SNAPSHOT") && !project.version.contains("alpha") \ @@ -107,19 +113,16 @@ task tagAsLatestAlpine(type: Exec) { && project.rootProject.properties['docker.registry'] \ == project.rootProject.properties['docker.testRegistry'] - def registry = "${project.rootProject.properties['docker.registry']}" - commandLine 'podman', 'tag', \ - "${registry}/${project.name}-alpine:${project.version}",\ + commandLine 'podman', 'push', \ + "${project.name}-alpine:${project.gitBranch}",\ "${registry}/${project.name}-alpine:latest" } -task pushImage { - dependsOn pushArchImage - dependsOn pushAlpineImage -} - -task tagAsLatest { +task publishImage { + dependsOn pushImageArch + dependsOn tagWithVersionArch dependsOn tagAsLatestArch + dependsOn pushImageAlpine + dependsOn tagWithVersionAlpine dependsOn tagAsLatestAlpine } - diff --git a/spice-squid/build.gradle b/spice-squid/build.gradle index 2cb7183..e7ccd00 100644 --- a/spice-squid/build.gradle +++ b/spice-squid/build.gradle @@ -5,44 +5,36 @@ plugins { dependencies { } +project.ext.gitBranch = grgit.branch.current.name.replace('/', '-') +def registry = "${project.rootProject.properties['docker.registry']}" + task buildImage(type: Exec) { inputs.files 'Containerfile' commandLine 'podman', 'build', '--pull', - '-t', "${project.name}:${project.version}",\ + '-t', "${project.name}:${project.gitBranch}",\ '-f', 'Containerfile', '.' } -task tagLatestImage(type: Exec) { - dependsOn buildImage - - enabled = !project.version.contains("SNAPSHOT") - && !project.version.contains("alpha") \ - && !project.version.contains("beta") \ - || project.rootProject.properties['docker.testRegistry'] \ - && project.rootProject.properties['docker.registry'] \ - == project.rootProject.properties['docker.testRegistry'] - - commandLine 'podman', 'tag', "${project.name}:${project.version}",\ - "${project.name}:latest" -} - -task buildLatestImage { - dependsOn buildImage - dependsOn tagLatestImage -} - task pushImage(type: Exec) { dependsOn buildImage commandLine 'podman', 'push', '--tls-verify=false', \ - "localhost/${project.name}:${project.version}", \ - "${project.rootProject.properties['docker.registry']}" \ - + "/${project.name}:${project.version}" + "${project.name}:${project.gitBranch}", \ + "${registry}/${project.name}:${project.gitBranch}" +} +task tagWithVersion(type: Exec) { + dependsOn pushImage + + enabled = !project.version.contains("SNAPSHOT") + + commandLine 'podman', 'push', \ + "${project.name}:${project.gitBranch}",\ + "${registry}/${project.name}:${project.version}" } -task pushLatestImage(type: Exec) { - dependsOn buildLatestImage +task tagAsLatest(type: Exec) { + dependsOn tagWithVersion enabled = !project.version.contains("SNAPSHOT") && !project.version.contains("alpha") \ @@ -51,18 +43,16 @@ task pushLatestImage(type: Exec) { && project.rootProject.properties['docker.registry'] \ == project.rootProject.properties['docker.testRegistry'] - commandLine 'podman', 'push', '--tls-verify=false', \ - "localhost/${project.name}:${project.version}", \ - "${project.rootProject.properties['docker.registry']}" \ - + "/${project.name}:latest" + commandLine 'podman', 'push', \ + "${project.name}:${project.gitBranch}",\ + "${registry}/${project.name}:latest" } -task pushImages { - // Don't push without testing first +task publishImage { dependsOn pushImage - dependsOn pushLatestImage + dependsOn tagWithVersion + dependsOn tagAsLatest } - test { enabled = project.hasProperty("k8s.testCluster") From 8b83a0cbc8bb5001ea3755f6dc3e5d5ed4886d01 Mon Sep 17 00:00:00 2001 From: "Michael N. Lipp" Date: Sun, 23 Jun 2024 17:02:44 +0200 Subject: [PATCH 5/8] Make sure to switch to branch. --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 04acdec..84d99d7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,7 +24,7 @@ stages: - "*/build" before_script: - echo -n $CI_REGISTRY_PASSWORD | podman login -u "$CI_REGISTRY_USER" --password-stdin $CI_REGISTRY - - git switch $CI_COMMIT_REF_NAME + - git switch $CI_COMMIT_BRANCH - git pull - git reset --hard $CI_COMMIT_SHA From e994fa154333af1d27f951e339d77ce2a6fcf690 Mon Sep 17 00:00:00 2001 From: "Michael N. Lipp" Date: Sun, 23 Jun 2024 21:41:00 +0200 Subject: [PATCH 6/8] Another attempt to find the branch. --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 84d99d7..9a07e7c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,7 +24,7 @@ stages: - "*/build" before_script: - echo -n $CI_REGISTRY_PASSWORD | podman login -u "$CI_REGISTRY_USER" --password-stdin $CI_REGISTRY - - git switch $CI_COMMIT_BRANCH + - git switch $(git branch -r --contains $CI_COMMIT_SHA | sed -e 's#[^/]*/##') - git pull - git reset --hard $CI_COMMIT_SHA From 8a434d8410e096d6efeee6b4dc083003224e14a7 Mon Sep 17 00:00:00 2001 From: "Michael N. Lipp" Date: Mon, 24 Jun 2024 10:04:09 +0200 Subject: [PATCH 7/8] Use newest branch if we have multiple matches. --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9a07e7c..7dff899 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,7 +24,7 @@ stages: - "*/build" before_script: - echo -n $CI_REGISTRY_PASSWORD | podman login -u "$CI_REGISTRY_USER" --password-stdin $CI_REGISTRY - - git switch $(git branch -r --contains $CI_COMMIT_SHA | sed -e 's#[^/]*/##') + - git switch $(git branch -r --sort="authordate" --contains $CI_COMMIT_SHA | head -1 | sed -e 's#[^/]*/##') - git pull - git reset --hard $CI_COMMIT_SHA From fc29786afe6d0234e08350597563604fa6fc3316 Mon Sep 17 00:00:00 2001 From: "Michael N. Lipp" Date: Mon, 24 Jun 2024 11:18:35 +0200 Subject: [PATCH 8/8] Fix links. --- webpages/vm-operator/index.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/webpages/vm-operator/index.md b/webpages/vm-operator/index.md index 04134d5..232a9ce 100644 --- a/webpages/vm-operator/index.md +++ b/webpages/vm-operator/index.md @@ -11,15 +11,15 @@ based VMs in Kubernetes pods. The image used for the VM pods combines Qemu and a control program for starting and managing the Qemu process. This application is called -"[the runner](runner.md)". +"[the runner](runner.html)". While you can deploy a runner manually (or with the help of some -helm templates), the preferred way is to deploy "[the manager](manager.md)" +helm templates), the preferred way is to deploy "[the manager](manager.html)" application which acts as a Kubernetes operator for runners and thus the VMs. If you just want to try out things, you can skip the remainder of this -page and proceed to "[the manager](manager.md)". +page and proceed to "[the manager](manager.html)". ## Motivation The project was triggered by a remark in the discussion about RedHat