From 5fe6f4fda1eaf5a1e05e87063aa4eafa47fa1c07 Mon Sep 17 00:00:00 2001 From: Jusong Yu Date: Thu, 9 Nov 2023 13:34:46 +0100 Subject: [PATCH] Docker: Add folders that automatically run scripts before/after daemon start (#6170) In order to simplify the implementation of using the `aiida-core` image as the base for customized images, the `run-before-daemon-start` and `run-after-daemon-start` script folders are created. Any executables in these two folders will be executed before and after the AiiDA daemon is started in the container, respectively. The standard linux `run-parts` tool is used to scan these folders for files, which are run in the lexical sort order of their names, according to the C/POSIX locale character collation rules --- .docker/aiida-core-base/Dockerfile | 2 ++ .../dependencies.d/run-before-daemon-start | 0 .../dependencies.d/aiida-daemon-start | 0 .../s6-rc.d/run-after-daemon-start/dependencies.d/base | 0 .../s6-assets/s6-rc.d/run-after-daemon-start/timeout-up | 1 + .../s6-assets/s6-rc.d/run-after-daemon-start/type | 1 + .../s6-assets/s6-rc.d/run-after-daemon-start/up | 6 ++++++ .../run-before-daemon-start/dependencies.d/aiida-prepare | 0 .../s6-rc.d/run-before-daemon-start/dependencies.d/base | 0 .../s6-assets/s6-rc.d/run-before-daemon-start/timeout-up | 1 + .../s6-assets/s6-rc.d/run-before-daemon-start/type | 1 + .../s6-assets/s6-rc.d/run-before-daemon-start/up | 6 ++++++ .../s6-rc.d/user/contents.d/run-after-daemon-start | 0 .../s6-rc.d/user/contents.d/run-before-daemon-start | 0 14 files changed, 18 insertions(+) create mode 100644 .docker/aiida-core-base/s6-assets/s6-rc.d/aiida-daemon-start/dependencies.d/run-before-daemon-start create mode 100644 .docker/aiida-core-base/s6-assets/s6-rc.d/run-after-daemon-start/dependencies.d/aiida-daemon-start create mode 100644 .docker/aiida-core-base/s6-assets/s6-rc.d/run-after-daemon-start/dependencies.d/base create mode 100644 .docker/aiida-core-base/s6-assets/s6-rc.d/run-after-daemon-start/timeout-up create mode 100644 .docker/aiida-core-base/s6-assets/s6-rc.d/run-after-daemon-start/type create mode 100644 .docker/aiida-core-base/s6-assets/s6-rc.d/run-after-daemon-start/up create mode 100644 .docker/aiida-core-base/s6-assets/s6-rc.d/run-before-daemon-start/dependencies.d/aiida-prepare create mode 100644 .docker/aiida-core-base/s6-assets/s6-rc.d/run-before-daemon-start/dependencies.d/base create mode 100644 .docker/aiida-core-base/s6-assets/s6-rc.d/run-before-daemon-start/timeout-up create mode 100644 .docker/aiida-core-base/s6-assets/s6-rc.d/run-before-daemon-start/type create mode 100644 .docker/aiida-core-base/s6-assets/s6-rc.d/run-before-daemon-start/up create mode 100644 .docker/aiida-core-base/s6-assets/s6-rc.d/user/contents.d/run-after-daemon-start create mode 100644 .docker/aiida-core-base/s6-assets/s6-rc.d/user/contents.d/run-before-daemon-start diff --git a/.docker/aiida-core-base/Dockerfile b/.docker/aiida-core-base/Dockerfile index 17307203ec..085e100e07 100644 --- a/.docker/aiida-core-base/Dockerfile +++ b/.docker/aiida-core-base/Dockerfile @@ -161,6 +161,8 @@ RUN mkdir -p "${CONDA_DIR}/etc/conda/activate.d" && \ COPY --chown="${SYSTEM_UID}:${SYSTEM_GID}" s6-assets/config-quick-setup.yaml "/aiida/assets/config-quick-setup.yaml" COPY s6-assets/s6-rc.d /etc/s6-overlay/s6-rc.d COPY s6-assets/init /etc/init +RUN mkdir /etc/init/run-before-daemon-start && \ + mkdir /etc/init/run-after-daemon-start # Otherwise will stuck on oneshot services # https://github.com/just-containers/s6-overlay/issues/467 diff --git a/.docker/aiida-core-base/s6-assets/s6-rc.d/aiida-daemon-start/dependencies.d/run-before-daemon-start b/.docker/aiida-core-base/s6-assets/s6-rc.d/aiida-daemon-start/dependencies.d/run-before-daemon-start new file mode 100644 index 0000000000..e69de29bb2 diff --git a/.docker/aiida-core-base/s6-assets/s6-rc.d/run-after-daemon-start/dependencies.d/aiida-daemon-start b/.docker/aiida-core-base/s6-assets/s6-rc.d/run-after-daemon-start/dependencies.d/aiida-daemon-start new file mode 100644 index 0000000000..e69de29bb2 diff --git a/.docker/aiida-core-base/s6-assets/s6-rc.d/run-after-daemon-start/dependencies.d/base b/.docker/aiida-core-base/s6-assets/s6-rc.d/run-after-daemon-start/dependencies.d/base new file mode 100644 index 0000000000..e69de29bb2 diff --git a/.docker/aiida-core-base/s6-assets/s6-rc.d/run-after-daemon-start/timeout-up b/.docker/aiida-core-base/s6-assets/s6-rc.d/run-after-daemon-start/timeout-up new file mode 100644 index 0000000000..573541ac97 --- /dev/null +++ b/.docker/aiida-core-base/s6-assets/s6-rc.d/run-after-daemon-start/timeout-up @@ -0,0 +1 @@ +0 diff --git a/.docker/aiida-core-base/s6-assets/s6-rc.d/run-after-daemon-start/type b/.docker/aiida-core-base/s6-assets/s6-rc.d/run-after-daemon-start/type new file mode 100644 index 0000000000..bdd22a1850 --- /dev/null +++ b/.docker/aiida-core-base/s6-assets/s6-rc.d/run-after-daemon-start/type @@ -0,0 +1 @@ +oneshot diff --git a/.docker/aiida-core-base/s6-assets/s6-rc.d/run-after-daemon-start/up b/.docker/aiida-core-base/s6-assets/s6-rc.d/run-after-daemon-start/up new file mode 100644 index 0000000000..d2e95d5190 --- /dev/null +++ b/.docker/aiida-core-base/s6-assets/s6-rc.d/run-after-daemon-start/up @@ -0,0 +1,6 @@ +#!/command/execlineb -P + +with-contenv + +foreground { s6-echo "Calling /etc/init/run-after-daemon-start" } +run-parts --regex=".*" /etc/init/run-after-daemon-start/ diff --git a/.docker/aiida-core-base/s6-assets/s6-rc.d/run-before-daemon-start/dependencies.d/aiida-prepare b/.docker/aiida-core-base/s6-assets/s6-rc.d/run-before-daemon-start/dependencies.d/aiida-prepare new file mode 100644 index 0000000000..e69de29bb2 diff --git a/.docker/aiida-core-base/s6-assets/s6-rc.d/run-before-daemon-start/dependencies.d/base b/.docker/aiida-core-base/s6-assets/s6-rc.d/run-before-daemon-start/dependencies.d/base new file mode 100644 index 0000000000..e69de29bb2 diff --git a/.docker/aiida-core-base/s6-assets/s6-rc.d/run-before-daemon-start/timeout-up b/.docker/aiida-core-base/s6-assets/s6-rc.d/run-before-daemon-start/timeout-up new file mode 100644 index 0000000000..573541ac97 --- /dev/null +++ b/.docker/aiida-core-base/s6-assets/s6-rc.d/run-before-daemon-start/timeout-up @@ -0,0 +1 @@ +0 diff --git a/.docker/aiida-core-base/s6-assets/s6-rc.d/run-before-daemon-start/type b/.docker/aiida-core-base/s6-assets/s6-rc.d/run-before-daemon-start/type new file mode 100644 index 0000000000..bdd22a1850 --- /dev/null +++ b/.docker/aiida-core-base/s6-assets/s6-rc.d/run-before-daemon-start/type @@ -0,0 +1 @@ +oneshot diff --git a/.docker/aiida-core-base/s6-assets/s6-rc.d/run-before-daemon-start/up b/.docker/aiida-core-base/s6-assets/s6-rc.d/run-before-daemon-start/up new file mode 100644 index 0000000000..3ff7dc0360 --- /dev/null +++ b/.docker/aiida-core-base/s6-assets/s6-rc.d/run-before-daemon-start/up @@ -0,0 +1,6 @@ +#!/command/execlineb -P + +with-contenv + +foreground { s6-echo "Calling /etc/init/run-before-daemon-start" } +run-parts --regex=".*" /etc/init/run-before-daemon-start/ diff --git a/.docker/aiida-core-base/s6-assets/s6-rc.d/user/contents.d/run-after-daemon-start b/.docker/aiida-core-base/s6-assets/s6-rc.d/user/contents.d/run-after-daemon-start new file mode 100644 index 0000000000..e69de29bb2 diff --git a/.docker/aiida-core-base/s6-assets/s6-rc.d/user/contents.d/run-before-daemon-start b/.docker/aiida-core-base/s6-assets/s6-rc.d/user/contents.d/run-before-daemon-start new file mode 100644 index 0000000000..e69de29bb2