From c348a1d885dabcd6ea794b4f37d22b0e5ac457e8 Mon Sep 17 00:00:00 2001 From: tuutti Date: Wed, 27 Mar 2024 17:14:05 +0200 Subject: [PATCH 1/4] Added entrypoints --- openshift/drupal-repository/Dockerfile | 13 ++++++++++--- .../files/entrypoints/10-queue.sh | 9 +++++++++ .../files/entrypoints/99-webhook.sh | 2 ++ .../files/usr/local/bin/entrypoint | 19 +++++++++++++++++++ 4 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 openshift/drupal-repository/files/entrypoints/10-queue.sh create mode 100644 openshift/drupal-repository/files/entrypoints/99-webhook.sh create mode 100644 openshift/drupal-repository/files/usr/local/bin/entrypoint diff --git a/openshift/drupal-repository/Dockerfile b/openshift/drupal-repository/Dockerfile index 4966dc6..eab6a17 100644 --- a/openshift/drupal-repository/Dockerfile +++ b/openshift/drupal-repository/Dockerfile @@ -2,7 +2,7 @@ FROM alpine:3.19 COPY --from=almir/webhook /usr/local/bin/webhook /usr/local/bin/webhook # We need php and git to build satis. -RUN apk add --no-cache git php82 php82-openssl php82-common php82-json php82-phar php82-mbstring php82-pecl-apcu php82-zip php82-simplexml make +RUN apk add --no-cache git php82 php82-openssl php82-common php82-json php82-phar php82-mbstring php82-pecl-apcu php82-zip php82-simplexml make tini ENV COMPOSER_HOME=/.composer ENV PROJECT_DIR=/var/www/html @@ -15,5 +15,12 @@ RUN \ WORKDIR /etc/webhook VOLUME ["/etc/webhook"] EXPOSE 9000 -ENTRYPOINT ["/usr/local/bin/webhook"] -CMD ["-verbose", "-hooks=/etc/webhook/hooks.json", "-template", "-hotreload", "-debug"] + +# Copy configuration files and scripts +COPY files/ / +RUN chmod +x /entrypoints/* && \ + chmod +x /usr/local/bin/entrypoint +ENTRYPOINT ["/sbin/tini", "--"] + +# Default command: Start up multiple services via entrypoint +CMD ["entrypoint"] diff --git a/openshift/drupal-repository/files/entrypoints/10-queue.sh b/openshift/drupal-repository/files/entrypoints/10-queue.sh new file mode 100644 index 0000000..0e23ab5 --- /dev/null +++ b/openshift/drupal-repository/files/entrypoints/10-queue.sh @@ -0,0 +1,9 @@ +#!/bin/sh +cd $PROJECT_DIR +make + +(while true +do + php console.php queue:consume package-queue --item-limit 10 +done) & + diff --git a/openshift/drupal-repository/files/entrypoints/99-webhook.sh b/openshift/drupal-repository/files/entrypoints/99-webhook.sh new file mode 100644 index 0000000..e04d5ca --- /dev/null +++ b/openshift/drupal-repository/files/entrypoints/99-webhook.sh @@ -0,0 +1,2 @@ +#!/bin/sh +/usr/local/bin/webhook -verbose -hooks=/etc/webhook/hooks.json -template -hotreload -debug diff --git a/openshift/drupal-repository/files/usr/local/bin/entrypoint b/openshift/drupal-repository/files/usr/local/bin/entrypoint new file mode 100644 index 0000000..93e4217 --- /dev/null +++ b/openshift/drupal-repository/files/usr/local/bin/entrypoint @@ -0,0 +1,19 @@ +#!/bin/sh + +# This script will be the default ENTRYPOINT for all children docker images. +# It just sources all files within /entrypoints/* in an alphabetical order and then runs `exec` on the given parameter. + +if [ -d /entrypoints ]; then + for i in /entrypoints/*; do + if [ -r $i ]; then + echo "# Source $i" + . $i + else + echo "! $i not sourced" + fi + done + unset i +fi + +echo "Exec: $@" +exec "$@" From 3f2c63e37715197295ab1af1885cecc733c5c074 Mon Sep 17 00:00:00 2001 From: tuutti Date: Thu, 28 Mar 2024 10:08:30 +0200 Subject: [PATCH 2/4] Use s6-overlay instead of tini --- openshift/drupal-repository/Dockerfile | 15 ++++++++------- .../files/entrypoints/10-queue.sh | 9 --------- .../etc/s6-overlay/s6-rc.d/package-queue/run | 4 ++++ .../etc/s6-overlay/s6-rc.d/package-queue/type | 1 + .../s6-rc.d/user/contents.d/package-queue | 0 .../s6-overlay/s6-rc.d/user/contents.d/webhook | 0 .../s6-rc.d/webhook/dependencies.d/package-queue | 0 .../s6-overlay/s6-rc.d/webhook/run} | 2 +- .../files/etc/s6-overlay/s6-rc.d/webhook/type | 1 + 9 files changed, 15 insertions(+), 17 deletions(-) delete mode 100644 openshift/drupal-repository/files/entrypoints/10-queue.sh create mode 100644 openshift/drupal-repository/files/etc/s6-overlay/s6-rc.d/package-queue/run create mode 100644 openshift/drupal-repository/files/etc/s6-overlay/s6-rc.d/package-queue/type create mode 100644 openshift/drupal-repository/files/etc/s6-overlay/s6-rc.d/user/contents.d/package-queue create mode 100644 openshift/drupal-repository/files/etc/s6-overlay/s6-rc.d/user/contents.d/webhook create mode 100644 openshift/drupal-repository/files/etc/s6-overlay/s6-rc.d/webhook/dependencies.d/package-queue rename openshift/drupal-repository/files/{entrypoints/99-webhook.sh => etc/s6-overlay/s6-rc.d/webhook/run} (77%) create mode 100644 openshift/drupal-repository/files/etc/s6-overlay/s6-rc.d/webhook/type diff --git a/openshift/drupal-repository/Dockerfile b/openshift/drupal-repository/Dockerfile index eab6a17..df74e63 100644 --- a/openshift/drupal-repository/Dockerfile +++ b/openshift/drupal-repository/Dockerfile @@ -1,8 +1,14 @@ FROM alpine:3.19 COPY --from=almir/webhook /usr/local/bin/webhook /usr/local/bin/webhook +ARG S6_OVERLAY_VERSION=3.1.6.2 +ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp +RUN tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz +ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-x86_64.tar.xz /tmp +RUN tar -C / -Jxpf /tmp/s6-overlay-x86_64.tar.xz + # We need php and git to build satis. -RUN apk add --no-cache git php82 php82-openssl php82-common php82-json php82-phar php82-mbstring php82-pecl-apcu php82-zip php82-simplexml make tini +RUN apk add --no-cache git php82 php82-openssl php82-common php82-json php82-phar php82-mbstring php82-pecl-apcu php82-zip php82-simplexml make ENV COMPOSER_HOME=/.composer ENV PROJECT_DIR=/var/www/html @@ -18,9 +24,4 @@ EXPOSE 9000 # Copy configuration files and scripts COPY files/ / -RUN chmod +x /entrypoints/* && \ - chmod +x /usr/local/bin/entrypoint -ENTRYPOINT ["/sbin/tini", "--"] - -# Default command: Start up multiple services via entrypoint -CMD ["entrypoint"] +ENTRYPOINT ["/init"] diff --git a/openshift/drupal-repository/files/entrypoints/10-queue.sh b/openshift/drupal-repository/files/entrypoints/10-queue.sh deleted file mode 100644 index 0e23ab5..0000000 --- a/openshift/drupal-repository/files/entrypoints/10-queue.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -cd $PROJECT_DIR -make - -(while true -do - php console.php queue:consume package-queue --item-limit 10 -done) & - diff --git a/openshift/drupal-repository/files/etc/s6-overlay/s6-rc.d/package-queue/run b/openshift/drupal-repository/files/etc/s6-overlay/s6-rc.d/package-queue/run new file mode 100644 index 0000000..70ffeca --- /dev/null +++ b/openshift/drupal-repository/files/etc/s6-overlay/s6-rc.d/package-queue/run @@ -0,0 +1,4 @@ +#!/command/with-contenv sh +cd $PROJECT_DIR +make +exec php console.php queue:consume package-queue --item-limit 10; diff --git a/openshift/drupal-repository/files/etc/s6-overlay/s6-rc.d/package-queue/type b/openshift/drupal-repository/files/etc/s6-overlay/s6-rc.d/package-queue/type new file mode 100644 index 0000000..5883cff --- /dev/null +++ b/openshift/drupal-repository/files/etc/s6-overlay/s6-rc.d/package-queue/type @@ -0,0 +1 @@ +longrun diff --git a/openshift/drupal-repository/files/etc/s6-overlay/s6-rc.d/user/contents.d/package-queue b/openshift/drupal-repository/files/etc/s6-overlay/s6-rc.d/user/contents.d/package-queue new file mode 100644 index 0000000..e69de29 diff --git a/openshift/drupal-repository/files/etc/s6-overlay/s6-rc.d/user/contents.d/webhook b/openshift/drupal-repository/files/etc/s6-overlay/s6-rc.d/user/contents.d/webhook new file mode 100644 index 0000000..e69de29 diff --git a/openshift/drupal-repository/files/etc/s6-overlay/s6-rc.d/webhook/dependencies.d/package-queue b/openshift/drupal-repository/files/etc/s6-overlay/s6-rc.d/webhook/dependencies.d/package-queue new file mode 100644 index 0000000..e69de29 diff --git a/openshift/drupal-repository/files/entrypoints/99-webhook.sh b/openshift/drupal-repository/files/etc/s6-overlay/s6-rc.d/webhook/run similarity index 77% rename from openshift/drupal-repository/files/entrypoints/99-webhook.sh rename to openshift/drupal-repository/files/etc/s6-overlay/s6-rc.d/webhook/run index e04d5ca..9fd3a4b 100644 --- a/openshift/drupal-repository/files/entrypoints/99-webhook.sh +++ b/openshift/drupal-repository/files/etc/s6-overlay/s6-rc.d/webhook/run @@ -1,2 +1,2 @@ -#!/bin/sh +#!/command/with-contenv sh /usr/local/bin/webhook -verbose -hooks=/etc/webhook/hooks.json -template -hotreload -debug diff --git a/openshift/drupal-repository/files/etc/s6-overlay/s6-rc.d/webhook/type b/openshift/drupal-repository/files/etc/s6-overlay/s6-rc.d/webhook/type new file mode 100644 index 0000000..5883cff --- /dev/null +++ b/openshift/drupal-repository/files/etc/s6-overlay/s6-rc.d/webhook/type @@ -0,0 +1 @@ +longrun From 3ea629e923382fe91582fd8c351915a1e15bc9f8 Mon Sep 17 00:00:00 2001 From: tuutti Date: Thu, 28 Mar 2024 10:39:40 +0200 Subject: [PATCH 3/4] Removed entrypoint --- .../files/usr/local/bin/entrypoint | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 openshift/drupal-repository/files/usr/local/bin/entrypoint diff --git a/openshift/drupal-repository/files/usr/local/bin/entrypoint b/openshift/drupal-repository/files/usr/local/bin/entrypoint deleted file mode 100644 index 93e4217..0000000 --- a/openshift/drupal-repository/files/usr/local/bin/entrypoint +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -# This script will be the default ENTRYPOINT for all children docker images. -# It just sources all files within /entrypoints/* in an alphabetical order and then runs `exec` on the given parameter. - -if [ -d /entrypoints ]; then - for i in /entrypoints/*; do - if [ -r $i ]; then - echo "# Source $i" - . $i - else - echo "! $i not sourced" - fi - done - unset i -fi - -echo "Exec: $@" -exec "$@" From 280fe1bf3b084cf4861814c5a4f19d537c59d191 Mon Sep 17 00:00:00 2001 From: tuutti Date: Fri, 29 Mar 2024 08:37:07 +0200 Subject: [PATCH 4/4] Build arm64 image --- openshift/drupal-repository/Makefile | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/openshift/drupal-repository/Makefile b/openshift/drupal-repository/Makefile index 4bca48c..26dbfe8 100644 --- a/openshift/drupal-repository/Makefile +++ b/openshift/drupal-repository/Makefile @@ -4,16 +4,11 @@ ifeq ($(TAG),) TAG = latest endif -.PHONY: build push release +.PHONY: push release -default: build - -run: - docker run -it --rm -u 100000 $(REPOSITORY):$(TAG) /bin/sh -build: - docker build -t $(REPOSITORY):$(TAG) ./ +default: push push: - docker push $(REPOSITORY):$(TAG) + docker buildx build --pull --platform linux/arm64,linux/amd64 -t $(REPOSITORY):$(TAG) ./ --push release: build push