@@ -11,7 +11,6 @@ ENV LC_ALL=C.UTF-8
1111# === INSTALL Node.js ===
1212
1313RUN apt-get update && \
14- # Install Node.js
1514 apt-get install -y curl wget gpg ca-certificates && \
1615 mkdir -p /etc/apt/keyrings && \
1716 curl -sL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
@@ -27,23 +26,21 @@ RUN apt-get update && \
2726 adduser pwuser
2827
2928# === BAKE BROWSERS INTO IMAGE ===
29+ # Browsers are split into separate layers to enable parallel pulls.
3030
3131ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
3232
3333# 1. Add tip-of-tree Playwright package to install its browsers.
3434# The package should be built beforehand from tip-of-tree Playwright.
3535COPY ./playwright-core.tar.gz /tmp/playwright-core.tar.gz
3636
37- # 2. Bake in browsers & deps.
38- # Browsers will be downloaded in `/ms-playwright`.
39- # Note: make sure to set 777 to the registry so that any user can access
40- # registry.
41- RUN mkdir /ms-playwright && \
37+ # 2. Set up playwright-core and install all system dependencies in one layer.
38+ RUN install -d -m 777 /ms-playwright /ms-playwright/.links && \
4239 mkdir /ms-playwright-agent && \
4340 cd /ms-playwright-agent && npm init -y && \
4441 npm i /tmp/playwright-core.tar.gz && \
4542 npm exec --no -- playwright-core mark-docker-image "${DOCKER_IMAGE_NAME_TEMPLATE}" && \
46- npm exec --no -- playwright-core install --with- deps && rm -rf /var/lib/apt/lists/* && \
43+ npm exec --no -- playwright-core install- deps && \
4744 # Workaround for https://github.com/microsoft/playwright/issues/27313
4845 # While the gstreamer plugin load process can be in-process, it ended up throwing
4946 # an error that it can't have libsoup2 and libsoup3 in the same process because
@@ -53,7 +50,21 @@ RUN mkdir /ms-playwright && \
5350 else \
5451 rm /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstwebrtc.so; \
5552 fi && \
53+ rm -rf /var/lib/apt/lists/*
54+
55+ # 3. Install each browser binary in its own layer for parallel pulling.
56+ # Note: installing chromium also installs chromium-headless-shell and ffmpeg.
57+ RUN cd /ms-playwright-agent && \
58+ npm exec --no -- playwright-core install chromium && \
59+ chmod -R 777 /ms-playwright/chromium-* /ms-playwright/chromium_headless_shell-* /ms-playwright/ffmpeg-*
60+
61+ RUN cd /ms-playwright-agent && \
62+ npm exec --no -- playwright-core install firefox && \
63+ chmod -R 777 /ms-playwright/firefox-*
64+
65+ RUN cd /ms-playwright-agent && \
66+ npm exec --no -- playwright-core install webkit && \
5667 rm /tmp/playwright-core.tar.gz && \
5768 rm -rf /ms-playwright-agent && \
5869 rm -rf ~/.npm/ && \
59- chmod -R 777 /ms-playwright
70+ chmod -R 777 /ms-playwright/webkit-*
0 commit comments