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 line
2.7 KiB

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