-
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
121 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,18 @@ | ||
version: '3' | ||
services: | ||
ozwd: | ||
image: openzwave/ozwdaemon:latest | ||
zwave: | ||
build: | ||
context: ./zwave | ||
dockerfile: Dockerfile | ||
network_mode: host | ||
security_opt: | ||
- seccomp:unconfined | ||
devices: | ||
- "/dev/ttyACM0" | ||
volumes: | ||
- .docker/data/ozwd/:/opt/ozw/config | ||
- .docker/data/zwavejs/cache:/cache | ||
ports: | ||
- "1983:1983" | ||
- "9312:3000" | ||
restart: unless-stopped | ||
env_file: | ||
- '.env.zwave' | ||
mqtt: | ||
restart: unless-stopped | ||
image: eclipse-mosquitto:latest | ||
network_mode: host | ||
volumes: | ||
- .docker/data/mosquitto:/mosquitto/data | ||
#- .docker/log/mosquitto.log:/mosquitto/log/mosquitto.log | ||
- ./mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
FROM alpine:3.13 | ||
|
||
WORKDIR /app | ||
|
||
RUN apk add --no-cache \ | ||
nodejs | ||
|
||
# Build tools required to install serialport, a zwave-js dependency | ||
RUN apk add --no-cache \ | ||
g++ \ | ||
git \ | ||
linux-headers \ | ||
make \ | ||
npm \ | ||
python3 | ||
|
||
RUN npm install npm@latest -g | ||
|
||
WORKDIR /app | ||
|
||
ARG [email protected] | ||
ARG ZWAVE_JS_SERVER_PACKAGE=@zwave-js/[email protected] | ||
ARG NPM_INSTALL_FLAGS= | ||
|
||
RUN npm install ${NPM_INSTALL_FLAGS} ${ZWAVE_JS_SERVER_PACKAGE} ${ZWAVE_JS_PACKAGE} | ||
|
||
RUN apk add --no-cache \ | ||
jq | ||
|
||
WORKDIR /app | ||
|
||
ENV NODE_ENV=production | ||
|
||
COPY docker-entrypoint.sh /usr/local/bin/ | ||
COPY options.js . | ||
RUN mkdir -p /cache/config /cache/db /logs | ||
|
||
VOLUME "/cache" | ||
EXPOSE 3000 | ||
|
||
ENV PATH=/app/node_modules/.bin:$PATH | ||
|
||
ENV USB_PATH=/dev/zwave | ||
ENV LOGFILENAME=/logs/zwave_%DATE%.log | ||
# Path to persistent device configuration DB | ||
ENV ZWAVEJS_EXTERNAL_CONFIG=/cache/db | ||
|
||
RUN ls | ||
ENTRYPOINT ["docker-entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
if [ -z "$1" ]; then | ||
if [ ! -c "$USB_PATH" ]; then | ||
echo "USB path \"$USB_PATH\" does not exist or is not a character device" | ||
exit 1 | ||
fi | ||
|
||
if [ -n "$NETWORK_KEY" ]; then | ||
echo "NETWORK_KEY is deprecated, use S0_LEGACY_KEY instead" | ||
fi | ||
|
||
set -- zwave-server --config options.js "$USB_PATH" | ||
echo "Starting zwave-server:" "$@" | ||
elif [ "$1" = "server" ]; then | ||
shift | ||
set -- zwave-server "$@" | ||
elif [ "$1" = "client" ]; then | ||
shift | ||
set -- zwave-client "$@" | ||
fi | ||
|
||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
function getLogConfig() { | ||
config = { | ||
forceConsole: true, | ||
}; | ||
|
||
if (process.env.LOGFILENAME) { | ||
config.filename = process.env.LOGFILENAME; | ||
} | ||
|
||
return config; | ||
} | ||
|
||
// Obtain the security keys from the environment variables. | ||
// The server and driver don't allow blank or undefined keys, | ||
// so skip any unset/blank environment variables. The server checks | ||
// the key lengths and converts to a Buffer for us. | ||
function getSecurityKeys() { | ||
const env_keys = { | ||
S2_AccessControl: process.env.S2_ACCESS_CONTROL_KEY, | ||
S2_Authenticated: process.env.S2_AUTHENTICATED_KEY, | ||
S2_Unauthenticated: process.env.S2_UNAUTHENTICATED_KEY, | ||
S0_Legacy: process.env.S0_LEGACY_KEY || process.env.NETWORK_KEY, | ||
}; | ||
|
||
keys = {}; | ||
for (const [name, key] of Object.entries(env_keys)) { | ||
if (key) { | ||
keys[name] = key; | ||
} | ||
} | ||
|
||
return keys; | ||
} | ||
|
||
module.exports = { | ||
logConfig: getLogConfig(), | ||
storage: { | ||
cacheDir: "/cache", | ||
deviceConfigPriorityDir: "/cache/config", | ||
}, | ||
securityKeys: getSecurityKeys(), | ||
}; |