summaryrefslogtreecommitdiff
path: root/roles
diff options
context:
space:
mode:
Diffstat (limited to 'roles')
-rw-r--r--roles/apps/nextcloud/defaults/main.yml4
-rw-r--r--roles/apps/nextcloud/tasks/custom-image.yml27
-rw-r--r--roles/apps/nextcloud/tasks/main.yml7
-rw-r--r--roles/apps/nextcloud/templates/pod-with-mariadb.yml.j22
4 files changed, 39 insertions, 1 deletions
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 }}