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