Matrix Docker Ansible eploy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

60 lines
3.6 KiB

  1. #jinja2: lstrip_blocks: "True"
  2. FROM {{ matrix_synapse_docker_image }}
  3. {% if matrix_synapse_container_image_customizations_auto_accept_invite_installation_enabled %}
  4. RUN pip install synapse-auto-accept-invite=={{ matrix_synapse_ext_synapse_auto_accept_invite_version }}
  5. {% endif %}
  6. {% if matrix_synapse_container_image_customizations_s3_storage_provider_installation_enabled %}
  7. {% if matrix_synapse_container_image_customizations_s3_storage_provider_installation_old_boto_workaround_enabled %}
  8. RUN pip install 'boto3<1.36.0' 'botocore<1.36.0' synapse-s3-storage-provider=={{ matrix_synapse_ext_synapse_s3_storage_provider_version }}
  9. {% else %}
  10. RUN pip install synapse-s3-storage-provider=={{ matrix_synapse_ext_synapse_s3_storage_provider_version }}
  11. {% endif %}
  12. {% endif %}
  13. {% if matrix_synapse_container_image_customizations_templates_enabled %}
  14. {#
  15. This ugly script below does quite a lot:
  16. - installs git and other dependencies temporarily, just so we could do a shallow-clone
  17. - prepare the SSH config: keyscanning (if enabled), private key (if enabled)
  18. - performs a git shallow clone with just the branch we need
  19. - makes sure the files are owned by the user that will actually run the container later
  20. - removes the `.git` directory to save space, but keeps git revision in `git-revision.txt`, should we need it for debugging
  21. - finally, verifies that the templates path can indeed be found within the base path (sanity check)
  22. #}
  23. {% set dependencies = ['git', 'ssh', 'openssh-client'] %}
  24. RUN \
  25. {% if matrix_synapse_container_image_customizations_templates_git_repository_ssh_private_key %}
  26. echo '{{ matrix_synapse_container_image_customizations_templates_git_repository_ssh_private_key | b64encode }}' | base64 -d > /custom-templates-private-key && \
  27. chmod 400 /custom-templates-private-key && \
  28. {% endif %}
  29. apt-get update && \
  30. apt-get install --no-install-recommends -y {{ dependencies | join(' ') }} && \
  31. {% if matrix_synapse_container_image_customizations_templates_git_repository_keyscan_enabled %}
  32. mkdir ~/.ssh && \
  33. chmod 700 ~/.ssh && \
  34. ssh-keyscan -t rsa {{ matrix_synapse_container_image_customizations_templates_git_repository_keyscan_hostname }} >> ~/.ssh/known_hosts && \
  35. {% endif %}
  36. {% if matrix_synapse_container_image_customizations_templates_git_repository_ssh_private_key %}GIT_SSH_COMMAND='ssh -i /custom-templates-private-key'{% endif %} git \
  37. clone \
  38. --branch={{ matrix_synapse_container_image_customizations_templates_git_repository_branch }} \
  39. --depth=1 \
  40. --single-branch \
  41. --no-tags \
  42. {{ matrix_synapse_container_image_customizations_templates_git_repository_url }} \
  43. {{ matrix_synapse_container_image_customizations_templates_in_container_base_path }} && \
  44. /bin/sh -c 'cd {{ matrix_synapse_container_image_customizations_templates_in_container_base_path }} && git rev-parse HEAD > git-revision.txt' && \
  45. rm -rf {{ matrix_synapse_container_image_customizations_templates_in_container_base_path }}/.git && \
  46. chown -R {{ matrix_synapse_uid }}:{{ matrix_synapse_gid }} {{ matrix_synapse_container_image_customizations_templates_in_container_base_path }} && \
  47. apt-get autoremove -y {{ dependencies | join(' ') }} && \
  48. {% if matrix_synapse_container_image_customizations_templates_git_repository_ssh_private_key %}
  49. rm /custom-templates-private-key && \
  50. {% endif %}
  51. true
  52. RUN /bin/sh -c 'stat {{ matrix_synapse_container_image_customizations_templates_in_container_base_path }}/{{ matrix_synapse_container_image_customizations_templates_in_container_template_files_relative_path }} || exit 1'
  53. {% endif %}
  54. {{ matrix_synapse_container_image_customizations_dockerfile_body_custom }}