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.
 
 

52 lines
3.1 KiB

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