Skip to content

Commit 5ab05e7

Browse files
AndrewFerrsandhose
andauthored
docker: use shebangs to invoke generated scripts (#18295)
When generating scripts from templates, don't add a leading newline so that their shebangs may be handled correctly. ### Pull Request Checklist <!-- Please read https://element-hq.github.io/synapse/latest/development/contributing_guide.html before submitting your pull request --> * [x] Pull request is based on the develop branch * [x] Pull request includes a [changelog file](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#changelog). The entry should: - Be a short description of your change which makes sense to users. "Fixed a bug that prevented receiving messages from other servers." instead of "Moved X method from `EventStore` to `EventWorkerStore`.". - Use markdown where necessary, mostly for `code blocks`. - End with either a period (.) or an exclamation mark (!). - Start with a capital letter. - Feel free to credit yourself, by adding a sentence "Contributed by @github_username." or "Contributed by [Your Name]." to the end of the entry. * [x] [Code style](https://element-hq.github.io/synapse/latest/code_style.html) is correct (run the [linters](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#run-the-linters)) --------- Co-authored-by: Quentin Gliech <quenting@element.io>
1 parent 7563b2a commit 5ab05e7

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

changelog.d/18295.docker

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
When generating container scripts from templates, don't add a leading newline so that their shebangs may be handled correctly.

docker/Dockerfile-workers

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,4 @@ FROM $FROM
7474
# Replace the healthcheck with one which checks *all* the workers. The script
7575
# is generated by configure_workers_and_start.py.
7676
HEALTHCHECK --start-period=5s --interval=15s --timeout=5s \
77-
CMD /bin/sh /healthcheck.sh
77+
CMD ["/healthcheck.sh"]

docker/complement/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ ENTRYPOINT ["/start_for_complement.sh"]
5858

5959
# Update the healthcheck to have a shorter check interval
6060
HEALTHCHECK --start-period=5s --interval=1s --timeout=1s \
61-
CMD /bin/sh /healthcheck.sh
61+
CMD ["/healthcheck.sh"]

docker/configure_workers_and_start.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,11 @@ def convert(src: str, dst: str, **template_vars: object) -> None:
376376
#
377377
# We use append mode in case the files have already been written to by something else
378378
# (for instance, as part of the instructions in a dockerfile).
379+
exists = os.path.isfile(dst)
379380
with open(dst, "a") as outfile:
380381
# In case the existing file doesn't end with a newline
381-
outfile.write("\n")
382+
if exists:
383+
outfile.write("\n")
382384

383385
outfile.write(rendered)
384386

@@ -998,6 +1000,7 @@ def generate_worker_files(
9981000
"/healthcheck.sh",
9991001
healthcheck_urls=healthcheck_urls,
10001002
)
1003+
os.chmod("/healthcheck.sh", 0o755)
10011004

10021005
# Ensure the logging directory exists
10031006
log_dir = data_dir + "/logs"

0 commit comments

Comments
 (0)