Skip to content

Commit 1632e6c

Browse files
committed
feat: update to 8.6.3
Signed-off-by: wilmardo <info@wilmardenouden.nl>
1 parent 6297999 commit 1632e6c

2 files changed

Lines changed: 57 additions & 39 deletions

File tree

Dockerfile

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,39 @@
11
#######################################################################################################################
22
# Nexe packaging of binary
33
#######################################################################################################################
4-
FROM lansible/nexe:4.0.0-rc1 as builder
4+
FROM lansible/nexe:4.0.0-rc.2 as builder
55

66
# https://github.com/docker/buildx#building-multi-platform-images
77
ARG TARGETPLATFORM
8-
ENV VERSION=v6.13.0
8+
# https://github.com/zwave-js/zwave-js-ui/releases
9+
ENV VERSION=v8.6.3
910

1011
# Add unprivileged user
11-
RUN echo "zwavejs2mqtt:x:1000:1000:zwavejs2mqtt:/:" > /etc_passwd
12+
RUN echo "zwave-js-ui:x:1000:1000:zwave-js-ui:/:" > /etc_passwd
1213
# Add to dailout as secondary group (20)
13-
RUN echo "dailout:x:20:zwavejs2mqtt" > /etc_group
14+
RUN echo "dailout:x:20:zwave-js-ui" > /etc_group
1415

1516
# eudev: needed for udevadm binary
1617
RUN apk --no-cache add \
1718
eudev
1819

19-
# Setup zwavejs2mqtt
20-
RUN git clone --depth 1 --single-branch --branch ${VERSION} https://github.com/zwave-js/zwavejs2mqtt.git /zwavejs2mqtt
20+
# Setup zwave-js-ui
21+
RUN git clone --depth 1 --single-branch --branch ${VERSION} https://github.com/zwave-js/zwave-js-ui.git /zwave-js-ui
2122

22-
WORKDIR /zwavejs2mqtt
23+
WORKDIR /zwave-js-ui
2324

2425
# Apply stateless patch
25-
COPY stateless.patch /zwavejs2mqtt/stateless.patch
26+
COPY stateless.patch /zwave-js-ui/stateless.patch
2627
RUN git apply stateless.patch
2728

2829
# Install all modules
2930
# Run build to make all html files
31+
# https://github.com/zwave-js/zwave-js-ui/blob/master/docker/Dockerfile#L20
3032
RUN CORES=$(grep -c '^processor' /proc/cpuinfo); \
3133
export MAKEFLAGS="-j$((CORES+1)) -l${CORES}"; \
32-
npm install && \
33-
npm run build && \
34-
npm prune --production
34+
yarn install --immutable && \
35+
yarn build && \
36+
yarn remove $(cat package.json | jq -r '.devDependencies | keys | join(" ")')
3537

3638
# Remove all unneeded prebuilds
3739
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
@@ -41,7 +43,7 @@ RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
4143
find . -name *.node -path *prebuilds/* -not -path *${PLATFORM}* -name *.node -delete && \
4244
find . -name *.glibc.node -path *prebuilds/* -delete
4345

44-
WORKDIR /zwavejs2mqtt/server
46+
WORKDIR /zwave-js-ui/server
4547

4648
# See: https://github.com/nexe/nexe/issues/441#issuecomment-359654690
4749
RUN sed -i "2s/^/require('ejs');\n/" bin/www.js
@@ -52,28 +54,29 @@ RUN nexe --build \
5254
--resource lib/ \
5355
--resource ../views/ \
5456
--resource ../dist/ \
55-
--output zwavejs2mqtt \
57+
--resource ../node_modules/@esm2cjs \
58+
--output zwave-js-ui \
5659
--input bin/www.js && \
5760
mkdir /config /data
5861

59-
6062
#######################################################################################################################
6163
# Final scratch image
6264
#######################################################################################################################
6365
FROM scratch
6466

6567
# Add description
66-
LABEL org.label-schema.description="Zwavejs2mqtt as single binary in a scratch container"
68+
LABEL org.label-schema.description="Zwave-js-ui as single binary in a scratch container"
6769

6870
# Set env vars for persistance
69-
# https://github.com/zwave-js/zwavejs2mqtt/blob/master/docs/guide/env-vars.md
71+
# https://github.com/zwave-js/zwave-js-ui/blob/master/docs/guide/env-vars.md
7072
# SETTINGS_FILE is from the stateless.patch
7173
# LIBC is set for prebuilify (node-gyp-build) to pickup the bindings file from serialport:
7274
# https://github.com/prebuild/node-gyp-build/blob/2e982977240368f8baed3975a0f3b048999af40e/index.js#L15
73-
ENV STORE_DIR=/data/ \
74-
ZWAVEJS_EXTERNAL_CONFIG=/data/zwavejs \
75+
ENV TMPDIR=/dev/shm \
76+
STORE_DIR=/data/ \
7577
SETTINGS_FILE=/config/settings.json \
76-
LIBC=musl
78+
LIBC=musl \
79+
NO_LOG_COLORS=true
7780

7881
# Copy the unprivileged user
7982
COPY --from=builder /etc_passwd /etc/passwd
@@ -92,26 +95,35 @@ COPY --from=builder \
9295
/usr/lib/libgcc_s.so.1 \
9396
/usr/lib/
9497

95-
# Copy zwavejs2mqtt binary
96-
COPY --from=builder /zwavejs2mqtt/server/zwavejs2mqtt /zwavejs2mqtt/bin/zwavejs2mqtt
98+
# Copy zwave-js-ui binary
99+
COPY --from=builder /zwave-js-ui/server/zwave-js-ui /zwave-js-ui/bin/zwave-js-ui
97100

98101
# Add bindings.node for serialport
99102
COPY --from=builder \
100-
/zwavejs2mqtt/node_modules/@serialport/bindings-cpp/prebuilds/ \
101-
/zwavejs2mqtt/node_modules/@serialport/bindings-cpp/prebuilds/
103+
/zwave-js-ui/node_modules/@serialport/bindings-cpp/prebuilds/ \
104+
/zwave-js-ui/node_modules/@serialport/bindings-cpp/prebuilds/
102105

103106
# After troubleshooting this somehow can't be packed
104107
COPY --from=builder \
105-
/zwavejs2mqtt/node_modules/engine.io-parser/ \
106-
/zwavejs2mqtt/node_modules/engine.io-parser/
108+
/zwave-js-ui/node_modules/socket.io-parser/ \
109+
/zwave-js-ui/node_modules/socket.io-parser/
110+
COPY --from=builder \
111+
/zwave-js-ui/node_modules/engine.io-parser/ \
112+
/zwave-js-ui/node_modules/engine.io-parser/
113+
COPY --from=builder \
114+
/zwave-js-ui/snippets/ \
115+
/zwave-js-ui/snippets/
116+
COPY --from=builder \
117+
/zwave-js-ui/node_modules/@zwave-js/config/config/devices \
118+
/zwave-js-ui/node_modules/@zwave-js/config/config/devices
107119

108120
# Create default data directory
109121
# Will fail at runtime due missing the mkdir binary
110-
COPY --from=builder --chown=zwavejs2mqtt:0 /config /config
111-
COPY --from=builder --chown=zwavejs2mqtt:0 /data /data
122+
COPY --from=builder --chown=zwave-js-ui:0 /config /config
123+
COPY --from=builder --chown=zwave-js-ui:0 /data /data
112124

113125
EXPOSE 8091
114-
USER zwavejs2mqtt
115-
WORKDIR /zwavejs2mqtt
126+
USER zwave-js-ui
127+
WORKDIR /zwave-js-ui
116128
# Relative includes so needs to be one folder down from root
117-
ENTRYPOINT ["./bin/zwavejs2mqtt"]
129+
ENTRYPOINT ["./bin/zwave-js-ui"]

stateless.patch

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
diff --git a/config/app.ts b/config/app.ts
2-
index 55735d4..db89ec4 100644
2+
index ffa2c22..7da939c 100644
33
--- a/config/app.ts
44
+++ b/config/app.ts
5-
@@ -6,6 +6,10 @@ config({ path: './.env.app' })
6-
// config/app.js
7-
export const title: string = 'ZWave To MQTT'
8-
export const storeDir: string = process.env.STORE_DIR || joinPath(true, 'store')
5+
@@ -9,11 +9,15 @@ export const storeDir: string = process.env.STORE_DIR || joinPath(true, 'store')
6+
export const logsDir: string = joinPath(storeDir, 'logs')
7+
export const snippetsDir: string = joinPath(storeDir, 'snippets')
8+
9+
-export const tmpDir: string = joinPath(storeDir, '.tmp')
10+
+export const tmpDir: string = process.env.TMPDIR || joinPath(storeDir, '.tmp')
11+
export const backupsDir: string = process.env.BACKUPS_DIR || joinPath(storeDir, 'backups')
12+
export const nvmBackupsDir: string = joinPath(backupsDir, 'nvm')
13+
export const storeBackupsDir: string = joinPath(backupsDir, 'store')
14+
915
+export const settingsFile: string = process.env.SETTINGS_FILE || joinPath(storeDir, 'settings.json')
1016
+export const scenesFile: string = process.env.SCENES_FILE || joinPath(storeDir, 'scenes.json')
1117
+export const nodesFile: string = process.env.NODES_FILE || joinPath(storeDir, 'nodes.json')
1218
+export const usersFile: string = process.env.USERS_FILE || joinPath(storeDir, 'users.json')
19+
1320
export const defaultUser: string = 'admin'
1421
export const defaultPsw: string = 'zwave'
15-
export const sessionSecret: string = process.env.SESSION_SECRET || 'DEFAULT_SESSION_SECRET_CHANGE_ME'
1622
diff --git a/config/store.ts b/config/store.ts
1723
index eb6ae24..b90cee4 100644
1824
--- a/config/store.ts
@@ -47,10 +53,10 @@ index eb6ae24..b90cee4 100644
4753

4854
export default store
4955
diff --git a/lib/jsonStore.ts b/lib/jsonStore.ts
50-
index 865ee9e..2e91521 100644
56+
index 7e16d00..ce45cdc 100644
5157
--- a/lib/jsonStore.ts
5258
+++ b/lib/jsonStore.ts
53-
@@ -40,7 +40,7 @@ export class StorageHelper {
59+
@@ -94,7 +94,7 @@ export class StorageHelper {
5460
let err: { code: string } | undefined
5561
let data: any
5662
try {
@@ -59,7 +65,7 @@ index 865ee9e..2e91521 100644
5965
} catch (error) {
6066
err = error
6167
}
62-
@@ -73,7 +73,7 @@ export class StorageHelper {
68+
@@ -127,7 +127,7 @@ export class StorageHelper {
6369
}
6470

6571
async put(model: StoreFile, data: any) {

0 commit comments

Comments
 (0)