From 0aaffe561580a9b1aff5f5ee777b24209d8eda99 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sun, 24 May 2020 23:42:40 +0200 Subject: fix nextcloud-update script in respect to custom-image --- roles/apps/collabora/code/tasks/custom-image.yml | 2 ++ roles/apps/nextcloud/tasks/custom-image.yml | 2 ++ .../apps/nextcloud/templates/nextcloud-upgrade.j2 | 22 +++++++++++++++++----- 3 files changed, 21 insertions(+), 5 deletions(-) (limited to 'roles') diff --git a/roles/apps/collabora/code/tasks/custom-image.yml b/roles/apps/collabora/code/tasks/custom-image.yml index 088e9318..9659fd75 100644 --- a/roles/apps/collabora/code/tasks/custom-image.yml +++ b/roles/apps/collabora/code/tasks/custom-image.yml @@ -10,6 +10,7 @@ FROM {{ item.value.custom_image.from | default('collabora/code:' + item.value.version) }} {{ item.value.custom_image.dockerfile }} dest: "{{ collabora_code_base_path }}/{{ item.key }}/build/Dockerfile" + register: nextcloud_custom_image_docker - name: install python-docker apt: @@ -20,6 +21,7 @@ docker_image: name: "collabora/code/{{ item.key }}:{{ item.value.version }}" state: present + force_source: "{{ nextcloud_custom_image_docker is changed }}" source: build build: path: "{{ collabora_code_base_path }}/{{ item.key }}/build" diff --git a/roles/apps/nextcloud/tasks/custom-image.yml b/roles/apps/nextcloud/tasks/custom-image.yml index 23454c80..c7e37654 100644 --- a/roles/apps/nextcloud/tasks/custom-image.yml +++ b/roles/apps/nextcloud/tasks/custom-image.yml @@ -10,6 +10,7 @@ FROM {{ item.value.custom_image.from | default('nextcloud:' + item.value.version) }} {{ item.value.custom_image.dockerfile }} dest: "{{ nextcloud_base_path }}/{{ item.key }}/build/Dockerfile" + register: nextcloud_custom_image_docker - name: install python-docker apt: @@ -20,6 +21,7 @@ docker_image: name: "nextcloud/{{ item.key }}:{{ item.value.version }}" state: present + force_source: "{{ nextcloud_custom_image_docker is changed }}" source: build build: path: "{{ nextcloud_base_path }}/{{ item.key }}/build" diff --git a/roles/apps/nextcloud/templates/nextcloud-upgrade.j2 b/roles/apps/nextcloud/templates/nextcloud-upgrade.j2 index aac5001f..27bc6222 100755 --- a/roles/apps/nextcloud/templates/nextcloud-upgrade.j2 +++ b/roles/apps/nextcloud/templates/nextcloud-upgrade.j2 @@ -22,14 +22,26 @@ function cleanup { } trap cleanup EXIT -echo "*** Pre-Pulling the image" -echo "" -ctr -n k8s.io image pull "docker.io/library/nextcloud:$VERSION" -echo "" +IMAGE_BUILD_D="{{ nextcloud_base_path }}/$INST_NAME/build" +IMAGE_NAME="nextcloud" +if [ -e "$IMAGE_BUILD_D/Dockerfile" ]; then + ## this only works if docker is installed... + echo "*** Building custom image" + echo "" + sed "0,/FROM \(.*\):.*/s//FROM \1:$VERSION/" -i "$IMAGE_BUILD_D/Dockerfile" + IMAGE_NAME="nextcloud/$INST_NAME" + docker build --rm --network host -t "$IMAGE_NAME:$VERSION" "$IMAGE_BUILD_D" + echo "" +else + echo "*** Pre-Pulling the image" + echo "" + crictl pull "docker.io/library/nextcloud:$VERSION" + echo "" +fi echo "*** Patching manifest file" echo "" -sed "s#image: \"nextcloud:.*\"#image: \"nextcloud:$VERSION\"#" "$K8S_MANIFEST_FILE" > "$TMP_D/upgraded.yml" +sed "s#image: \"$IMAGE_NAME:.*\"#image: \"$IMAGE_NAME:$VERSION\"#" "$K8S_MANIFEST_FILE" > "$TMP_D/upgraded.yml" set +e diff -u "$K8S_MANIFEST_FILE" "$TMP_D/upgraded.yml" if [ $? -eq 0 ]; then -- cgit v1.2.3