From ecb24dcaabafcf4ceccd175bb4b437475c154740 Mon Sep 17 00:00:00 2001 From: Michael Hollister Date: Thu, 13 Jul 2023 15:02:21 -0500 Subject: [PATCH] Changed volume mounting and directory structure --- roles/custom/matrix-media-repo/defaults/main.yml | 2 ++ .../matrix-media-repo/tasks/setup_install.yml | 16 +++++++++++++++- .../templates/media-repo/env.j2 | 1 + .../systemd/matrix-media-repo.service.j2 | 4 +++- 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 roles/custom/matrix-media-repo/templates/media-repo/env.j2 diff --git a/roles/custom/matrix-media-repo/defaults/main.yml b/roles/custom/matrix-media-repo/defaults/main.yml index d1790a8b..5be31c4b 100644 --- a/roles/custom/matrix-media-repo/defaults/main.yml +++ b/roles/custom/matrix-media-repo/defaults/main.yml @@ -17,6 +17,8 @@ matrix_media_repo_docker_image_tag: "v1.2.13" matrix_media_repo_docker_image_force_pull: "{{ matrix_media_repo_docker_image.endswith(':latest') }}" matrix_media_repo_base_path: "{{ matrix_base_data_path }}/media-repo" +matrix_media_repo_config_path: "{{ matrix_media_repo_base_path }}/config" +matrix_media_repo_data_path: "{{ matrix_media_repo_base_path }}/data" matrix_media_repo_docker_src_files_path: "{{ matrix_media_repo_base_path }}/docker-src" # List of systemd services that matrix-conduit.service depends on diff --git a/roles/custom/matrix-media-repo/tasks/setup_install.yml b/roles/custom/matrix-media-repo/tasks/setup_install.yml index af02d4b0..5e739905 100644 --- a/roles/custom/matrix-media-repo/tasks/setup_install.yml +++ b/roles/custom/matrix-media-repo/tasks/setup_install.yml @@ -10,14 +10,28 @@ with_items: - path: "{{ matrix_media_repo_base_path }}" when: true + - path: "{{ matrix_media_repo_config_path }}" + when: true + - path: "{{ matrix_media_repo_data_path }}" + when: true - path: "{{ matrix_media_repo_docker_src_files_path }}" when: "{{ matrix_media_repo_container_image_self_build }}" when: "item.when | bool" +- name: Ensure media-repo support files installed + ansible.builtin.template: + src: "{{ role_path }}/templates/media-repo/{{ item }}.j2" + dest: "{{ matrix_media_repo_base_path }}/{{ item }}" + mode: 0640 + owner: "{{ matrix_user_username }}" + group: "{{ matrix_user_groupname }}" + with_items: + - env + - name: Ensure media-repo configuration installed ansible.builtin.template: src: "{{ role_path }}/templates/media-repo/media-repo.yaml.j2" - dest: "{{ matrix_media_repo_base_path }}/media-repo.yaml" + dest: "{{ matrix_media_repo_config_path }}/media-repo.yaml" mode: 0640 owner: "{{ matrix_user_username }}" group: "{{ matrix_user_groupname }}" diff --git a/roles/custom/matrix-media-repo/templates/media-repo/env.j2 b/roles/custom/matrix-media-repo/templates/media-repo/env.j2 new file mode 100644 index 00000000..8b26f77d --- /dev/null +++ b/roles/custom/matrix-media-repo/templates/media-repo/env.j2 @@ -0,0 +1 @@ +REPO_CONFIG=/config/media-repo.yaml diff --git a/roles/custom/matrix-media-repo/templates/media-repo/systemd/matrix-media-repo.service.j2 b/roles/custom/matrix-media-repo/templates/media-repo/systemd/matrix-media-repo.service.j2 index 09133796..33b5199a 100644 --- a/roles/custom/matrix-media-repo/templates/media-repo/systemd/matrix-media-repo.service.j2 +++ b/roles/custom/matrix-media-repo/templates/media-repo/systemd/matrix-media-repo.service.j2 @@ -23,13 +23,15 @@ ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} create \ --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \ --cap-drop=ALL \ --network={{ matrix_docker_network }} \ + --env-file={{ matrix_media_repo_base_path }}/env \ {% if matrix_media_repo_container_http_host_bind_port %} -p {{ matrix_media_repo_container_http_host_bind_port }}:{{ matrix_media_repo_port }} \ {% endif %} {% if matrix_media_repo_metrics_enabled and matrix_media_repo_container_metrics_host_bind_port %} -p {{ matrix_media_repo_container_metrics_host_bind_port }}:{{ matrix_media_repo_metrics_port }} \ {% endif %} - -v {{ matrix_media_repo_base_path }}:/data:z \ + --mount type=bind,src={{ matrix_media_repo_config_path }},dst=/config,ro \ + --mount type=bind,src={{ matrix_media_repo_data_path }},dst=/data \ --workdir='/data' \ --entrypoint='media_repo' \ {% for arg in matrix_media_repo_container_extra_arguments %}