turn into normal docker image (alpine) instead of hass-addon
This commit is contained in:
parent
3d8b323fb4
commit
1c3f0135f3
10 changed files with 61 additions and 164 deletions
|
|
@ -1,25 +1,7 @@
|
|||
# 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
|
||||
FROM alpine:3.23.2
|
||||
|
||||
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"]
|
||||
|
||||
# Copy data for add-on
|
||||
COPY ./*.js /plejd/
|
||||
COPY ./config.json /plejd/
|
||||
COPY ./package.json /plejd/
|
||||
|
||||
ARG BUILD_ARCH
|
||||
|
||||
# Install Node
|
||||
RUN set -eux; \
|
||||
apk add --no-cache --virtual .build-dependencies \
|
||||
g++ \
|
||||
|
|
@ -39,35 +21,18 @@ RUN set -eux; \
|
|||
dbus-dev \
|
||||
glib-dev
|
||||
|
||||
COPY ./package.json /plejd/
|
||||
WORKDIR /plejd
|
||||
RUN npm install \
|
||||
--no-audit \
|
||||
--no-update-notifier \
|
||||
--unsafe-perm
|
||||
|
||||
# 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
|
||||
COPY ./*.js /plejd/
|
||||
COPY ./config.json /plejd/
|
||||
|
||||
# Build arguments
|
||||
ARG BUILD_DATE
|
||||
ARG BUILD_REF
|
||||
ARG BUILD_VERSION
|
||||
COPY ./entrypoint.sh /plejd/
|
||||
COPY ./options.json.template /plejd/
|
||||
RUN chmod a+x /plejd/entrypoint.sh
|
||||
|
||||
# Labels
|
||||
LABEL \
|
||||
io.hass.name="Plejd" \
|
||||
io.hass.description="Adds support for the Swedish home automation devices from Plejd." \
|
||||
io.hass.arch="${BUILD_ARCH}" \
|
||||
io.hass.type="addon" \
|
||||
io.hass.version=${BUILD_VERSION} \
|
||||
maintainer="Marcus Westin <marcus@sekurbit.se>" \
|
||||
org.label-schema.description="Adds support for the Swedish home automation devices from Plejd." \
|
||||
org.label-schema.build-date=${BUILD_DATE} \
|
||||
org.label-schema.name="Plejd" \
|
||||
org.label-schema.schema-version="1.0" \
|
||||
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"
|
||||
ENTRYPOINT ["/bin/sh", "/plejd/entrypoint.sh"]
|
||||
|
|
|
|||
|
|
@ -1,6 +0,0 @@
|
|||
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
|
||||
39
plejd/entrypoint.sh
Normal file
39
plejd/entrypoint.sh
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#! /bin/sh
|
||||
|
||||
if [ -z "${site}" ]; then
|
||||
echo "Plejd site not set."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "${username}" ]; then
|
||||
echo "Plejd username not set."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "${password}" ]; then
|
||||
echo "Plejd password not set."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "${mqttUsername}" ]; then
|
||||
echo "Mqtt username not set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "${mqttPassword}" ]; then
|
||||
echo "Mqtt password not set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir /data
|
||||
|
||||
mqttBroker="${mqttBroker:=mqtt://}" \
|
||||
includeRoomsAsLights="${includeRoomsAsLights:=false}" \
|
||||
preferCachedApiResponse="${preferCachedApiResponse:=false}" \
|
||||
updatePlejdClock="${updatePlejdClock:=false}" \
|
||||
logLevel="${logLevel:=info}" \
|
||||
connectionTimout="${connectionTimout:=2}" \
|
||||
writeQueueWaitTime="${writeQueueWaitTime:=400}" \
|
||||
envsubst <"/plejd/options.json.template" >"/data/options.json"
|
||||
|
||||
node /plejd/main.js
|
||||
14
plejd/options.json.template
Normal file
14
plejd/options.json.template
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"site": "$site",
|
||||
"username": "$username",
|
||||
"password": "$password",
|
||||
"mqttBroker": "$mqttBroker",
|
||||
"mqttUsername": "$mqttUsername",
|
||||
"mqttPassword": "$mqttPassword",
|
||||
"includeRoomsAsLights": "$includeRoomsAsLights",
|
||||
"preferCachedApiResponse": "$preferCachedApiResponse",
|
||||
"updatePlejdClock": "$updatePlejdClock",
|
||||
"logLevel": "$logLevel",
|
||||
"connectionTimeout": $connectionTimout,
|
||||
"writeQueueWaitTime": $writeQueueWaitTime
|
||||
}
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
#!/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'
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Community Hass.io Add-ons: Plejd
|
||||
# Runs the Plejd service
|
||||
# ==============================================================================
|
||||
|
||||
bashio::log.info 'Starting the Plejd service...'
|
||||
|
||||
# Change working directory
|
||||
cd /plejd || bashio::exit.nok 'Unable to change working directory'
|
||||
|
||||
# Run the Plejd service
|
||||
bashio::log.info 'Executing startup script'
|
||||
exec /usr/bin/plejd.sh
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
#!/usr/bin/with-contenv bashio
|
||||
|
||||
bashio::log.info 'Running add-on'
|
||||
exec node /plejd/main.js
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue