diff --git a/Dockerfile b/Dockerfile index 460d40e8c..4eea7b878 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,13 +25,13 @@ RUN cp /code/OpenBullet2.Web/dbip-country-lite.mmdb /build # -------- # FRONTEND # -------- -FROM node:20.9.0 AS frontend +FROM node:22-bookworm-slim AS frontend WORKDIR /code COPY openbullet2-web-client/package.json . COPY openbullet2-web-client/package-lock.json . -RUN npm install +RUN npm ci COPY openbullet2-web-client . RUN npm run build @@ -50,20 +50,19 @@ COPY --from=backend /build/web . COPY --from=frontend /build ./wwwroot COPY OpenBullet2.Web/dbip-country-lite.mmdb . -# Install dependencies -RUN apt-get update -yq && apt-get install -y --no-install-recommends apt-utils -RUN apt-get upgrade -yq && apt-get install -yq apt-utils curl git nano wget unzip python3 python3-pip - -# Setup nodejs -RUN curl -sL https://deb.nodesource.com/setup_current.x | bash - && apt-get install -yq nodejs build-essential -RUN echo "deb http://deb.debian.org/debian/ unstable main contrib non-free" >> /etc/apt/sources.list.d/debian.list - -# Install chromium and firefox for selenium and puppeteer -RUN apt-get update -yq && apt-get install -y --no-install-recommends firefox chromium -RUN pip3 install webdrivermanager || true -RUN webdrivermanager firefox chrome --linkpath /usr/local/bin || true - -RUN apt-get clean && rm -rf /var/lib/apt/lists/* +# Install dependencies and Node.js in a single layer to reduce image size +RUN apt-get update -yq \ + && apt-get install -y --no-install-recommends \ + apt-utils curl git nano wget unzip \ + python3 \ + nodejs npm \ + chromium firefox-esr \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +# Note: Selenium 4.6+ includes Selenium Manager which automatically +# downloads the correct browser drivers at runtime. No need for +# the deprecated webdrivermanager pip package. EXPOSE 5000 CMD ["dotnet", "./OpenBullet2.Web.dll", "--urls=http://*:5000"] diff --git a/Dockerfile.build b/Dockerfile.build index c0765115e..fadeb13b0 100644 --- a/Dockerfile.build +++ b/Dockerfile.build @@ -39,13 +39,13 @@ RUN cp /code/OpenBullet2.Web/dbip-country-lite.mmdb /build # -------- # FRONTEND # -------- -FROM node:20.9.0 AS frontend +FROM node:22-bookworm-slim AS frontend WORKDIR /code COPY openbullet2-web-client/package.json . COPY openbullet2-web-client/package-lock.json . -RUN npm install +RUN npm ci COPY openbullet2-web-client . RUN npm run build diff --git a/Dockerfile.remote b/Dockerfile.remote index badd3af50..ab375ecb4 100644 --- a/Dockerfile.remote +++ b/Dockerfile.remote @@ -2,7 +2,7 @@ FROM mcr.microsoft.com/dotnet/aspnet:8.0-bookworm-slim ENV DEBIAN_FRONTEND=noninteractive -# Install basic dependencies +# Install dependencies, Node.js, and browsers in a single layer RUN apt-get update -yq \ && apt-get install -y --no-install-recommends \ apt-utils \ @@ -12,32 +12,15 @@ RUN apt-get update -yq \ wget \ unzip \ python3 \ - python3-pip \ - gnupg \ - lsb-release \ - software-properties-common - -# Setup Node.js (LTS Version) -RUN curl -sL https://deb.nodesource.com/setup_lts.x | bash - \ - && apt-get install -yq nodejs build-essential - -# Add Mozilla Team PPA for the latest Firefox -RUN echo "deb http://ppa.launchpad.net/mozillateam/ppa/ubuntu focal main" | tee /etc/apt/sources.list.d/mozillateam-ppa.list \ - && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A6DCF7707EBC211F \ - && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 9BDB3D89CE49EC21 \ - && apt-get update -yq - -# Install the latest Firefox and Chromium -RUN apt-get install -y --no-install-recommends \ - firefox \ - chromium - -# Install WebDriverManager -RUN pip3 install webdrivermanager || true \ - && webdrivermanager firefox chrome --linkpath /usr/local/bin || true - -# Clean up -RUN apt-get clean && rm -rf /var/lib/apt/lists/* + nodejs npm \ + chromium \ + firefox-esr \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +# Note: Selenium 4.6+ includes Selenium Manager which automatically +# downloads the correct browser drivers at runtime. No need for +# the deprecated webdrivermanager pip package. WORKDIR /app