From e758dcb05cd4d2d965205d7f8e6a4bf3d6630163 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sun, 24 May 2020 19:55:50 +0200 Subject: add support for nextcloud custom images --- roles/apps/nextcloud/defaults/main.yml | 4 ++++ roles/apps/nextcloud/tasks/custom-image.yml | 27 ++++++++++++++++++++++ roles/apps/nextcloud/tasks/main.yml | 7 ++++++ .../nextcloud/templates/pod-with-mariadb.yml.j2 | 2 +- 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 roles/apps/nextcloud/tasks/custom-image.yml (limited to 'roles') diff --git a/roles/apps/nextcloud/defaults/main.yml b/roles/apps/nextcloud/defaults/main.yml index 16637f44..261f4fa6 100644 --- a/roles/apps/nextcloud/defaults/main.yml +++ b/roles/apps/nextcloud/defaults/main.yml @@ -25,3 +25,7 @@ nextcloud_db_gid: "951" # type: mariadb # version: 10.4.8 # password: "{{ vault_nextcloud_database_passwords['example'] }}" +# custom_image: # optional +# from: foo/bar:1.0 # optional +# dockerfile: | +# RUN apt-get install ... diff --git a/roles/apps/nextcloud/tasks/custom-image.yml b/roles/apps/nextcloud/tasks/custom-image.yml new file mode 100644 index 00000000..23454c80 --- /dev/null +++ b/roles/apps/nextcloud/tasks/custom-image.yml @@ -0,0 +1,27 @@ +--- +- name: create build directory for custom image + file: + path: "{{ nextcloud_base_path }}/{{ item.key }}/build" + state: directory + +- name: generate Dockerfile for custom image + copy: + content: | + FROM {{ item.value.custom_image.from | default('nextcloud:' + item.value.version) }} + {{ item.value.custom_image.dockerfile }} + dest: "{{ nextcloud_base_path }}/{{ item.key }}/build/Dockerfile" + +- name: install python-docker + apt: + name: python-docker + state: present + +- name: build custom image + docker_image: + name: "nextcloud/{{ item.key }}:{{ item.value.version }}" + state: present + source: build + build: + path: "{{ nextcloud_base_path }}/{{ item.key }}/build" + network: host + pull: yes diff --git a/roles/apps/nextcloud/tasks/main.yml b/roles/apps/nextcloud/tasks/main.yml index 68e9dc78..1a17bb55 100644 --- a/roles/apps/nextcloud/tasks/main.yml +++ b/roles/apps/nextcloud/tasks/main.yml @@ -97,6 +97,13 @@ dest: "{{ nextcloud_base_path }}/{{ item }}/config/ports.conf" +- name: build custom image + loop: "{{ nextcloud_instances | dict2items }}" + loop_control: + label: "{{ item.key }}" + when: "'custom_image' in item.value" + include_tasks: custom-image.yml + - name: generate pod manifests loop: "{{ nextcloud_instances | dict2items }}" loop_control: diff --git a/roles/apps/nextcloud/templates/pod-with-mariadb.yml.j2 b/roles/apps/nextcloud/templates/pod-with-mariadb.yml.j2 index 72f8cb7a..20752490 100644 --- a/roles/apps/nextcloud/templates/pod-with-mariadb.yml.j2 +++ b/roles/apps/nextcloud/templates/pod-with-mariadb.yml.j2 @@ -7,7 +7,7 @@ spec: allowPrivilegeEscalation: false containers: - name: nextcloud - image: "nextcloud:{{ item.value.version }}" + image: "nextcloud{% if 'custom_image' in item.value %}/{{ item.key }}{% endif %}:{{ item.value.version }}" securityContext: runAsUser: {{ nextcloud_app_uid }} runAsGroup: {{ nextcloud_app_gid }} -- cgit v1.2.3