Skip to content

docker: use shebangs to invoke generated scripts #18295

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/18295.docker
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
When generating container scripts from templates, don't add a leading newline so that their shebangs may be handled correctly.
2 changes: 1 addition & 1 deletion docker/Dockerfile-workers
Original file line number Diff line number Diff line change
@@ -74,4 +74,4 @@ FROM $FROM
# Replace the healthcheck with one which checks *all* the workers. The script
# is generated by configure_workers_and_start.py.
HEALTHCHECK --start-period=5s --interval=15s --timeout=5s \
CMD /bin/sh /healthcheck.sh
CMD ["/healthcheck.sh"]
2 changes: 1 addition & 1 deletion docker/complement/Dockerfile
Original file line number Diff line number Diff line change
@@ -58,4 +58,4 @@ ENTRYPOINT ["/start_for_complement.sh"]

# Update the healthcheck to have a shorter check interval
HEALTHCHECK --start-period=5s --interval=1s --timeout=1s \
CMD /bin/sh /healthcheck.sh
CMD ["/healthcheck.sh"]
5 changes: 4 additions & 1 deletion docker/configure_workers_and_start.py
Original file line number Diff line number Diff line change
@@ -376,9 +376,11 @@ def convert(src: str, dst: str, **template_vars: object) -> None:
#
# We use append mode in case the files have already been written to by something else
# (for instance, as part of the instructions in a dockerfile).
exists = os.path.isfile(dst)
with open(dst, "a") as outfile:
# In case the existing file doesn't end with a newline
outfile.write("\n")
if exists:
outfile.write("\n")

outfile.write(rendered)

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

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