diff --git a/Dockerfile b/Dockerfile index 531b756..dada1f1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,6 +33,29 @@ RUN \ /root-out && \ sed -i -e 's/^root::/root:!:/' /root-out/etc/shadow +# set version for s6 overlay +ARG S6_OVERLAY_VERSION="3.1.0.1" +ARG S6_OVERLAY_ARCH="x86_64" + +# add s6 overlay +ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp +RUN tar -C /root-out -Jxpf /tmp/s6-overlay-noarch.tar.xz +ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${S6_OVERLAY_ARCH}.tar.xz /tmp +RUN tar -C /root-out -Jxpf /tmp/s6-overlay-${S6_OVERLAY_ARCH}.tar.xz + +# add s6 optional symlinks +ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-noarch.tar.xz /tmp +RUN tar -C /root-out -Jxpf /tmp/s6-overlay-symlinks-noarch.tar.xz +ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-arch.tar.xz /tmp +RUN tar -C /root-out -Jxpf /tmp/s6-overlay-symlinks-arch.tar.xz + +# copy ci-checks +COPY ci-check/ /root-out/package/admin/s6-overlay-${S6_OVERLAY_VERSION}/etc/s6-rc/sources/top/contents.d + +# patch cont-init for docker-mods +COPY patch/ /tmp/patch +RUN patch -u /root-out/package/admin/s6-overlay-${S6_OVERLAY_VERSION}/etc/s6-linux-init/skel/rc.init -i /tmp/patch/package/admin/s6-overlay-@VERSION@/etc/s6-linux-init/skel/rc.init.patch + # Runtime stage FROM scratch COPY --from=rootfs-stage /root-out/ / @@ -41,31 +64,18 @@ ARG VERSION LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}" LABEL maintainer="TheLamer" -# set version for s6 overlay -ARG OVERLAY_VERSION="v2.2.0.3" -ARG OVERLAY_ARCH="amd64" - -# add s6 overlay -ADD https://github.com/just-containers/s6-overlay/releases/download/${OVERLAY_VERSION}/s6-overlay-${OVERLAY_ARCH}-installer /tmp/ -RUN chmod +x /tmp/s6-overlay-${OVERLAY_ARCH}-installer && /tmp/s6-overlay-${OVERLAY_ARCH}-installer / && rm /tmp/s6-overlay-${OVERLAY_ARCH}-installer -COPY patch/ /tmp/patch - # environment variables ENV PS1="$(whoami)@$(hostname):$(pwd)\\$ " \ HOME="/root" \ TERM="xterm" RUN \ - echo "**** install build packages ****" && \ - apk add --no-cache --virtual=build-dependencies \ - curl \ - patch \ - tar && \ echo "**** install runtime packages ****" && \ apk add --no-cache \ bash \ ca-certificates \ coreutils \ + curl \ procps \ shadow \ tzdata && \ @@ -77,11 +87,7 @@ RUN \ /app \ /config \ /defaults && \ - mv /usr/bin/with-contenv /usr/bin/with-contenvb && \ - patch -u /etc/s6/init/init-stage2 -i /tmp/patch/etc/s6/init/init-stage2.patch && \ echo "**** cleanup ****" && \ - apk del --purge \ - build-dependencies && \ rm -rf \ /tmp/* diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index 8eb7662..d7b13c0 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -33,6 +33,29 @@ RUN \ /root-out && \ sed -i -e 's/^root::/root:!:/' /root-out/etc/shadow +# set version for s6 overlay +ARG S6_OVERLAY_VERSION="3.1.0.1" +ARG S6_OVERLAY_ARCH="x86_64" + +# add s6 overlay +ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp +RUN tar -C /root-out -Jxpf /tmp/s6-overlay-noarch.tar.xz +ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${S6_OVERLAY_ARCH}.tar.xz /tmp +RUN tar -C /root-out -Jxpf /tmp/s6-overlay-${S6_OVERLAY_ARCH}.tar.xz + +# add s6 optional symlinks +ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-noarch.tar.xz /tmp +RUN tar -C /root-out -Jxpf /tmp/s6-overlay-symlinks-noarch.tar.xz +ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-arch.tar.xz /tmp +RUN tar -C /root-out -Jxpf /tmp/s6-overlay-symlinks-arch.tar.xz + +# copy ci-checks +COPY ci-check/ /root-out/package/admin/s6-overlay-${S6_OVERLAY_VERSION}/etc/s6-rc/sources/top/contents.d + +# patch cont-init for docker-mods +COPY patch/ /tmp/patch +RUN patch -u /root-out/package/admin/s6-overlay-${S6_OVERLAY_VERSION}/etc/s6-linux-init/skel/rc.init -i /tmp/patch/package/admin/s6-overlay-@VERSION@/etc/s6-linux-init/skel/rc.init.patch + # Runtime stage FROM scratch COPY --from=rootfs-stage /root-out/ / @@ -41,31 +64,18 @@ ARG VERSION LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}" LABEL maintainer="TheLamer" -# set version for s6 overlay -ARG OVERLAY_VERSION="v2.2.0.3" -ARG OVERLAY_ARCH="aarch64" - -# add s6 overlay -ADD https://github.com/just-containers/s6-overlay/releases/download/${OVERLAY_VERSION}/s6-overlay-${OVERLAY_ARCH}-installer /tmp/ -RUN chmod +x /tmp/s6-overlay-${OVERLAY_ARCH}-installer && /tmp/s6-overlay-${OVERLAY_ARCH}-installer / && rm /tmp/s6-overlay-${OVERLAY_ARCH}-installer -COPY patch/ /tmp/patch - # environment variables ENV PS1="$(whoami)@$(hostname):$(pwd)\\$ " \ HOME="/root" \ TERM="xterm" RUN \ - echo "**** install build packages ****" && \ - apk add --no-cache --virtual=build-dependencies \ - curl \ - patch \ - tar && \ echo "**** install runtime packages ****" && \ apk add --no-cache \ bash \ ca-certificates \ coreutils \ + curl \ procps \ shadow \ tzdata && \ @@ -77,16 +87,12 @@ RUN \ /app \ /config \ /defaults && \ - mv /usr/bin/with-contenv /usr/bin/with-contenvb && \ - patch -u /etc/s6/init/init-stage2 -i /tmp/patch/etc/s6/init/init-stage2.patch && \ echo "**** add qemu ****" && \ curl -o \ /usr/bin/qemu-aarch64-static -L \ "https://lsio-ci.ams3.digitaloceanspaces.com/qemu-aarch64-static" && \ chmod +x /usr/bin/qemu-aarch64-static && \ echo "**** cleanup ****" && \ - apk del --purge \ - build-dependencies && \ rm -rf \ /tmp/* diff --git a/Dockerfile.armhf b/Dockerfile.armhf index b60730c..c9a317a 100644 --- a/Dockerfile.armhf +++ b/Dockerfile.armhf @@ -33,6 +33,29 @@ RUN \ /root-out && \ sed -i -e 's/^root::/root:!:/' /root-out/etc/shadow +# set version for s6 overlay +ARG S6_OVERLAY_VERSION="3.1.0.1" +ARG S6_OVERLAY_ARCH="x86_64" + +# add s6 overlay +ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp +RUN tar -C /root-out -Jxpf /tmp/s6-overlay-noarch.tar.xz +ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${S6_OVERLAY_ARCH}.tar.xz /tmp +RUN tar -C /root-out -Jxpf /tmp/s6-overlay-${S6_OVERLAY_ARCH}.tar.xz + +# add s6 optional symlinks +ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-noarch.tar.xz /tmp +RUN tar -C /root-out -Jxpf /tmp/s6-overlay-symlinks-noarch.tar.xz +ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-arch.tar.xz /tmp +RUN tar -C /root-out -Jxpf /tmp/s6-overlay-symlinks-arch.tar.xz + +# copy ci-checks +COPY ci-check/ /root-out/package/admin/s6-overlay-${S6_OVERLAY_VERSION}/etc/s6-rc/sources/top/contents.d + +# patch cont-init for docker-mods +COPY patch/ /tmp/patch +RUN patch -u /root-out/package/admin/s6-overlay-${S6_OVERLAY_VERSION}/etc/s6-linux-init/skel/rc.init -i /tmp/patch/package/admin/s6-overlay-@VERSION@/etc/s6-linux-init/skel/rc.init.patch + # Runtime stage FROM scratch COPY --from=rootfs-stage /root-out/ / @@ -41,31 +64,18 @@ ARG VERSION LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}" LABEL maintainer="TheLamer" -# set version for s6 overlay -ARG OVERLAY_VERSION="v2.2.0.3" -ARG OVERLAY_ARCH="arm" - -# add s6 overlay -ADD https://github.com/just-containers/s6-overlay/releases/download/${OVERLAY_VERSION}/s6-overlay-${OVERLAY_ARCH}-installer /tmp/ -RUN chmod +x /tmp/s6-overlay-${OVERLAY_ARCH}-installer && /tmp/s6-overlay-${OVERLAY_ARCH}-installer / && rm /tmp/s6-overlay-${OVERLAY_ARCH}-installer -COPY patch/ /tmp/patch - # environment variables ENV PS1="$(whoami)@$(hostname):$(pwd)\\$ " \ HOME="/root" \ TERM="xterm" RUN \ - echo "**** install build packages ****" && \ - apk add --no-cache --virtual=build-dependencies \ - curl \ - patch \ - tar && \ echo "**** install runtime packages ****" && \ apk add --no-cache \ bash \ ca-certificates \ coreutils \ + curl \ procps \ shadow \ tzdata && \ @@ -77,16 +87,12 @@ RUN \ /app \ /config \ /defaults && \ - mv /usr/bin/with-contenv /usr/bin/with-contenvb && \ - patch -u /etc/s6/init/init-stage2 -i /tmp/patch/etc/s6/init/init-stage2.patch && \ echo "**** add qemu ****" && \ curl -o \ /usr/bin/qemu-arm-static -L \ "https://lsio-ci.ams3.digitaloceanspaces.com/qemu-arm-static" && \ chmod +x /usr/bin/qemu-arm-static && \ echo "**** cleanup ****" && \ - apk del --purge \ - build-dependencies && \ rm -rf \ /tmp/* diff --git a/ci-check/99-ci-service-check b/ci-check/99-ci-service-check new file mode 100644 index 0000000..e69de29 diff --git a/patch/etc/s6/init/init-stage2.patch b/patch/etc/s6/init/init-stage2.patch deleted file mode 100644 index db176f8..0000000 --- a/patch/etc/s6/init/init-stage2.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- init-stage2 2021-01-20 20:21:41.628300700 -0600 -+++ init-stage2_new 2021-01-20 20:23:48.123677700 -0600 -@@ -17,6 +17,12 @@ - backtick -D 0 -n S6_READ_ONLY_ROOT { printcontenv S6_READ_ONLY_ROOT } - importas -u S6_READ_ONLY_ROOT S6_READ_ONLY_ROOT - -+# Docker Mods run logic -+foreground -+{ -+ /docker-mods -+} -+ - foreground - { - if diff --git a/patch/package/admin/s6-overlay-@VERSION@/etc/s6-linux-init/skel/rc.init.patch b/patch/package/admin/s6-overlay-@VERSION@/etc/s6-linux-init/skel/rc.init.patch new file mode 100644 index 0000000..b01a7f0 --- /dev/null +++ b/patch/package/admin/s6-overlay-@VERSION@/etc/s6-linux-init/skel/rc.init.patch @@ -0,0 +1,11 @@ +--- rc.init 2022-05-20 17:41:11.195721000 -0500 ++++ rc.init.patched 2022-05-20 17:41:37.646586700 -0500 +@@ -6,6 +6,8 @@ + s6-chmod 0755 /run/s6/container_environment + fi + ++/docker-mods ++ + if profile=`printcontenv S6_RUNTIME_PROFILE` ; then + etc="/etc/cont-profile.d/$profile" + else diff --git a/root/docker-mods b/root/docker-mods index 9bd9231..732f167 100755 --- a/root/docker-mods +++ b/root/docker-mods @@ -1,5 +1,14 @@ #!/usr/bin/with-contenv bash +# Set executable bit on cont-init and services built into the image +set_legacy_executable_bits() { + mkdir -p /etc/{cont-init.d,services.d} + chmod +x \ + /etc/cont-init.d/* \ + /etc/services.d/*/* 2> /dev/null || true +} +set_legacy_executable_bits + # Exit if mods is not set if [ -z ${DOCKER_MODS+x} ]; then exit 0 @@ -119,3 +128,6 @@ for DOCKER_MOD in "${DOCKER_MODS[@]}"; do echo ${SHALAYER} > "/${FILENAME}" fi done + +# Set executable bit on cont-init and services that may have been unpacked by mods +set_legacy_executable_bits diff --git a/root/etc/cont-init.d/01-envfile b/root/etc/cont-init.d/01-envfile old mode 100644 new mode 100755 diff --git a/root/etc/cont-init.d/02-tamper-check b/root/etc/cont-init.d/02-tamper-check old mode 100644 new mode 100755 diff --git a/root/etc/cont-init.d/10-adduser b/root/etc/cont-init.d/10-adduser old mode 100644 new mode 100755 diff --git a/root/etc/cont-init.d/90-custom-folders b/root/etc/cont-init.d/90-custom-folders old mode 100644 new mode 100755 diff --git a/root/etc/cont-init.d/99-custom-files b/root/etc/cont-init.d/99-custom-files old mode 100644 new mode 100755 diff --git a/root/etc/s6-overlay/s6-rc.d/99-ci-service-check/dependencies.d/base b/root/etc/s6-overlay/s6-rc.d/99-ci-service-check/dependencies.d/base new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/s6-overlay/s6-rc.d/99-ci-service-check/dependencies.d/legacy-services b/root/etc/s6-overlay/s6-rc.d/99-ci-service-check/dependencies.d/legacy-services new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/s6-overlay/s6-rc.d/99-ci-service-check/dependencies.d/user b/root/etc/s6-overlay/s6-rc.d/99-ci-service-check/dependencies.d/user new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/s6-overlay/s6-rc.d/99-ci-service-check/type b/root/etc/s6-overlay/s6-rc.d/99-ci-service-check/type new file mode 100644 index 0000000..bdd22a1 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/99-ci-service-check/type @@ -0,0 +1 @@ +oneshot diff --git a/root/etc/s6-overlay/s6-rc.d/99-ci-service-check/up b/root/etc/s6-overlay/s6-rc.d/99-ci-service-check/up new file mode 100644 index 0000000..e0f9488 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/99-ci-service-check/up @@ -0,0 +1 @@ +echo "[ls.io-init] done." \ No newline at end of file diff --git a/root/usr/bin/with-contenv b/root/usr/bin/with-contenv index b535def..e26f8f4 100755 --- a/root/usr/bin/with-contenv +++ b/root/usr/bin/with-contenv @@ -1,7 +1,7 @@ #! /bin/bash if [[ -f /var/run/s6/container_environment/UMASK ]] && [[ "$(pwdx $$)" =~ "/run/s6/services/" ]]; then umask $(cat /var/run/s6/container_environment/UMASK) - exec /usr/bin/with-contenvb "$@" + exec /command/with-contenv "$@" else - exec /usr/bin/with-contenvb "$@" + exec /command/with-contenv "$@" fi