From 841fbea3dbdbf5eb877b046bc5e965330ba61cc1 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sun, 24 May 2020 19:12:00 +0200 Subject: custom image support for collabora code --- roles/apps/collabora/code/defaults/main.yml | 6 ++++++ roles/apps/collabora/code/tasks/custom-image.yml | 27 ++++++++++++++++++++++++ roles/apps/collabora/code/tasks/main.yml | 7 ++++++ roles/apps/collabora/code/templates/pod.yml.j2 | 2 +- 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 roles/apps/collabora/code/tasks/custom-image.yml (limited to 'roles') diff --git a/roles/apps/collabora/code/defaults/main.yml b/roles/apps/collabora/code/defaults/main.yml index 2f025db5..2f93cf88 100644 --- a/roles/apps/collabora/code/defaults/main.yml +++ b/roles/apps/collabora/code/defaults/main.yml @@ -11,3 +11,9 @@ collabora_code_base_path: /srv/collabora/code # password: S3cret # backend_storages: # - cloud.example.com +# custom_image: # optional +# from: foo/bar:1.0 # optional +# dockerfile: | +# USER root +# RUN apt-get install ... +# USER 101 diff --git a/roles/apps/collabora/code/tasks/custom-image.yml b/roles/apps/collabora/code/tasks/custom-image.yml new file mode 100644 index 00000000..088e9318 --- /dev/null +++ b/roles/apps/collabora/code/tasks/custom-image.yml @@ -0,0 +1,27 @@ +--- +- name: create build directory for custom image + file: + path: "{{ collabora_code_base_path }}/{{ item.key }}/build" + state: directory + +- name: generate Dockerfile for custom image + copy: + content: | + 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" + +- name: install python-docker + apt: + name: python-docker + state: present + +- name: build custom image + docker_image: + name: "collabora/code/{{ item.key }}:{{ item.value.version }}" + state: present + source: build + build: + path: "{{ collabora_code_base_path }}/{{ item.key }}/build" + network: host + pull: yes diff --git a/roles/apps/collabora/code/tasks/main.yml b/roles/apps/collabora/code/tasks/main.yml index e283035b..57bdfa34 100644 --- a/roles/apps/collabora/code/tasks/main.yml +++ b/roles/apps/collabora/code/tasks/main.yml @@ -14,6 +14,13 @@ src: "config/loolwsd.{{ item.value.version }}.xml.j2" dest: "{{ collabora_code_base_path }}/{{ item.key }}/config/loolwsd.xml" +- name: build custom image + loop: "{{ collabora_code_instances | dict2items }}" + loop_control: + label: "{{ item.key }}" + when: "'custom_image' in item.value" + include_tasks: custom-image.yml + - name: generate pod manifests loop: "{{ collabora_code_instances | dict2items }}" loop_control: diff --git a/roles/apps/collabora/code/templates/pod.yml.j2 b/roles/apps/collabora/code/templates/pod.yml.j2 index eb771de7..53fb4c0d 100644 --- a/roles/apps/collabora/code/templates/pod.yml.j2 +++ b/roles/apps/collabora/code/templates/pod.yml.j2 @@ -5,7 +5,7 @@ metadata: spec: containers: - name: collabora-code - image: "collabora/code:{{ item.value.version }}" + image: "collabora/code{% if 'custom_image' in item.value %}/{{ item.key }}{% endif %}:{{ item.value.version }}" resources: limits: memory: "4Gi" -- cgit v1.2.3