From 582388528675749da3a9f839183a50c794bfad3c Mon Sep 17 00:00:00 2001 From: "andrew.brock" Date: Tue, 11 Jan 2022 10:23:33 +1030 Subject: [PATCH 01/10] Make variable naming consistent. Closes #22 --- Makefile | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index f228f93..2da4b7b 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,10 @@ xnat_version = 1.8.2.2 plugin_container_service_ver = 3.0.0 plugin_ldap_auth_ver = 1.1.0 -plugin_ohif-viewer_ver = 3.0.1 +plugin_ohif_viewer_ver = 3.0.1 plugin_openid_auth_ver = 1.0.2 plugin_xsync_ver = 1.4.0.1 -plugin_batch-launch_ver = 0.4.0 +plugin_batch_launch_ver = 0.4.0 xnat_war = xnat-web-$(xnat_version).war xnat_url = https://github.com/Australian-Imaging-Service/xnat-web/releases/download/release-$(xnat_version)-ais/$(xnat_war) @@ -15,8 +15,8 @@ plugin_container_service_url = https://bitbucket.org/xnatdev/container-service/d plugin_ldap_auth_jar = ldap-auth-plugin-$(plugin_ldap_auth_ver).jar plugin_ldap_auth_url = https://bitbucket.org/xnatx/ldap-auth-plugin/downloads/$(plugin_ldap_auth_jar) -plugin_ohif-viewer_jar = ohif-viewer-$(plugin_ohif-viewer_ver).jar -plugin_ohif-viewer_url = https://bitbucket.org/icrimaginginformatics/ohif-viewer-xnat-plugin/downloads/ohif-viewer-$(plugin_ohif-viewer_ver)-XNAT-1.8.0.jar +plugin_ohif_viewer_jar = ohif-viewer-$(plugin_ohif_viewer_ver).jar +plugin_ohif_viewer_url = https://bitbucket.org/icrimaginginformatics/ohif-viewer-xnat-plugin/downloads/ohif-viewer-$(plugin_ohif_viewer_ver)-XNAT-1.8.0.jar plugin_openid_auth_jar = openid-auth-plugin-$(plugin_openid_auth_ver).jar plugin_openid_auth_url = https://github.com/Australian-Imaging-Service/xnat-openid-auth-plugin/releases/download/$(plugin_openid_auth_ver)/xnat-openid-auth-plugin-all-$(plugin_openid_auth_ver).jar @@ -24,10 +24,10 @@ plugin_openid_auth_url = https://github.com/Australian-Imaging-Service/xnat-open plugin_xsync_jar = xsync-plugin-all-$(plugin_xsync_ver).jar plugin_xsync_url = https://bitbucket.org/xnatdev/xsync/downloads/$(plugin_xsync_jar) -plugin_batch-launch_jar = batch-launch-plugin-$(plugin_batch-launch_ver).jar -plugin_batch-launch_url = https://bitbucket.org/xnatx/xnatx-batch-launch-plugin/downloads/$(plugin_batch_launch_jar) +plugin_batch_launch_jar = batch-launch-plugin-$(plugin_batch_launch_ver).jar +plugin_batch_launch_url = https://bitbucket.org/xnatx/xnatx-batch-launch-plugin/downloads/$(plugin_batch_launch_jar) -plugins = $(plugin_container_service_jar) $(plugin_ldap_auth_jar) $(plugin_openid_auth_jar) $(plugin_ohif-viewer_jar) $(plugin_xsync_jar) $(plugin_batch-launch_jar) +plugins = $(plugin_container_service_jar) $(plugin_ldap_auth_jar) $(plugin_openid_auth_jar) $(plugin_ohif_viewer_jar) $(plugin_xsync_jar) $(plugin_batch_launch_jar) $(xnat_war) : $(plugins) wget --no-verbose -O $(xnat_war) $(xnat_url) @@ -41,14 +41,14 @@ $(plugin_ldap_auth_jar) : $(plugin_openid_auth_jar) : wget --no-verbose -O $(plugin_openid_auth_jar) $(plugin_openid_auth_url) -$(plugin_ohif-viewer_jar) : - wget --no-verbose -O $(plugin_ohif-viewer_jar) $(plugin_ohif-viewer_url) +$(plugin_ohif_viewer_jar) : + wget --no-verbose -O $(plugin_ohif_viewer_jar) $(plugin_ohif_viewer_url) $(plugin_xsync_jar) : wget --no-verbose -O $(plugin_xsync_jar) $(plugin_xsync_url) -$(plugin_batch-launch_jar) : - wget --no-verbose -O ${plugin_batch-launch_jar} $(plugin_batch-launch_url) +$(plugin_batch_launch_jar) : + wget --no-verbose -O $(plugin_batch_launch_jar) $(plugin_batch_launch_url) .PHONY : clean clean : From 89f187831ce106123ffbc9fcd62454aa48005beb Mon Sep 17 00:00:00 2001 From: Dean Taylor Date: Mon, 24 Jan 2022 12:40:04 +0800 Subject: [PATCH 02/10] merge version branch 1.7 --- .github/workflows/packer-build-ci.yml | 6 ++---- xnat-web.pkr.hcl | 8 ++++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/packer-build-ci.yml b/.github/workflows/packer-build-ci.yml index 0d753c0..28f4f65 100644 --- a/.github/workflows/packer-build-ci.yml +++ b/.github/workflows/packer-build-ci.yml @@ -4,14 +4,12 @@ name: Packer build on: push: branches: - - v1.7 - - v1.8 + - main paths: - "**.pkr.hcl" pull_request: branches: - - v1.7 - - v1.8 + - main paths: - "**.pkr.hcl" workflow_dispatch: diff --git a/xnat-web.pkr.hcl b/xnat-web.pkr.hcl index 0e0a574..2ea20a3 100644 --- a/xnat-web.pkr.hcl +++ b/xnat-web.pkr.hcl @@ -31,6 +31,10 @@ variable "docker_image" { default = "tomcat:9.0.46-jdk8-openjdk-buster" type = string } +variable "repository" { + default = "ghcr.io/australian-imaging-service" + type = string +} build { provisioner "shell" { @@ -92,11 +96,11 @@ build { post-processors { post-processor "docker-tag" { - repository = "ghcr.io/australian-imaging-service/${source.name}" + repository = "${var.repository}/${source.name}" tags = ["${var.xnat_version}"] only = ["docker.xnat-web"] } - #post-processor "docker-push" { only = ["docker.xnat-web"]} + #post-processor "docker-push" { only = ["docker.xnat-web"] } } post-processors { post-processor "docker-tag" { From 6c455110f1cfaf72d613771acef5eefa00c116fe Mon Sep 17 00:00:00 2001 From: Dean Taylor Date: Mon, 24 Jan 2022 12:55:50 +0800 Subject: [PATCH 03/10] merge version branch 1.8 --- xnat-web.pkr.hcl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/xnat-web.pkr.hcl b/xnat-web.pkr.hcl index 3e87046..015dd89 100644 --- a/xnat-web.pkr.hcl +++ b/xnat-web.pkr.hcl @@ -124,8 +124,7 @@ source "docker" "xnat-web" { "ENV XNAT_HOME=${var.xnat_home}", "LABEL maintainer=\"Dean Taylor \"", "LABEL org.opencontainers.image.source https://github.com/australian-imaging-service/xnat-build", - "USER ${var.run_as_uid}", - "VOLUME ${var.xnat_root}/archive ${var.xnat_root}/cache ${var.xnat_root}/prearchive ${var.xnat_home}/work" + "USER ${var.run_as_uid}" ] commit = true image = var.docker_image From 20840f8c508389cc7e33c819c63fdcaceff082a7 Mon Sep 17 00:00:00 2001 From: Dean Taylor Date: Thu, 27 Jan 2022 14:48:56 +0800 Subject: [PATCH 04/10] image build workflow run on new tag release and manual only packer build instruction changed to run on entire directory, allows hcl file to be split up as required github workflow uses local registry for temporary storage of images until pushed using tag-push-action to push image and add deployment tags set up with docker metadata-action packer hcl file split variable list into seperate file to unclutter teh build operations change packer instructions to push image. This will work with CI as well as microk8s dev instructions --- .github/workflows/packer-build-ci.yml | 55 +++++++++++++++---------- xnat-web-variables.pkr.hcl | 39 ++++++++++++++++++ xnat-web.pkr.hcl | 58 +++++---------------------- 3 files changed, 83 insertions(+), 69 deletions(-) create mode 100644 xnat-web-variables.pkr.hcl diff --git a/.github/workflows/packer-build-ci.yml b/.github/workflows/packer-build-ci.yml index 28f4f65..c732b17 100644 --- a/.github/workflows/packer-build-ci.yml +++ b/.github/workflows/packer-build-ci.yml @@ -3,37 +3,38 @@ name: Packer build on: push: - branches: - - main - paths: - - "**.pkr.hcl" - pull_request: - branches: - - main - paths: - - "**.pkr.hcl" + tags: + - "v*" workflow_dispatch: env: REGISTRY: ghcr.io +permissions: + contents: read + packages: write + jobs: packer: runs-on: ubuntu-latest - permissions: - contents: read - packages: write - name: packer steps: - - name: Checkout Repository - uses: actions/checkout@v2 + - name: Docker metadata + id: meta + uses: docker/metadata-action@v3 with: - fetch-depth: 0 + images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/xnat-web + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }} + type=sha - name: Log in to the Container registry - uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + uses: docker/login-action@v1 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} @@ -51,13 +52,25 @@ jobs: sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" sudo apt-get -q update && sudo apt-get -yq install packer + - name: Checkout Repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Build Artifacts run: | + # run make instructions if file exists [[ -f Makefile ]] && make - CHANGED_FILES=$(git diff --name-only ${{github.event.before}}..${{github.event.after}} |grep '\.pkr\.hcl$') - for FILE in "${CHANGED_FILES[@]}"; do - packer validate -syntax-only "${FILE}" - [[ $? -eq 0 ]] && packer build -color=false -on-error=abort -only=docker.* "${FILE}" + if packer validate "./"; then + packer build -color=false -on-error=abort -only=docker.xnat-web "./" done env: PACKER_LOG: 1 + + # Push docker image produced by packer with tags + - name: Push docker image + uses: akhilerm/tag-push-action@v2.0.0 + with: + src: localhost:32000/xnat-web:ci + dst: | + ${{ steps.meta.outputs.tags }} diff --git a/xnat-web-variables.pkr.hcl b/xnat-web-variables.pkr.hcl new file mode 100644 index 0000000..0f5308c --- /dev/null +++ b/xnat-web-variables.pkr.hcl @@ -0,0 +1,39 @@ +variable "xnat_version" { + default = "1.8.2.2" + type = string +} +variable "xnat_root" { + default = "/data/xnat" + type = string +} +variable "xnat_home" { + default = "/data/xnat/home" + type = string +} +variable "xnat_plugins" { + default = "/data/xnat/home/plugins" + type = string +} +variable "xnat_plugins_list" { + default = [ + "container-service-3.0.0.jar", + "ldap-auth-plugin-1.1.0.jar", + "ohif-viewer-3.0.1.jar", + "openid-auth-plugin-1.0.2.jar", + "xsync-plugin-all-1.4.0.1.jar", + "batch-launch-plugin-0.4.0.jar" + ] + type = list(string) +} +variable "run_as_uid" { + default = "0" + type = string +} +variable "docker_image" { + default = "tomcat:9.0.46-jdk8-openjdk-buster" + type = string +} +variable "repository" { + default = "ghcr.io/australian-imaging-service" + type = string +} diff --git a/xnat-web.pkr.hcl b/xnat-web.pkr.hcl index 015dd89..db8e025 100644 --- a/xnat-web.pkr.hcl +++ b/xnat-web.pkr.hcl @@ -1,43 +1,7 @@ -variable "xnat_version" { - default = "1.8.2.2" - type = string -} -variable "xnat_root" { - default = "/data/xnat" - type = string -} -variable "xnat_home" { - default = "/data/xnat/home" - type = string -} -variable "xnat_plugins" { - default = "/data/xnat/home/plugins" - type = string -} -variable "xnat_plugins_list" { - default = [ - "container-service-3.0.0.jar", - "ldap-auth-plugin-1.1.0.jar", - "ohif-viewer-3.0.1.jar", - "openid-auth-plugin-1.0.2.jar", - "xsync-plugin-all-1.4.0.1.jar", - "batch-launch-plugin-0.4.0.jar" - ] - type = list(string) -} -variable "run_as_uid" { - default = "0" - type = string -} -variable "docker_image" { - default = "tomcat:9.0.46-jdk8-openjdk-buster" - type = string -} -variable "repository" { - default = "ghcr.io/australian-imaging-service" - type = string -} - +# xnat-build/xnat-web.pkr.hcl +# variables: xnat-build/xnat-web-variables.pkr.hcl +# pre-req.: make +# build { provisioner "shell" { inline = [ @@ -97,17 +61,15 @@ build { } post-processors { + # Do not remove + # repository and ci tag required for CICD pipeline + # used for development; microk8s registery post-processor "docker-tag" { - repository = "${var.repository}/${source.name}" - tags = ["${var.xnat_version}"] + repository = "localhost:32000/${source.name}" + tags = ["${var.xnat_version}","ci"] only = ["docker.xnat-web"] } - #post-processor "docker-push" { only = ["docker.xnat-web"] } - } - post-processors { - post-processor "docker-tag" { - repository = "localhost:32000/${source.name}" - tags = ["${var.xnat_version}"] + post-processor "docker-push" { only = ["docker.xnat-web"] } } From 052ff061eb398d1e7841a4e56396c7ac90b056e0 Mon Sep 17 00:00:00 2001 From: Dean Taylor Date: Thu, 27 Jan 2022 15:29:13 +0800 Subject: [PATCH 05/10] fix workflow syntax error --- .github/workflows/packer-build-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/packer-build-ci.yml b/.github/workflows/packer-build-ci.yml index c732b17..b92102c 100644 --- a/.github/workflows/packer-build-ci.yml +++ b/.github/workflows/packer-build-ci.yml @@ -63,7 +63,7 @@ jobs: [[ -f Makefile ]] && make if packer validate "./"; then packer build -color=false -on-error=abort -only=docker.xnat-web "./" - done + fi env: PACKER_LOG: 1 From 48de7cbd86aec5c5536ef061e59ee6b23f795be4 Mon Sep 17 00:00:00 2001 From: Dean Taylor Date: Thu, 27 Jan 2022 15:43:19 +0800 Subject: [PATCH 06/10] added workflow docker registry service --- .github/workflows/packer-build-ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/packer-build-ci.yml b/.github/workflows/packer-build-ci.yml index b92102c..2336c46 100644 --- a/.github/workflows/packer-build-ci.yml +++ b/.github/workflows/packer-build-ci.yml @@ -19,6 +19,13 @@ jobs: runs-on: ubuntu-latest name: packer + services: + registry: + image: registry:2 + ports: + - 5000:5000 + - 32000:5000 + steps: - name: Docker metadata id: meta From ffb4993df81bcbac831084be57df9a24044db70c Mon Sep 17 00:00:00 2001 From: Andrew Brock <70552043+andrewbrock-sahmri@users.noreply.github.com> Date: Tue, 1 Feb 2022 09:26:01 +1030 Subject: [PATCH 07/10] Update build instructions to reflect recent packer changes --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 0b212c1..2130612 100644 --- a/README.md +++ b/README.md @@ -5,14 +5,14 @@ $ make # Build all images -$ packer build xnat-web.pkr.hcl +$ packer build . # Build an individual image -$ packer build -only docker.xnat17 xnat-web.pkr.hcl +$ packer build -only docker.xnat-web . # Build all docker images -$ packer build -only docker.* xnat-web.pkr.hcl -``` +$ packer build -only docker.* . -Reference: -* https://bitbucket.org/xnatdev/container-service/downloads/ +# Build the xnat-web docker image with an overridden uid +$ packer build -var "run_as_uid=997" -only docker.xnat-web . +``` From af3de5d945b99c51ac504364376b4baccafcfa69 Mon Sep 17 00:00:00 2001 From: "andrew.brock" Date: Tue, 1 Feb 2022 10:10:59 +1030 Subject: [PATCH 08/10] Allow override of destination Docker registry --- xnat-web-variables.pkr.hcl | 3 ++- xnat-web.pkr.hcl | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/xnat-web-variables.pkr.hcl b/xnat-web-variables.pkr.hcl index 0f5308c..6d67eba 100644 --- a/xnat-web-variables.pkr.hcl +++ b/xnat-web-variables.pkr.hcl @@ -34,6 +34,7 @@ variable "docker_image" { type = string } variable "repository" { - default = "ghcr.io/australian-imaging-service" + # Do not change default - required for CI/CD pipeline + default = "localhost:32000" type = string } diff --git a/xnat-web.pkr.hcl b/xnat-web.pkr.hcl index db8e025..7501dbd 100644 --- a/xnat-web.pkr.hcl +++ b/xnat-web.pkr.hcl @@ -61,11 +61,10 @@ build { } post-processors { - # Do not remove - # repository and ci tag required for CICD pipeline - # used for development; microk8s registery + # Do not remove ci tag - required for CICD pipeline + # used for development; microk8s registry post-processor "docker-tag" { - repository = "localhost:32000/${source.name}" + repository = "${var.repository}/${source.name}" tags = ["${var.xnat_version}","ci"] only = ["docker.xnat-web"] } From 8b952beec43652624d4d3c20727d3a308cb7b484 Mon Sep 17 00:00:00 2001 From: Fang Xu Date: Sat, 14 May 2022 16:29:40 +1000 Subject: [PATCH 09/10] upgrade tomcat base image; rm postgresql client --- xnat-web-variables.pkr.hcl | 2 +- xnat-web.pkr.hcl | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/xnat-web-variables.pkr.hcl b/xnat-web-variables.pkr.hcl index 6d67eba..52e7386 100644 --- a/xnat-web-variables.pkr.hcl +++ b/xnat-web-variables.pkr.hcl @@ -30,7 +30,7 @@ variable "run_as_uid" { type = string } variable "docker_image" { - default = "tomcat:9.0.46-jdk8-openjdk-buster" + default = "tomcat:9.0.62-jdk8-openjdk-bullseye" type = string } variable "repository" { diff --git a/xnat-web.pkr.hcl b/xnat-web.pkr.hcl index 7501dbd..c19d5a7 100644 --- a/xnat-web.pkr.hcl +++ b/xnat-web.pkr.hcl @@ -45,7 +45,6 @@ build { provisioner "shell" { inline = [ "apt-get update", - "apt-get -y install postgresql-client", "rm -rf $${CATALINA_HOME}/webapps/*", "unzip -o -d $${CATALINA_HOME}/webapps/ROOT /tmp/xnat-web-*.war", "sed -i 's/ch.qos.logback.core.rolling.RollingFileAppender/ch.qos.logback.core.ConsoleAppender/' $${CATALINA_HOME}/webapps/ROOT/WEB-INF/classes/logback.xml", From 835d91e2e3a097041546c1a18fd1b64cc57637a8 Mon Sep 17 00:00:00 2001 From: fxusyd <54692384+fxusyd@users.noreply.github.com> Date: Wed, 8 Jun 2022 10:10:42 +1000 Subject: [PATCH 10/10] xnat build v1.8.4.1 (#30) * upgrade tomcat base image; rm postgresql client * upgrade xnat to v1.8.4.1, also upgrade ohif viewer plugin, container plugin, batch launcher plugin * upgrade xnat to v1.8.4.1, also upgrade ohif viewer plugin, container plugin, batch launcher plugin * removed commented lines * Update Makefile use the latest built from the upstream commit * Update xnat-web-variables.pkr.hcl use latest build of openid plugin from upstream --- Makefile | 14 +++++++------- xnat-web-variables.pkr.hcl | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 2da4b7b..1ce3f80 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,13 @@ -xnat_version = 1.8.2.2 -plugin_container_service_ver = 3.0.0 +xnat_version = 1.8.4.1 +plugin_container_service_ver = 3.1.1 plugin_ldap_auth_ver = 1.1.0 -plugin_ohif_viewer_ver = 3.0.1 -plugin_openid_auth_ver = 1.0.2 +plugin_ohif_viewer_ver = 3.2.0 +plugin_openid_auth_ver = 1.2.0-SNAPSHOT plugin_xsync_ver = 1.4.0.1 -plugin_batch_launch_ver = 0.4.0 +plugin_batch_launch_ver = 0.5.0 xnat_war = xnat-web-$(xnat_version).war -xnat_url = https://github.com/Australian-Imaging-Service/xnat-web/releases/download/release-$(xnat_version)-ais/$(xnat_war) +xnat_url = https://bitbucket.org/xnatdev/xnat-web/downloads/$(xnat_war) plugin_container_service_jar = container-service-$(plugin_container_service_ver).jar plugin_container_service_url = https://bitbucket.org/xnatdev/container-service/downloads/container-service-$(plugin_container_service_ver)-fat.jar @@ -19,7 +19,7 @@ plugin_ohif_viewer_jar = ohif-viewer-$(plugin_ohif_viewer_ver).jar plugin_ohif_viewer_url = https://bitbucket.org/icrimaginginformatics/ohif-viewer-xnat-plugin/downloads/ohif-viewer-$(plugin_ohif_viewer_ver)-XNAT-1.8.0.jar plugin_openid_auth_jar = openid-auth-plugin-$(plugin_openid_auth_ver).jar -plugin_openid_auth_url = https://github.com/Australian-Imaging-Service/xnat-openid-auth-plugin/releases/download/$(plugin_openid_auth_ver)/xnat-openid-auth-plugin-all-$(plugin_openid_auth_ver).jar +plugin_openid_auth_url = https://github.com/Australian-Imaging-Service/openid-auth-plugin/releases/download/$(plugin_openid_auth_ver)/openid-auth-plugin-$(plugin_openid_auth_ver).jar plugin_xsync_jar = xsync-plugin-all-$(plugin_xsync_ver).jar plugin_xsync_url = https://bitbucket.org/xnatdev/xsync/downloads/$(plugin_xsync_jar) diff --git a/xnat-web-variables.pkr.hcl b/xnat-web-variables.pkr.hcl index 52e7386..cf0cf7f 100644 --- a/xnat-web-variables.pkr.hcl +++ b/xnat-web-variables.pkr.hcl @@ -1,5 +1,5 @@ variable "xnat_version" { - default = "1.8.2.2" + default = "1.8.4.1" type = string } variable "xnat_root" { @@ -16,12 +16,12 @@ variable "xnat_plugins" { } variable "xnat_plugins_list" { default = [ - "container-service-3.0.0.jar", + "container-service-3.1.1.jar", "ldap-auth-plugin-1.1.0.jar", - "ohif-viewer-3.0.1.jar", - "openid-auth-plugin-1.0.2.jar", + "ohif-viewer-3.2.0.jar", + "openid-auth-plugin-1.2.0-SNAPSHOT.jar", "xsync-plugin-all-1.4.0.1.jar", - "batch-launch-plugin-0.4.0.jar" + "batch-launch-plugin-0.5.0.jar" ] type = list(string) }