From 48b082b7a68924b1f4448882496fb2cbf0ef4e4a Mon Sep 17 00:00:00 2001 From: Amir Zarrinkafsh Date: Sat, 16 Oct 2021 20:27:21 +1100 Subject: [PATCH 1/3] refactor: replace supervisord with s6 This change looks to drop the python dependency in the base image and replaces supervisord with [s6](https://github.com/just-containers/s6-overlay). If we could get this branch pushed to the `s6` tag on Docker it will allow us to test this with the downstream containers. I will update the README.md if it's decided that we will adopt s6 over supervisord. --- Dockerfile | 38 ++++++----- goss.yaml | 2 +- overlay/etc/cont-init.d/00-asciilogo | 12 ++++ overlay/etc/supervisor/conf.d/.gitkeep | 0 overlay/etc/supervisor/supervisord.conf | 18 ----- overlay/hooks/.gitkeep | 0 overlay/hooks/entrypoint-pre.d/.gitkeep | 0 .../hooks/entrypoint-pre.d/00_asciilogo.sh | 9 --- overlay/hooks/supervisord-pre.d/.gitkeep | 0 overlay/init/entrypoint | 68 ------------------- overlay/init/supervisord | 31 --------- run-tests.sh | 8 +-- 12 files changed, 35 insertions(+), 151 deletions(-) create mode 100644 overlay/etc/cont-init.d/00-asciilogo delete mode 100644 overlay/etc/supervisor/conf.d/.gitkeep delete mode 100644 overlay/etc/supervisor/supervisord.conf delete mode 100644 overlay/hooks/.gitkeep delete mode 100644 overlay/hooks/entrypoint-pre.d/.gitkeep delete mode 100644 overlay/hooks/entrypoint-pre.d/00_asciilogo.sh delete mode 100644 overlay/hooks/supervisord-pre.d/.gitkeep delete mode 100755 overlay/init/entrypoint delete mode 100755 overlay/init/supervisord diff --git a/Dockerfile b/Dockerfile index 7d58fce..d2ca65a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,28 @@ FROM ubuntu:24.04 LABEL maintainer="LanCache.Net Team " -ARG DEBIAN_FRONTEND=noninteractive -RUN \ - apt-get -y update && apt-get -y upgrade && \ - apt-get -y install supervisor curl wget bzip2 locales tzdata --no-install-recommends && \ - locale-gen en_GB.utf8 && \ - update-locale LANG=en_GB.utf8 && \ - apt-get -y clean && \ - rm -rf /var/lib/apt/lists/* +ARG DEBIAN_FRONTEND=noninteractive +ARG ARCH="amd64" +ARG OVERLAY_VERSION="v2.2.0.3" ENV \ - SUPERVISORD_EXIT_ON_FATAL=1 \ - LC_ALL=en_GB.UTF-8 \ - LANG=en_GB.UTF-8 \ - LANGUAGE=en_GB.UTF-8 \ - TZ=Europe/London \ - SUPERVISORD_LOGLEVEL=WARN + S6_BEHAVIOUR_IF_STAGE2_FAILS=2 \ + LC_ALL=en_GB.UTF-8 \ + LANG=en_GB.UTF-8 \ + LANGUAGE=en_GB.UTF-8 \ + TZ=Europe/London COPY overlay/ / -RUN chmod -R 755 /init /hooks -ENTRYPOINT ["/bin/bash", "-e", "/init/entrypoint"] -CMD ["/init/supervisord"] + +RUN \ + apt-get -y update && apt-get -y upgrade && \ + apt-get -y install curl wget bzip2 locales tzdata --no-install-recommends && \ + locale-gen en_GB.utf8 && \ + update-locale LANG=en_GB.utf8 \ + cd /tmp && \ + curl -sSfL -o s6-overlay.tar.gz "https://github.com/just-containers/s6-overlay/releases/download/${OVERLAY_VERSION}/s6-overlay-${ARCH}.tar.gz" && \ + tar xfz s6-overlay.tar.gz -C / && \ + apt-get -y clean && \ + rm -rf /tmp/* /var/lib/apt/lists/* + +ENTRYPOINT ["/init"] diff --git a/goss.yaml b/goss.yaml index b4d2b90..d3269ae 100644 --- a/goss.yaml +++ b/goss.yaml @@ -6,5 +6,5 @@ package: wget: installed: true process: - supervisord: + s6-svscan: running: true diff --git a/overlay/etc/cont-init.d/00-asciilogo b/overlay/etc/cont-init.d/00-asciilogo new file mode 100644 index 0000000..fb94a67 --- /dev/null +++ b/overlay/etc/cont-init.d/00-asciilogo @@ -0,0 +1,12 @@ +#!/usr/bin/with-contenv bash + +cat < /dev/null || true - -entrypoint_pre=$(ls /hooks/entrypoint-pre.d/* 2>/dev/null | sort -n ) -if [ "$entrypoint_pre" != "" ]; then - for hook in $entrypoint_pre; do - echo "Executing hook ${hook}" - /bin/bash -c "${hook}" - if [ "$?" != "0" ]; then - die "hook ${hook}} returned a non-zero exit status '$?'" - fi - done -fi - -[[ -f "/hooks/entrypoint-pre" ]] && echo "The /hooks/entrypoint-pre hook has been replaced with /hooks/entrypoint-pre.d/*" && exit 1 - -[[ -f "/init/setup" ]] && /init/setup - -eval ${SETUP:-} - -case ${1} in - run) - check_depending_env - [[ -f "/hooks/entrypoint-run" ]] && /hooks/entrypoint-run - if [[ -e /init/supervisord && -d /etc/supervisor ]]; then - # Use exec so we replace our current process so signals can get through - exec /bin/bash /init/supervisord - else - exec /bin/bash - fi - ;; - *) - [[ -f "/hooks/entrypoint-exec" ]] && /hooks/entrypoint-exec - exec $* - ;; -esac diff --git a/overlay/init/supervisord b/overlay/init/supervisord deleted file mode 100755 index 5509a39..0000000 --- a/overlay/init/supervisord +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -[ ${DOCKER_DEBUG} ] && set -x - -die () { - echo "ERROR: ${1}" - exit 1 -} - -# PID, trap, wait; all belongs to 'docker stop' signal handeling. -# This is the same logic as the parent docker container, but rather this, -# than creating a one-time process in supervisord to handle this logic. -PID=; trap '[[ ${PID} ]] && kill ${PID}; exit 0' SIGTERM - -supervisord_pre=$(ls /hooks/supervisord-pre.d/* 2>/dev/null | sort -n ) -if [ "$supervisord_pre" != "" ]; then - for hook in $supervisord_pre; do - echo "Executing hook ${hook}" - /bin/bash -c "${hook}" - if [ "$?" != "0" ]; then - die "hook ${hook}} returned a non-zero exit status '$?'" - fi - done -fi - -[[ -f "/hooks/supervisord-pre" ]] && echo "The /hooks/supervisord-pre hook has been replaced with /hooks/supervisord-pre.d/*" && exit 1 -#[ -f "/hooks/supervisord-pre" ] && /hooks/supervisord-pre - -echo "Starting Supervisord" - -exec /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf -e ${SUPERVISORD_LOGLEVEL:-error} diff --git a/run-tests.sh b/run-tests.sh index beffdf4..1136f21 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -1,9 +1,3 @@ #!/bin/bash -if [[ "$@" == *" -- "* ]]; then - SD_LOGLEVEL="-e SUPERVISORD_LOGLEVEL=INFO" -else - SD_LOGLEVEL="-- -e SUPERVISORD_LOGLEVEL=INFO" -fi - -curl -fsSL https://raw.githubusercontent.com/lancachenet/test-suite/master/dgoss-tests.sh | bash -s -- --imagename="lancachenet/ubuntu:goss-test" $@ $SD_LOGLEVEL +curl -fsSL https://raw.githubusercontent.com/lancachenet/test-suite/master/dgoss-tests.sh | bash -s -- --imagename="lancachenet/ubuntu:goss-test" $@ From 044d4e56f7f1b7a1db7c6c02cdf515d4a6ba908a Mon Sep 17 00:00:00 2001 From: Amir Zarrinkafsh Date: Wed, 25 Sep 2024 10:20:44 +1000 Subject: [PATCH 2/3] feat: update to s6 v3 --- Dockerfile | 12 ++++++++---- goss.yaml | 2 -- .../s6-overlay/s6-rc.d/asciilogo/dependencies.d/base | 0 overlay/etc/s6-overlay/s6-rc.d/asciilogo/type | 1 + overlay/etc/s6-overlay/s6-rc.d/asciilogo/up | 1 + .../etc/s6-overlay/s6-rc.d/user/contents.d/asciilogo | 0 .../00-asciilogo => s6-overlay/scripts/asciilogo} | 2 +- 7 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 overlay/etc/s6-overlay/s6-rc.d/asciilogo/dependencies.d/base create mode 100644 overlay/etc/s6-overlay/s6-rc.d/asciilogo/type create mode 100644 overlay/etc/s6-overlay/s6-rc.d/asciilogo/up create mode 100644 overlay/etc/s6-overlay/s6-rc.d/user/contents.d/asciilogo rename overlay/etc/{cont-init.d/00-asciilogo => s6-overlay/scripts/asciilogo} (93%) mode change 100644 => 100755 diff --git a/Dockerfile b/Dockerfile index d2ca65a..01a4b96 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,10 +3,12 @@ LABEL maintainer="LanCache.Net Team " ARG DEBIAN_FRONTEND=noninteractive ARG ARCH="amd64" -ARG OVERLAY_VERSION="v2.2.0.3" +ARG ARCH_ALT="x86_64" +ARG OVERLAY_VERSION="3.2.0.0" ENV \ S6_BEHAVIOUR_IF_STAGE2_FAILS=2 \ + S6_VERBOSITY=1 \ LC_ALL=en_GB.UTF-8 \ LANG=en_GB.UTF-8 \ LANGUAGE=en_GB.UTF-8 \ @@ -16,12 +18,14 @@ COPY overlay/ / RUN \ apt-get -y update && apt-get -y upgrade && \ - apt-get -y install curl wget bzip2 locales tzdata --no-install-recommends && \ + apt-get -y install ca-certificates curl locales tzdata wget xz-utils --no-install-recommends && \ locale-gen en_GB.utf8 && \ update-locale LANG=en_GB.utf8 \ cd /tmp && \ - curl -sSfL -o s6-overlay.tar.gz "https://github.com/just-containers/s6-overlay/releases/download/${OVERLAY_VERSION}/s6-overlay-${ARCH}.tar.gz" && \ - tar xfz s6-overlay.tar.gz -C / && \ + curl -sSfL -o s6-overlay-noarch.tar.xz "https://github.com/just-containers/s6-overlay/releases/download/v${OVERLAY_VERSION}/s6-overlay-noarch.tar.xz" && \ + curl -sSfL -o s6-overlay.tar.xz "https://github.com/just-containers/s6-overlay/releases/download/v${OVERLAY_VERSION}/s6-overlay-${ARCH_ALT}.tar.xz" && \ + tar -C / -Jpxf s6-overlay-noarch.tar.xz && \ + tar -C / -Jpxf s6-overlay.tar.xz && \ apt-get -y clean && \ rm -rf /tmp/* /var/lib/apt/lists/* diff --git a/goss.yaml b/goss.yaml index d3269ae..de3fb7e 100644 --- a/goss.yaml +++ b/goss.yaml @@ -1,6 +1,4 @@ package: - bzip2: - installed: true curl: installed: true wget: diff --git a/overlay/etc/s6-overlay/s6-rc.d/asciilogo/dependencies.d/base b/overlay/etc/s6-overlay/s6-rc.d/asciilogo/dependencies.d/base new file mode 100644 index 0000000..e69de29 diff --git a/overlay/etc/s6-overlay/s6-rc.d/asciilogo/type b/overlay/etc/s6-overlay/s6-rc.d/asciilogo/type new file mode 100644 index 0000000..3d92b15 --- /dev/null +++ b/overlay/etc/s6-overlay/s6-rc.d/asciilogo/type @@ -0,0 +1 @@ +oneshot \ No newline at end of file diff --git a/overlay/etc/s6-overlay/s6-rc.d/asciilogo/up b/overlay/etc/s6-overlay/s6-rc.d/asciilogo/up new file mode 100644 index 0000000..4789af4 --- /dev/null +++ b/overlay/etc/s6-overlay/s6-rc.d/asciilogo/up @@ -0,0 +1 @@ +/etc/s6-overlay/scripts/asciilogo \ No newline at end of file diff --git a/overlay/etc/s6-overlay/s6-rc.d/user/contents.d/asciilogo b/overlay/etc/s6-overlay/s6-rc.d/user/contents.d/asciilogo new file mode 100644 index 0000000..e69de29 diff --git a/overlay/etc/cont-init.d/00-asciilogo b/overlay/etc/s6-overlay/scripts/asciilogo old mode 100644 new mode 100755 similarity index 93% rename from overlay/etc/cont-init.d/00-asciilogo rename to overlay/etc/s6-overlay/scripts/asciilogo index fb94a67..ddc81f0 --- a/overlay/etc/cont-init.d/00-asciilogo +++ b/overlay/etc/s6-overlay/scripts/asciilogo @@ -1,4 +1,4 @@ -#!/usr/bin/with-contenv bash +#!/command/with-contenv bash cat < Date: Wed, 25 Sep 2024 10:36:12 +1000 Subject: [PATCH 3/3] fix: circleci image deprecation --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8c95e0d..fe4e951 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -42,7 +42,7 @@ version: 2.1 executors: testbuild-executor: machine: - image: ubuntu-2004:202201-02 + image: default jobs: test: executor: testbuild-executor