Refactored docker logic

This commit is contained in:
2025-05-25 17:44:58 +02:00
parent 7a7825cc61
commit cdfd464bce
53 changed files with 95 additions and 146 deletions

View File

@@ -10,5 +10,4 @@
domain: "{{ domains | get_domain(application_id) }}"
http_port: "{{ ports.localhost.http[application_id] }}"
- name: "copy docker-compose.yml and env file"
include_tasks: copy-docker-compose-and-env.yml
- include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/create-files.yml"

View File

@@ -47,5 +47,4 @@
version: "main"
notify: docker compose project build and setup
- name: "copy docker-compose.yml and env file"
include_tasks: copy-docker-compose-and-env.yml
- include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/create-files.yml"

View File

@@ -0,0 +1,35 @@
- name: "Create (optional) '{{ docker_compose.files.dockerfile }}'"
template:
src: "{{ playbook_dir }}/roles/{{ role_name }}/templates/{{ template_name }}"
dest: "{{ docker_compose.files.dockerfile }}"
notify: docker compose project build and setup
ignore_errors: true
- name: "Create (optional) '{{ docker_compose.files.env }}'"
template:
src: "env.j2"
dest: "{{ docker_compose.files.env }}"
mode: '770'
force: yes
notify: docker compose project setup
register: env_template
ignore_errors: true
- name: "Create (obligatoric) '{{ docker_compose.files.docker_compose }}'"
template:
src: "docker-compose.yml.j2"
dest: "{{ docker_compose.files.docker_compose }}"
notify: docker compose project setup
register: docker_compose_template
- name: "Check if any container is running in {{ docker_compose.directories.instance }}"
command: docker compose ps -q --filter status=running
args:
chdir: "{{ docker_compose.directories.instance }}"
register: docker_ps
changed_when: (docker_ps.stdout | trim) == ""
notify: docker compose project setup
when: not (docker_compose_template.changed or env_template.changed)
- name: flush docker compose project setup
meta: flush_handlers

View File

@@ -10,5 +10,4 @@
domain: "{{ domains | get_domain(application_id) }}"
http_port: "{{ ports.localhost.http[application_id] }}"
- name: "copy docker-compose.yml and env file"
include_tasks: copy-docker-compose-and-env.yml
- include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/create-files.yml"

View File

@@ -14,8 +14,7 @@
domain: "{{ domains | get_domain(application_id) }}"
http_port: "{{ ports.localhost.http[application_id] }}"
- name: "copy docker-compose.yml and env file"
include_tasks: copy-docker-compose-and-env.yml
- include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/create-files.yml"
- name: Set OIDC scopes in EspoCRM config (inside web container)
ansible.builtin.shell: |

View File

@@ -10,5 +10,4 @@
domain: "{{ domains | get_domain(application_id) }}"
http_port: "{{ ports.localhost.http[application_id] }}"
- name: "copy docker-compose.yml and env file"
include_tasks: copy-docker-compose-and-env.yml
- include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/create-files.yml"

View File

@@ -10,7 +10,6 @@
domain: "{{ domains | get_domain(application_id) }}"
http_port: "{{ ports.localhost.http[application_id] }}"
- name: "copy docker-compose.yml and env file"
include_tasks: copy-docker-compose-and-env.yml
- include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/create-files.yml"

View File

@@ -9,5 +9,4 @@
domain: "{{ domains | get_domain(application_id) }}"
http_port: "{{ ports.localhost.http[application_id] }}"
- name: "copy docker-compose.yml and env file"
include_tasks: copy-docker-compose-and-env.yml
- include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/create-files.yml"

View File

@@ -10,5 +10,4 @@
domain: "{{ domains | get_domain(application_id) }}"
http_port: "{{ ports.localhost.http[application_id] }}"
- name: "copy docker-compose.yml and env file"
include_tasks: copy-docker-compose-and-env.yml
- include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/create-files.yml"

View File

@@ -10,5 +10,4 @@
domain: "{{ domains | get_domain(application_id) }}"
http_port: "{{ ports.localhost.http[application_id] }}"
- name: "copy docker-compose.yml and env file"
include_tasks: copy-docker-compose-and-env.yml
- include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/create-files.yml"

View File

@@ -13,5 +13,4 @@
loop_control:
loop_var: domain
- name: "copy docker-compose.yml and env file"
include_tasks: copy-docker-compose-and-env.yml
- include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/create-files.yml"

View File

@@ -10,8 +10,7 @@
domain: "{{ domains | get_domain(application_id) }}"
http_port: "{{ ports.localhost.http[application_id] }}"
- name: "copy docker-compose.yml and env file"
include_tasks: copy-docker-compose-and-env.yml
- include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/create-files.yml"
- name: "create directory {{import_directory_host}}"
file:

View File

@@ -9,5 +9,4 @@
domain: "{{ domains | get_domain(application_id) }}"
http_port: "{{ ports.localhost.http[application_id] }}"
- name: "copy docker-compose.yml and env file"
include_tasks: copy-docker-compose-and-env.yml
- include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/create-files.yml"

View File

@@ -23,8 +23,7 @@
ipam_config:
- subnet: "{{ networks.local.central_ldap.subnet }}"
- name: "copy docker-compose.yml and env file"
include_tasks: copy-docker-compose-and-env.yml
- include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/create-files.yml"
- name: "create directory {{ldif_host_path}}{{item}}"
file:

View File

@@ -25,8 +25,7 @@
dest: "{{docker_compose.directories.config}}config.toml"
notify: docker compose project setup
- name: "copy docker-compose.yml and env file"
include_tasks: copy-docker-compose-and-env.yml
- include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/create-files.yml"
- name: Check if listmonk database is already initialized
command: docker compose exec -T {{database_host}} psql -U {{database_username}} -d {{database_name}} -c "\dt"

View File

@@ -18,8 +18,7 @@
name: nginx-docker-cert-deploy
when: run_once_docker_mailu is not defined
- name: "Copy docker-compose.yml and env file"
include_tasks: copy-docker-compose-and-env.yml
- include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/create-files.yml"
when: run_once_docker_mailu is not defined
- name: Flush docker service handlers

View File

@@ -16,8 +16,7 @@
client_max_body_size: "80m"
vhost_flavour: "ws_generic"
- name: "copy docker-compose.yml and env file"
include_tasks: copy-docker-compose-and-env.yml
- include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/create-files.yml"
- name: flush docker service
meta: flush_handlers

View File

@@ -12,8 +12,7 @@
http_port: "{{ ports.localhost.http[application_id] }}"
when: run_once_docker_matomo is not defined
- name: "copy docker-compose.yml and env file"
include_tasks: copy-docker-compose-and-env.yml
- include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/create-files.yml"
when: run_once_docker_matomo is not defined
- name: run the docker matomo tasks once

View File

@@ -10,14 +10,7 @@
domain: "{{ domains | get_domain(application_id) }}"
http_port: "{{ ports.localhost.http[application_id] }}"
- name: "Transfer Dockerfile to {{ docker_compose.directories.instance }}"
template:
src: Dockerfile.j2
dest: "{{ docker_compose.directories.instance }}Dockerfile"
notify: docker compose project build and setup
- name: "copy docker-compose.yml and env file"
include_tasks: copy-docker-compose-and-env.yml
- include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/create-files.yml"
- name: "Configure OIDC login for Moodle if enabled"
include_tasks: oidc.yml

View File

@@ -35,8 +35,7 @@
dest: "{{docker_compose.directories.volumes}}nginx.conf"
notify: restart nextcloud nginx service
- name: "copy docker-compose.yml and env file"
include_tasks: copy-docker-compose-and-env.yml
- include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/create-files.yml"
- name: Flush all handlers immediately so that occ can be used
meta: flush_handlers

View File

@@ -10,23 +10,16 @@
domain: "{{ domains | get_domain(application_id) }}"
http_port: "{{ ports.localhost.http[application_id] }}"
- name: "Create {{openproject_plugins_service}}"
- name: "Create {{openproject_plugins_folder}}"
file:
path: "{{openproject_plugins_service}}"
path: "{{openproject_plugins_folder}}"
state: directory
mode: '0755'
- name: "Transfering Gemfile.plugins to {{openproject_plugins_service}}"
- name: "Transfering Gemfile.plugins to {{openproject_plugins_folder}}"
copy:
src: Gemfile.plugins
dest: "{{openproject_plugins_service}}Gemfile.plugins"
notify:
- docker compose project build and setup
- name: "Transfering Dockerfile to {{openproject_plugins_service}}Dockerfile"
template:
src: Dockerfile
dest: "{{openproject_plugins_service}}Dockerfile"
dest: "{{openproject_plugins_folder}}Gemfile.plugins"
notify:
- docker compose project build and setup
@@ -40,8 +33,7 @@
state: directory
mode: 0755
- name: "copy docker-compose.yml and env file"
include_tasks: copy-docker-compose-and-env.yml
- include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/create-files.yml"
- name: flush docker service
meta: flush_handlers

View File

@@ -5,7 +5,7 @@ FROM openproject/community:{{applications.openproject.version}}
# path inside of the container. Say for `/app/vendor/plugins/openproject-slack`:
# COPY /path/to/my/local/openproject-slack /app/vendor/plugins/openproject-slack
COPY Gemfile.plugins /app/
COPY volumes/plugins/Gemfile.plugins /app/
# If the plugin uses any external NPM dependencies you have to install them here.
# RUN npm add npm <package-name>*

View File

@@ -4,7 +4,7 @@ x-op-app: &app
driver: journald
image: {{custom_openproject_image}}
build:
context: {{openproject_plugins_service}}
context: .
dockerfile: Dockerfile
services:

View File

@@ -9,7 +9,7 @@ ldap:
features:
matomo: true
css: true
portfolio_iframe: false
portfolio_iframe: false
ldap: true
central_database: true
oauth2: true

View File

@@ -2,7 +2,8 @@ application_id: "openproject"
docker_repository_address: "https://github.com/opf/openproject-deploy"
database_type: "postgres"
openproject_plugins_service: "{{docker_compose.directories.services}}plugins/"
openproject_plugins_folder: "{{docker_compose.directories.volumes}}plugins/"
custom_openproject_image: "custom_openproject"
# The following volume doesn't have a practcical function. It just exist to prevent the creation of unnecessary anonymous volumes
@@ -23,4 +24,4 @@ openproject_filters:
users: >-
{{ '(memberOf=cn=openproject-users,' ~ ldap.dn.application_roles ~ ')'
if applications[application_id].ldap.filters.users else '' }}
if applications[application_id].ldap.filters.users else '' }}

View File

@@ -11,8 +11,7 @@
vars:
http: "{{ ports.localhost.http[application_id] }}"
- name: "copy docker-compose.yml and env file"
include_tasks: copy-docker-compose-and-env.yml
- include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/create-files.yml"
- name: "Install and activate auth-openid-connect plugin if OIDC is enabled"
include_tasks: enable-oidc.yml

View File

@@ -14,5 +14,4 @@
include_tasks: configuration.yml
when: applications[application_id].server_mode | bool
- name: "copy docker-compose.yml and env file"
include_tasks: copy-docker-compose-and-env.yml
- include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/create-files.yml"

View File

@@ -9,5 +9,4 @@
domain: "{{ domains | get_domain(application_id) }}"
http_port: "{{ ports.localhost.http[application_id] }}"
- name: "copy docker-compose.yml and env file"
include_tasks: copy-docker-compose-and-env.yml
- include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/create-files.yml"

View File

@@ -10,5 +10,4 @@
domain: "{{ domains | get_domain(application_id) }}"
http_port: "{{ ports.localhost.http[application_id] }}"
- name: "copy docker-compose.yml and env file"
include_tasks: copy-docker-compose-and-env.yml
- include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/create-files.yml"

View File

@@ -10,5 +10,4 @@
domain: "{{ domains | get_domain(application_id) }}"
http_port: "{{ ports.localhost.http[application_id] }}"
- name: "copy docker-compose.yml and env file"
include_tasks: copy-docker-compose-and-env.yml
- include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/create-files.yml"

View File

@@ -26,5 +26,4 @@
domain: "{{ domains | get_domain(application_id) }}"
http_port: "{{ ports.localhost.http[application_id] }}"
- name: "copy docker-compose.yml and env file"
include_tasks: copy-docker-compose-and-env.yml
- include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/create-files.yml"

View File

@@ -12,10 +12,4 @@
become: true
ignore_errors: true
- name: add docker-compose.yml
template: src=docker-compose.yml.j2 dest={{docker_compose.directories.instance}}docker-compose.yml
notify: docker compose project setup
- name: add Dockerfile
template: src=Dockerfile.j2 dest={{docker_compose.directories.instance}}Dockerfile
notify: docker compose project setup
- include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/create-files.yml"

View File

@@ -10,5 +10,4 @@
domain: "{{ domains | get_domain(application_id) }}"
http_port: "{{ ports.localhost.http[application_id] }}"
- name: "copy docker-compose.yml and env file"
include_tasks: copy-docker-compose-and-env.yml
- include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/create-files.yml"

View File

@@ -22,5 +22,4 @@
domain: "{{ domains | get_domain(application_id) }}"
http_port: "{{ ports.localhost.http[application_id] }}"
- name: "copy docker-compose.yml and env file"
include_tasks: copy-docker-compose-and-env.yml
- include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/create-files.yml"

View File

@@ -27,5 +27,4 @@
force: yes
notify: docker compose project setup
- name: "copy docker-compose.yml and env file"
include_tasks: copy-docker-compose-and-env.yml
- include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/create-files.yml"

View File

@@ -28,5 +28,4 @@
dest: "{{docker_compose_init}}"
notify: docker compose project build and setup
- name: "copy docker-compose.yml and env file"
include_tasks: copy-docker-compose-and-env.yml
- include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/create-files.yml"

View File

@@ -25,14 +25,7 @@
dest: "{{ host_msmtp_conf }}"
notify: docker compose project build and setup
- name: "Transfering Dockerfile to {{ docker_compose.directories.instance }}"
copy:
src: Dockerfile
dest: "{{ docker_compose.directories.instance }}Dockerfile"
notify: docker compose project build and setup
- name: "copy docker-compose.yml and env file"
include_tasks: copy-docker-compose-and-env.yml
- include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/create-files.yml"
- name: "Install wordpress"
include_tasks: install.yml

View File

@@ -1,4 +1,4 @@
FROM wordpress
FROM wordpress:{{applications[application_id].version}}
# Install msmtp and update system
RUN apt-get update && \

View File

@@ -10,5 +10,4 @@
domain: "{{ domains | get_domain(application_id) }}"
http_port: "{{ ports.localhost.http[application_id] }}"
- name: "copy docker-compose.yml and env file"
include_tasks: copy-docker-compose-and-env.yml
- include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/create-files.yml"