docker: move firefox install up to other apt deps; --with-deps needed!

Without --with-deps we get and error starting the browser:

node:internal/process/esm_loader:108
    internalBinding('errors').triggerUncaughtException(
                              ^

browserType.launchPersistentContext:
╔══════════════════════════════════════════════════════╗
║ Host system is missing dependencies to run browsers. ║
║ Please install them with the following command:      ║
║                                                      ║
║     npx playwright install-deps                      ║
║                                                      ║
║ Alternatively, use apt:                              ║
║     apt-get install libgtk-3-0\                      ║
║         libasound2\                                  ║
║         libxcomposite1\                              ║
║         libpangocairo-1.0-0\                         ║
║         libpango-1.0-0\                              ║
║         libatk1.0-0\                                 ║
║         libcairo-gobject2\                           ║
║         libcairo2\                                   ║
║         libgdk-pixbuf-2.0-0\                         ║
║         libdbus-glib-1-2\                            ║
║         libxcursor1                                  ║
║                                                      ║
║ <3 Playwright Team                                   ║
╚══════════════════════════════════════════════════════╝
    at async file:///fgc/prime-gaming.js:25:17 {
  name: 'Error'
}
This commit is contained in:
Ralf Vogler 2022-12-24 15:02:28 +01:00
parent 8ce6c2fdc9
commit 67e622e6ec

View file

@ -2,12 +2,15 @@
# Partially from https://github.com/microsoft/playwright/blob/main/utils/docker/Dockerfile.focal # Partially from https://github.com/microsoft/playwright/blob/main/utils/docker/Dockerfile.focal
FROM ubuntu:jammy FROM ubuntu:jammy
# Configuration variables are at the end!
# https://github.com/hadolint/hadolint/wiki/DL4006 # https://github.com/hadolint/hadolint/wiki/DL4006
SHELL ["/bin/bash", "-o", "pipefail", "-c"] SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG DEBIAN_FRONTEND=noninteractive ARG DEBIAN_FRONTEND=noninteractive
ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD true ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD true
# Install up-to-date node & npm, then deps for virtual screen & noVNC # Install up-to-date node & npm, deps for virtual screen & noVNC, browser.
# Playwright needs --with-deps for firefox.
RUN apt-get update \ RUN apt-get update \
&& apt-get install -y curl \ && apt-get install -y curl \
&& curl -fsSL https://deb.nodesource.com/setup_19.x | bash - \ && curl -fsSL https://deb.nodesource.com/setup_19.x | bash - \
@ -19,6 +22,7 @@ RUN apt-get update \
tini \ tini \
novnc websockify \ novnc websockify \
dos2unix \ dos2unix \
&& npx playwright install --with-deps firefox \
&& apt-get clean \ && apt-get clean \
&& rm -rf \ && rm -rf \
/tmp/* \ /tmp/* \
@ -32,16 +36,11 @@ RUN ln -s /usr/share/novnc/vnc_auto.html /usr/share/novnc/index.html
WORKDIR /fgc WORKDIR /fgc
COPY package*.json ./ COPY package*.json ./
# Install browser & dependencies only RUN npm install
RUN npm install \
&& npx playwright install --with-deps firefox \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
COPY . . COPY . .
# Shell scripts # Shell scripts need Linux line endings. On Windows, git might be configured to check out dos/CRLF line endings, so we convert them for those people in case they want to build the image.
# On windows, git might be configured to check out dos/CRLF line endings, so we convert them for those people in case they want to build the image.
RUN dos2unix ./docker/*.sh RUN dos2unix ./docker/*.sh
RUN mv ./docker/entrypoint.sh /usr/local/bin/entrypoint \ RUN mv ./docker/entrypoint.sh /usr/local/bin/entrypoint \
&& chmod +x /usr/local/bin/entrypoint && chmod +x /usr/local/bin/entrypoint