From dcad32263a41a3ca982bb34bb950b232f0c22e54 Mon Sep 17 00:00:00 2001 From: Daniel Lando Date: Mon, 27 Nov 2023 11:46:37 +0100 Subject: [PATCH 1/4] chore(docker): switch to non-alpine image and drop armv6 --- .github/workflows/docker-release-test.yml | 2 +- .github/workflows/docker-release.yml | 2 +- .github/workflows/docker-test.yml | 2 +- docker/Dockerfile | 25 +++---- docker/Dockerfile.alpine | 86 +++++++++++++++++++++++ 5 files changed, 102 insertions(+), 15 deletions(-) create mode 100644 docker/Dockerfile.alpine diff --git a/.github/workflows/docker-release-test.yml b/.github/workflows/docker-release-test.yml index 0e3bb027d5..3b23237147 100644 --- a/.github/workflows/docker-release-test.yml +++ b/.github/workflows/docker-release-test.yml @@ -68,7 +68,7 @@ jobs: uses: docker/build-push-action@v5 timeout-minutes: 120 with: - platforms: linux/arm64,linux/amd64,linux/arm/v6,linux/arm/v7 + platforms: linux/arm64,linux/amd64,linux/arm/v7 file: docker/Dockerfile context: . # without this it will use master instead of the selected branch cache-from: type=gha diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml index 4e4981f5c8..073d40ace8 100644 --- a/.github/workflows/docker-release.yml +++ b/.github/workflows/docker-release.yml @@ -84,7 +84,7 @@ jobs: timeout-minutes: 120 # prevents this to run indeterminatly uses: docker/build-push-action@v5 with: - platforms: linux/arm64,linux/amd64,linux/arm/v6,linux/arm/v7 + platforms: linux/arm64,linux/amd64,linux/arm/v7 file: docker/Dockerfile context: . # without this it will clone master branch instead of using local cache-from: type=gha diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml index 84f5827bfd..7ed05bd0b7 100644 --- a/.github/workflows/docker-test.yml +++ b/.github/workflows/docker-test.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - platforms: [linux/amd64, linux/arm64, linux/arm/v6, linux/arm/v7] + platforms: [linux/amd64, linux/arm64, linux/arm/v7] steps: - uses: actions/checkout@v3 diff --git a/docker/Dockerfile b/docker/Dockerfile index cf8fe61be8..2491942551 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,16 +1,17 @@ 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 \ +RUN apt-get update && apt-get install -y \ coreutils \ jq \ - linux-headers \ - alpine-sdk \ - python3 + build-essential \ + python3 \ + libudev-dev \ + && rm -rf /var/lib/apt/lists/* COPY package.json yarn.lock .yarnrc.yml ./ COPY .yarn/releases .yarn/releases @@ -59,18 +60,18 @@ 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 \ +RUN apt-get update && apt-get install -y \ libstdc++ \ openssl \ - libgcc \ - libusb \ + libgcc1 \ + libusb-1.0-0 \ tzdata \ - eudev + libudev1 \ + && 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 diff --git a/docker/Dockerfile.alpine b/docker/Dockerfile.alpine new file mode 100644 index 0000000000..cf8fe61be8 --- /dev/null +++ b/docker/Dockerfile.alpine @@ -0,0 +1,86 @@ +ARG image=zwave-js-ui + +# STEP: 1 build +FROM node:20.10.0-alpine3.18 AS build-zui + +WORKDIR /usr/src/app + +RUN apk --no-cache add \ + coreutils \ + jq \ + linux-headers \ + alpine-sdk \ + python3 + +COPY package.json yarn.lock .yarnrc.yml ./ +COPY .yarn/releases .yarn/releases + +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 +RUN [ -d 'node_modules' ] && echo "Skipping install" || yarn install --immutable + +# Fix issue with serialport bindings #2349 +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 yarn remove $(cat package.json | jq -r '.devDependencies | keys | join(" ")') && \ + rm -rf \ + build \ + package.sh \ + src \ + static \ + docs \ + .yarn \ + .github \ + .vscode + +# add plugin support, space separated +ARG plugins +RUN if [ ! -z "$plugins" ]; \ + then echo "Installing plugins ${plugins}"; yarn add ${plugins} ; fi + +# when update devices arg is set update config files from zwavejs repo +ARG updateDevices +ARG zwavejs=https://github.com/zwave-js/node-zwave-js/archive/master.tar.gz + +RUN if [ ! -z "$updateDevices" ]; \ + then curl -sL ${zwavejs} | \ + tar vxz --strip=5 -C ./node_modules/@zwave-js/config/config/devices \ + node-zwave-js-master/packages/config/config/devices/ ;\ + fi + +# STEP: 2 (runtime) +FROM node:20.10.0-alpine3.18 + +RUN apk add --no-cache \ + libstdc++ \ + openssl \ + libgcc \ + libusb \ + tzdata \ + eudev + + +# 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 + +ENV TAG_NAME=${image_name} + +ENV NODE_ENV=production + +WORKDIR /usr/src/app + +EXPOSE 8091 + +CMD ["node", "server/bin/www"] From 2dde7b9f35d4d364eb3f249125f04b571bf6545e Mon Sep 17 00:00:00 2001 From: Daniel Lando Date: Mon, 27 Nov 2023 11:48:13 +0100 Subject: [PATCH 2/4] fix: missing armv6 references --- .github/workflows/docker-release.yml | 2 +- docs/development/custom-docker.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml index 073d40ace8..8b5456618d 100644 --- a/.github/workflows/docker-release.yml +++ b/.github/workflows/docker-release.yml @@ -97,7 +97,7 @@ jobs: timeout-minutes: 120 uses: docker/build-push-action@v5 with: - platforms: linux/arm64,linux/amd64,linux/arm/v6,linux/arm/v7 + platforms: linux/arm64,linux/amd64,linux/arm/v7 file: docker/Dockerfile context: . # without this it will clone master branch instead of using local cache-from: type=gha diff --git a/docs/development/custom-docker.md b/docs/development/custom-docker.md index 3398ba8a06..a07e2a3680 100644 --- a/docs/development/custom-docker.md +++ b/docs/development/custom-docker.md @@ -31,7 +31,7 @@ docker buildx inspect --bootstrap # build the containers docker buildx build \ - --platform linux/arm64,linux/amd64,linux/arm/v6,linux/arm/v7 \ + --platform linux/arm64,linux/amd64,linux/arm/v7 \ -t zwavejs/zwave-js-ui:latest \ -f docker/Dockerfile \ . From 3e0664164e063c3c0e62e5c79e1b8a9a9312ac94 Mon Sep 17 00:00:00 2001 From: Daniel Lando Date: Mon, 27 Nov 2023 11:53:12 +0100 Subject: [PATCH 3/4] chore: remove useless deps --- docker/Dockerfile | 8 -------- 1 file changed, 8 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 2491942551..6fa11dd2db 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -6,11 +6,8 @@ FROM node:20.10.0-bookworm AS build-zui WORKDIR /usr/src/app RUN apt-get update && apt-get install -y \ - coreutils \ jq \ - build-essential \ python3 \ - libudev-dev \ && rm -rf /var/lib/apt/lists/* COPY package.json yarn.lock .yarnrc.yml ./ @@ -63,12 +60,7 @@ RUN if [ ! -z "$updateDevices" ]; \ FROM node:20.10.0-bookworm-slim RUN apt-get update && apt-get install -y \ - libstdc++ \ openssl \ - libgcc1 \ - libusb-1.0-0 \ - tzdata \ - libudev1 \ && rm -rf /var/lib/apt/lists/* # Copy files from the previous build stage From c5a853c3d990e1e76b678f730f34d7426616b4b5 Mon Sep 17 00:00:00 2001 From: Daniel Lando Date: Mon, 27 Nov 2023 11:58:26 +0100 Subject: [PATCH 4/4] chore: prevent heap error --- docker/Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 6fa11dd2db..f5654b50a4 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -17,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