From f3dc8291118a162faf604f67c5c22c70fc318bab Mon Sep 17 00:00:00 2001 From: MrMeeb Date: Sat, 27 May 2023 17:49:19 +0000 Subject: [PATCH 1/6] get correct s6 for architecture --- Dockerfile | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index a0be22a..ffb34cf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,13 @@ -FROM alpine:latest +FROM alpine:latest as base +ARG TARGETARCH + +FROM base AS base-amd64 +ENV S6_OVERLAY_ARCH=x86_64 + +FROM base AS base-arm64 +ENV S6_OVERLAY_ARCH=aarch64 + +FROM base-${TARGETARCH}${TARGETVARIANT} ARG S6_OVERLAY_VERSION=3.1.5.0 @@ -23,7 +32,7 @@ RUN mkdir /config && \ #Install s6-overlay RUN curl -fsSL "https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz" | tar Jpxf - -C / && \ - curl -fsSL "https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-x86_64.tar.xz" | tar Jpxf - -C / && \ + curl -fsSL "https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${S6_OVERLAY_ARCH}.tar.xz" | tar Jpxf - -C / && \ curl -fsSL "https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-noarch.tar.xz" | tar Jpxf - -C / && \ curl -fsSL "https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-arch.tar.xz" | tar Jpxf - -C / ENV S6_BEHAVIOUR_IF_STAGE2_FAILS=2 S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 S6_VERBOSITY=1 From bfbc0e22d77c8194a751d17ca6e26b910c6028ae Mon Sep 17 00:00:00 2001 From: MrMeeb Date: Sat, 27 May 2023 18:15:12 +0000 Subject: [PATCH 2/6] fix not hooking conf in if already setup --- root/cronicle-prepare.sh | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/root/cronicle-prepare.sh b/root/cronicle-prepare.sh index a0bd1a2..95c9d1c 100644 --- a/root/cronicle-prepare.sh +++ b/root/cronicle-prepare.sh @@ -42,9 +42,19 @@ then #Copying config directory to /config/cronicle/conf if not already there, then linking back into Cronicle if [ ! -d /config/cronicle/conf ] then + + echo "Config dir is missing, creating." + cp -r /app/cronicle/conf /config/cronicle/conf rm -rf /app/cronicle/conf ln -s /config/cronicle/conf /app/cronicle/conf + else + + echo "Config dir already exists. Doesn't need creating." + echo "Linking persistent config dir back into Cronicle." + rm -rf /app/cronicle/conf + ln -s /config/cronicle/conf /app/cronicle/conf + fi if [ ! -f /config/cronicle/data/.setup_done ] @@ -60,8 +70,6 @@ then rm -rf /app/cronicle/data ln -s /config/cronicle/data /app/cronicle/data - #exec node /app/cronicle/lib/main.js --color 1 - else echo "Setup already completed." @@ -69,8 +77,6 @@ then rm -rf /app/cronicle/data ln -s /config/cronicle/data /app/cronicle/data - #exec node /app/cronicle/lib/main.js --color 1 - fi elif [ $MODE == "worker" ] @@ -89,9 +95,7 @@ then #Removing default config.json and linking provided one back into Cronicle rm -rf /app/cronicle/conf/config.json - ln -s /config/config.json /app/cronicle/conf/config.json - - #exec node /app/cronicle/lib/main.js --color 1 + ln -s /config/cronicle/conf/config.json /app/cronicle/conf/config.json fi @@ -99,9 +103,4 @@ else echo "'$MODE' is not a recognised appion for the MODE environment variable. Accepted appions are 'manager' and 'worker'." -fi - -#echo "Applying permissions to /config and /app (this can take a while on first run or after PUID/PGID changes)" -#chmod "=rwx" /config -#chown -R mrmeeb:mrmeeb /config -#chown -R mrmeeb:mrmeeb /app \ No newline at end of file +fi \ No newline at end of file From f1f322d58a6bd9e689486efb2f917794e8aa9240 Mon Sep 17 00:00:00 2001 From: MrMeeb Date: Sat, 27 May 2023 18:46:23 +0000 Subject: [PATCH 3/6] rename user to cronicle --- Dockerfile | 7 ++----- root/container-init.sh | 12 ++++++------ root/etc/s6-overlay/s6-rc.d/cronicle-prepare/up | 2 +- root/etc/s6-overlay/s6-rc.d/cronicle/run | 2 +- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index ffb34cf..8c2366b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,8 +27,8 @@ RUN apk update && apk add tzdata curl shadow bash xz git procps nodejs npm RUN mkdir /config && \ mkdir /app && \ #Create default user - useradd -u 1000 -U -d /config -s /bin/false mrmeeb && \ - usermod -G users mrmeeb + useradd -u 1000 -U -d /config -s /bin/false cronicle && \ + usermod -G users cronicle #Install s6-overlay RUN curl -fsSL "https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz" | tar Jpxf - -C / && \ @@ -44,9 +44,6 @@ RUN npm install && \ node bin/build dist RUN rm -rf /app/cronicle/Docker* .vscode -#Create Cronicle user, necessary for SSH plugin with default settings -RUN adduser --disabled-password --no-create-home cronicle - COPY root/ / RUN chmod +x /cronicle-prepare.sh && \ chmod +x /container-init.sh diff --git a/root/container-init.sh b/root/container-init.sh index c6e6821..ff45c08 100644 --- a/root/container-init.sh +++ b/root/container-init.sh @@ -28,11 +28,11 @@ MODE=${MODE} if [[ ! "${PUID}" -eq 0 ]] && [[ ! "${PGID}" -eq 0 ]]; then echo "Executing usermod..." mkdir "/tmp/temphome" - usermod -d "/tmp/temphome" mrmeeb - usermod -o -u "${PUID}" mrmeeb - usermod -d /config mrmeeb + usermod -d "/tmp/temphome" cronicle + usermod -o -u "${PUID}" cronicle + usermod -d /config cronicle rm -rf "/tmp/temphome" - groupmod -o -g "${PGID}" mrmeeb + groupmod -o -g "${PGID}" cronicle else echo "Running as root is not supported, please fix your PUID and PGID!" exit 1 @@ -43,11 +43,11 @@ echo "Checking permissions in /config and /app (this can take some time)." if [ ! "$(stat -c %u /app)" -eq "${PUID}" ] || [ ! "$(stat -c %g /app)" -eq "${PGID}" ] then echo "Fixing permissions for /app." - chown -R mrmeeb:mrmeeb /app + chown -R cronicle:cronicle /app fi if [ ! "$(stat -c %u /config)" -eq "${PUID}" ] || [ ! "$(stat -c %g /config)" -eq "${PGID}" ] then echo "Fixing permissions for /config." - chown -R mrmeeb:mrmeeb /config + chown -R cronicle:cronicle /config fi \ No newline at end of file diff --git a/root/etc/s6-overlay/s6-rc.d/cronicle-prepare/up b/root/etc/s6-overlay/s6-rc.d/cronicle-prepare/up index 5c021c4..c4512f8 100644 --- a/root/etc/s6-overlay/s6-rc.d/cronicle-prepare/up +++ b/root/etc/s6-overlay/s6-rc.d/cronicle-prepare/up @@ -1 +1 @@ -exec s6-setuidgid mrmeeb /cronicle-prepare.sh \ No newline at end of file +exec s6-setuidgid cronicle /cronicle-prepare.sh \ No newline at end of file diff --git a/root/etc/s6-overlay/s6-rc.d/cronicle/run b/root/etc/s6-overlay/s6-rc.d/cronicle/run index d41cf93..ffe517e 100644 --- a/root/etc/s6-overlay/s6-rc.d/cronicle/run +++ b/root/etc/s6-overlay/s6-rc.d/cronicle/run @@ -1,3 +1,3 @@ #!/command/with-contenv bash # shellcheck shell=bash -exec s6-setuidgid mrmeeb node /app/cronicle/lib/main.js --color 1 \ No newline at end of file +exec s6-setuidgid cronicle node /app/cronicle/lib/main.js --color 1 \ No newline at end of file From 76cdb2640e760150e5553639b52b66a842c97e16 Mon Sep 17 00:00:00 2001 From: MrMeeb Date: Sat, 27 May 2023 21:53:40 +0000 Subject: [PATCH 4/6] fix to defined cronicle version --- Dockerfile | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8c2366b..d9fb0e2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,7 @@ ENV S6_OVERLAY_ARCH=aarch64 FROM base-${TARGETARCH}${TARGETVARIANT} ARG S6_OVERLAY_VERSION=3.1.5.0 +ARG CRONICLE_EDGE_VERSION=1.6.2 ENV CRONICLE_foreground=1 ENV CRONICLE_echo=1 @@ -38,11 +39,16 @@ RUN curl -fsSL "https://github.com/just-containers/s6-overlay/releases/download/ ENV S6_BEHAVIOUR_IF_STAGE2_FAILS=2 S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 S6_VERBOSITY=1 #Install Cronicle -RUN git clone https://github.com/cronicle-edge/cronicle-edge.git /app/cronicle +RUN mkdir /app/cronicle && \ + cd /app/cronicle && \ + wget https://github.com/cronicle-edge/cronicle-edge/archive/refs/tags/v${CRONICLE_EDGE_VERSION}.tar.gz && \ + tar -xf v${CRONICLE_EDGE_VERSION}.tar.gz --strip-components 1 && \ + rm -rf /app/cronicle/Docker* && \ + rm -rf v${CRONICLE_EDGE_VERSION}.tar.gz + WORKDIR /app/cronicle RUN npm install && \ node bin/build dist -RUN rm -rf /app/cronicle/Docker* .vscode COPY root/ / RUN chmod +x /cronicle-prepare.sh && \ From ab731325539bfc8182502b3def8d8b1424cb0201 Mon Sep 17 00:00:00 2001 From: MrMeeb Date: Sat, 27 May 2023 21:58:31 +0000 Subject: [PATCH 5/6] set permissions to 1000 at build --- Dockerfile | 3 ++- root/container-init.sh | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index d9fb0e2..947b202 100644 --- a/Dockerfile +++ b/Dockerfile @@ -52,7 +52,8 @@ RUN npm install && \ COPY root/ / RUN chmod +x /cronicle-prepare.sh && \ - chmod +x /container-init.sh + chmod +x /container-init.sh && \ + chown -R ${PUID}:${PGID} /app /config EXPOSE 3012 diff --git a/root/container-init.sh b/root/container-init.sh index ff45c08..394615d 100644 --- a/root/container-init.sh +++ b/root/container-init.sh @@ -38,16 +38,16 @@ else exit 1 fi -echo "Checking permissions in /config and /app (this can take some time)." +echo "Checking permissions in /config and /app." if [ ! "$(stat -c %u /app)" -eq "${PUID}" ] || [ ! "$(stat -c %g /app)" -eq "${PGID}" ] then - echo "Fixing permissions for /app." + echo "Fixing permissions for /app (this can take some time)." chown -R cronicle:cronicle /app fi if [ ! "$(stat -c %u /config)" -eq "${PUID}" ] || [ ! "$(stat -c %g /config)" -eq "${PGID}" ] then - echo "Fixing permissions for /config." + echo "Fixing permissions for /config (this can take some time)." chown -R cronicle:cronicle /config fi \ No newline at end of file From 6ac07ec9a0571e6efa7a12c529add9cf494b05cf Mon Sep 17 00:00:00 2001 From: MrMeeb Date: Sat, 27 May 2023 22:05:58 +0000 Subject: [PATCH 6/6] cleanup misc files in app dir --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 947b202..ada529c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,7 +43,7 @@ RUN mkdir /app/cronicle && \ cd /app/cronicle && \ wget https://github.com/cronicle-edge/cronicle-edge/archive/refs/tags/v${CRONICLE_EDGE_VERSION}.tar.gz && \ tar -xf v${CRONICLE_EDGE_VERSION}.tar.gz --strip-components 1 && \ - rm -rf /app/cronicle/Docker* && \ + rm -rf Docker* .gitignore Readme.md .vscode && \ rm -rf v${CRONICLE_EDGE_VERSION}.tar.gz WORKDIR /app/cronicle