From b7de63bef8e0914acbfcda5bc0c5f6d969376ff4 Mon Sep 17 00:00:00 2001 From: Daniel Lando Date: Mon, 27 Nov 2023 13:58:43 +0100 Subject: [PATCH] fix(docker): try using custom alpine --- docker/Dockerfile | 34 +++++++++++++------ .../{Dockerfile.alpine => Dockerfile.debian} | 25 +++++--------- 2 files changed, 32 insertions(+), 27 deletions(-) rename docker/{Dockerfile.alpine => Dockerfile.debian} (82%) diff --git a/docker/Dockerfile b/docker/Dockerfile index f5654b50a43..b1db4abd3fe 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,14 +1,30 @@ ARG image=zwave-js-ui -# STEP: 1 build -FROM node:20.10.0-bookworm AS build-zui +FROM alpine:3.18.4 as base + +RUN apk add --no-cache \ + libstdc++ \ + openssl \ + libgcc \ + libusb \ + tzdata \ + eudev \ + nodejs=18.18.2-r0 WORKDIR /usr/src/app -RUN apt-get update && apt-get install -y \ +# STEP: 1 build +FROM base AS build-zui + +RUN apk --no-cache add \ + coreutils \ jq \ + linux-headers \ + alpine-sdk \ python3 \ - && rm -rf /var/lib/apt/lists/* + npm=9.6.6-r0 + +RUN npm install --global yarn@2.4.3 COPY package.json yarn.lock .yarnrc.yml ./ COPY .yarn/releases .yarn/releases @@ -17,6 +33,8 @@ 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 @@ -55,13 +73,9 @@ RUN if [ ! -z "$updateDevices" ]; \ fi # STEP: 2 (runtime) -FROM node:20.10.0-bookworm-slim - -RUN apt-get update && apt-get install -y \ - openssl \ - && rm -rf /var/lib/apt/lists/* +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 diff --git a/docker/Dockerfile.alpine b/docker/Dockerfile.debian similarity index 82% rename from docker/Dockerfile.alpine rename to docker/Dockerfile.debian index cf8fe61be8f..f5654b50a43 100644 --- a/docker/Dockerfile.alpine +++ b/docker/Dockerfile.debian @@ -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