Skip to content

Commit

Permalink
fix(docker): try using custom alpine (#3443)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando authored Nov 27, 2023
1 parent 46773f7 commit 400cb4f
Show file tree
Hide file tree
Showing 8 changed files with 1,174 additions and 1,262 deletions.
4 changes: 2 additions & 2 deletions api/lib/ZwaveClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6023,8 +6023,8 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
zwaveValueMeta.type === 'number'
? parseInt(k)
: zwaveValueMeta.type === 'boolean'
? k === 'true'
: k,
? k === 'true'
: k,
})
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions api/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export type DeepPartial<T> = {
[P in keyof T]?: T[P] extends Array<infer U>
? Array<DeepPartial<U>>
: T[P] extends ReadonlyArray<infer U>
? ReadonlyArray<DeepPartial<U>>
: DeepPartial<T[P]>
? ReadonlyArray<DeepPartial<U>>
: DeepPartial<T[P]>
}

export interface ErrnoException extends Error {
Expand Down
49 changes: 30 additions & 19 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
ARG image=zwave-js-ui

# STEP: 1 build
FROM node:20.10.0-bookworm AS build-zui
FROM alpine:3.18.4 as base

WORKDIR /usr/src/app
RUN apk add --no-cache \
openssl \
libusb \
tzdata \
eudev \
nodejs=18.18.2-r0

RUN apt-get update && apt-get install -y \
jq \
python3 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /usr/src/app

COPY package.json yarn.lock .yarnrc.yml ./
COPY .yarn/releases .yarn/releases
# STEP: 1 build
FROM base AS build-zui

RUN \
apk add --no-cache --virtual .build-dependencies \
jq \
build-base \
linux-headers \
python3-dev \
npm=9.6.6-r0 \
\
&& npm install --global yarn

ENV YARN_HTTP_TIMEOUT=300000
# set production env install will not install devDependencies
Expand All @@ -26,15 +37,19 @@ RUN [ -d 'node_modules' ] && echo "Skipping install" || yarn install --immutable
RUN npm_config_build_from_source=true npm rebuild @serialport/bindings-cpp

# Build back and frontend only when not existing
RUN [ -d 'dist' ] && echo "Skipping build" || yarn build
RUN [ -d 'dist' ] && echo "Skipping build" || npm run build

RUN yarn remove $(cat package.json | jq -r '.devDependencies | keys | join(" ")') && \
RUN npm prune --production && \
rm -rf \
package-lock.json \
build \
package.sh \
src \
api \
static \
docs \
kubernetes \
test \
.yarn \
.github \
.vscode
Expand All @@ -54,14 +69,12 @@ RUN if [ ! -z "$updateDevices" ]; \
node-zwave-js-master/packages/config/config/devices/ ;\
fi

# STEP: 2 (runtime)
FROM node:20.10.0-bookworm-slim
RUN apk del --no-cache --purge .build-dependencies

RUN apt-get update && apt-get install -y \
openssl \
&& rm -rf /var/lib/apt/lists/*
# STEP: 2 (runtime)
FROM base AS runtime

# Copy files from the previous build stage
# Copy files from previous build stage
COPY --from=build-zui /usr/src/app /usr/src/app

ENV ZWAVEJS_EXTERNAL_CONFIG=/usr/src/app/store/.config-db
Expand All @@ -70,8 +83,6 @@ ENV TAG_NAME=${image_name}

ENV NODE_ENV=production

WORKDIR /usr/src/app

EXPOSE 8091

CMD ["node", "server/bin/www"]
25 changes: 8 additions & 17 deletions docker/Dockerfile.alpine → docker/Dockerfile.debian
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
ARG image=zwave-js-ui

# STEP: 1 build
FROM node:20.10.0-alpine3.18 AS build-zui
FROM node:20.10.0-bookworm AS build-zui

WORKDIR /usr/src/app

RUN apk --no-cache add \
coreutils \
RUN apt-get update && apt-get install -y \
jq \
linux-headers \
alpine-sdk \
python3
python3 \
&& rm -rf /var/lib/apt/lists/*

COPY package.json yarn.lock .yarnrc.yml ./
COPY .yarn/releases .yarn/releases
Expand All @@ -19,8 +17,6 @@ ENV YARN_HTTP_TIMEOUT=300000
# set production env install will not install devDependencies
ENV NODE_ENV=production

ENV NODE_OPTIONS="--max-old-space-size=4096"

COPY . .

# if node_modules does not exist, run it, otherwise skip
Expand Down Expand Up @@ -59,18 +55,13 @@ RUN if [ ! -z "$updateDevices" ]; \
fi

# STEP: 2 (runtime)
FROM node:20.10.0-alpine3.18
FROM node:20.10.0-bookworm-slim

RUN apk add --no-cache \
libstdc++ \
RUN apt-get update && apt-get install -y \
openssl \
libgcc \
libusb \
tzdata \
eudev

&& rm -rf /var/lib/apt/lists/*

# Copy files from previous build stage
# Copy files from the previous build stage
COPY --from=build-zui /usr/src/app /usr/src/app

ENV ZWAVEJS_EXTERNAL_CONFIG=/usr/src/app/store/.config-db
Expand Down
8 changes: 4 additions & 4 deletions src/components/ValueId.vue
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@
'max-width': $vuetify.breakpoint.smAndDown
? '280px'
: $vuetify.breakpoint.smOnly
? '400px'
: 'auto',
? '400px'
: 'auto',
}"
:hint="help"
persistent-hint
Expand Down Expand Up @@ -197,8 +197,8 @@
'max-width': $vuetify.breakpoint.smAndDown
? '280px'
: $vuetify.breakpoint.smOnly
? '400px'
: 'auto',
? '400px'
: 'auto',
}"
:hint="help"
persistent-hint
Expand Down
4 changes: 2 additions & 2 deletions src/components/nodes-table/nodes-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ export default {
value === undefined
? valueMap.default
: value
? valueMap.true
: valueMap.false
? valueMap.true
: valueMap.false
return {
align: 'center',
icon: map.icon,
Expand Down
4 changes: 2 additions & 2 deletions src/modules/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export class Settings {
valStr === 'false'
? false
: valStr === 'true'
? true
: defaultVal
? true
: defaultVal
break
case 'number':
val = valStr && !isNaN(valStr) ? Number(valStr) : defaultVal
Expand Down
Loading

0 comments on commit 400cb4f

Please sign in to comment.