From 7c01409231153ef1e73cddaee97e5815457c5d37 Mon Sep 17 00:00:00 2001 From: Tim Jackson Date: Fri, 17 Oct 2025 17:00:18 +0200 Subject: [PATCH] Fix #329: Fails to start with node syntax errors (#330) * Fix #329: Fails to start with node syntax errors * s6 v3: Don't try to send commands to the supervision tree, per https://github.com/just-containers/s6-overlay/blob/master/MOVING-TO-V3.md * Updates to build process to set the correct permissions, as well as through cont-init.d as well as set a fixed (more modern) base image * Fix build to actually be locked to a specified version of the base image Update to base image 18.2.0 --- plejd/Dockerfile | 21 +++++++++++++-------- plejd/build.json | 11 ----------- plejd/build.yaml | 6 ++++++ plejd/config.json | 1 + plejd/rootfs/etc/cont-init.d/10-plejd-perms | 4 ++++ plejd/rootfs/etc/services.d/plejd/finish | 8 -------- plejd/rootfs/etc/services.d/plejd/run | 4 ---- plejd/rootfs/usr/bin/plejd.sh | 0 8 files changed, 24 insertions(+), 31 deletions(-) delete mode 100644 plejd/build.json create mode 100644 plejd/build.yaml create mode 100755 plejd/rootfs/etc/cont-init.d/10-plejd-perms delete mode 100644 plejd/rootfs/etc/services.d/plejd/finish mode change 100644 => 100755 plejd/rootfs/etc/services.d/plejd/run mode change 100644 => 100755 plejd/rootfs/usr/bin/plejd.sh diff --git a/plejd/Dockerfile b/plejd/Dockerfile index 2b9213f..d51b9d8 100644 --- a/plejd/Dockerfile +++ b/plejd/Dockerfile @@ -1,7 +1,13 @@ -ARG BUILD_FROM=hassioaddons/base:14.2.2 +# To specify the base image version, edit build.yaml +# Specifying BUILD_FROM=image:version in this file doesn't work +ARG BUILD_FROM FROM $BUILD_FROM -ENV LANG C.UTF-8 +ENV LANG=C.UTF-8 + +# Instruct npm to run lifecycle scripts (like preinstall, install, postinstall) +# as the root user, instead of trying to downgrade permissions. +ENV NPM_CONFIG_UNSAFE_PERM=true # Set shell SHELL ["/bin/bash", "-o", "pipefail", "-c"] @@ -14,8 +20,7 @@ COPY ./package.json /plejd/ ARG BUILD_ARCH # Install Node -RUN apk add --no-cache jq -RUN \ +RUN set -eux; \ apk add --no-cache --virtual .build-dependencies \ g++ \ gcc \ @@ -32,9 +37,7 @@ RUN \ nodejs \ npm \ dbus-dev \ - glib-dev \ - \ - && npm config set unsafe-perm true + glib-dev WORKDIR /plejd RUN npm install \ @@ -44,6 +47,9 @@ RUN npm install \ # Copy root filesystem COPY rootfs / +# Ensure runtime scripts remain executable even if modes were lost in the source checkout +RUN set -eux; \ + chmod 0755 /etc/services.d/plejd/run /etc/cont-init.d/10-plejd-perms /usr/bin/plejd.sh # Build arguments ARG BUILD_DATE @@ -65,4 +71,3 @@ LABEL \ org.label-schema.usage="https://github.com/icanos/hassio-plejd/tree/master/README.md" \ org.label-schema.vcs-ref=${BUILD_REF} \ org.label-schema.vcs-url="https://github.com/icanos/hassio-plejd" - diff --git a/plejd/build.json b/plejd/build.json deleted file mode 100644 index 1afb131..0000000 --- a/plejd/build.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "squash": false, - "build_from": { - "aarch64": "hassioaddons/base-aarch64:8.0.6", - "amd64": "hassioaddons/base-amd64:8.0.6", - "armhf": "hassioaddons/base-armhf:8.0.6", - "armv7": "hassioaddons/base-armv7:8.0.6", - "i386": "hassioaddons/base-i386:8.0.6" - }, - "args": {} -} diff --git a/plejd/build.yaml b/plejd/build.yaml new file mode 100644 index 0000000..7a1e009 --- /dev/null +++ b/plejd/build.yaml @@ -0,0 +1,6 @@ +build_from: + armhf: ghcr.io/hassio-addons/base/armhf:18.2.0 + armv7: ghcr.io/hassio-addons/base/armv7:18.2.0 + aarch64: ghcr.io/hassio-addons/base/aarch64:18.2.0 + amd64: ghcr.io/hassio-addons/base/amd64:18.2.0 + i386: ghcr.io/hassio-addons/base/i386:18.2.0 diff --git a/plejd/config.json b/plejd/config.json index 5c6eab2..84f9d73 100644 --- a/plejd/config.json +++ b/plejd/config.json @@ -10,6 +10,7 @@ "host_network": true, "host_dbus": true, "apparmor": false, + "init": false, "options": { "site": "Default Site", "username": "", diff --git a/plejd/rootfs/etc/cont-init.d/10-plejd-perms b/plejd/rootfs/etc/cont-init.d/10-plejd-perms new file mode 100755 index 0000000..4074ba6 --- /dev/null +++ b/plejd/rootfs/etc/cont-init.d/10-plejd-perms @@ -0,0 +1,4 @@ +#!/usr/bin/with-contenv bashio + +bashio::log.info 'Ensuring Plejd scripts are executable' +chmod 0755 /etc/services.d/plejd/run /usr/bin/plejd.sh || bashio::exit.nok 'Failed to set permissions' diff --git a/plejd/rootfs/etc/services.d/plejd/finish b/plejd/rootfs/etc/services.d/plejd/finish deleted file mode 100644 index 97dd55a..0000000 --- a/plejd/rootfs/etc/services.d/plejd/finish +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/execlineb -S0 -# ============================================================================== -# Community Hass.io Add-ons: Plejd -# ============================================================================== -if -n { s6-test $# -ne 0 } -if -n { s6-test ${1} -eq 256 } - -s6-svscanctl -t /var/run/s6/services diff --git a/plejd/rootfs/etc/services.d/plejd/run b/plejd/rootfs/etc/services.d/plejd/run old mode 100644 new mode 100755 index 409652c..7aa83a6 --- a/plejd/rootfs/etc/services.d/plejd/run +++ b/plejd/rootfs/etc/services.d/plejd/run @@ -5,14 +5,10 @@ # ============================================================================== bashio::log.info 'Starting the Plejd service...' -bashio::log.info 'Docker env updated 2023-10-17...' # Change working directory cd /plejd || bashio::exit.nok 'Unable to change working directory' # Run the Plejd service -bashio::log.info 'Verified permissions on startup script' -chmod +x /usr/bin/plejd.sh - bashio::log.info 'Executing startup script' exec /usr/bin/plejd.sh diff --git a/plejd/rootfs/usr/bin/plejd.sh b/plejd/rootfs/usr/bin/plejd.sh old mode 100644 new mode 100755