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..8b5456618d 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 @@ -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/.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..f5654b50a4 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -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 @@ -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 @@ -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 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"] 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 \ .