fix(docker): avoid symlink hack in Docker images (#5429)

Instead of symlinking pwuser's registry to root's registry, we now
use the `PLAYWRIGHT_BROWSERS_PATH` variable to define a single
browser registry across the docker image, accessible for all
users.

Fixes #4485
This commit is contained in:
Andrey Lushnikov 2021-02-11 18:33:30 -08:00 committed by GitHub
parent 9d2269dc75
commit 5ea6d6eefd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 8 deletions

View File

@ -77,16 +77,17 @@ RUN apt-get update && apt-get install -y python3.8 python3-pip && \
# === BAKE BROWSERS INTO IMAGE ===
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
RUN mkdir /ms-playwright && chmod 777 /ms-playwright
# 1. Add tip-of-tree Playwright package to install its browsers.
# The package should be built beforehand from tip-of-tree Playwright.
COPY ./playwright.tar.gz /tmp/playwright.tar.gz
# 2. Install playwright and then delete the installation.
# Browsers will remain downloaded in `/home/pwuser/.cache/ms-playwright`.
# Browsers will remain downloaded in `/ms-playwright`.
RUN su pwuser -c "mkdir /tmp/pw && cd /tmp/pw && npm init -y && \
npm i /tmp/playwright.tar.gz" && \
rm -rf /tmp/pw && rm /tmp/playwright.tar.gz
# 3. Symlink downloaded browsers for root user
RUN mkdir /root/.cache/ && \
ln -s /home/pwuser/.cache/ms-playwright/ /root/.cache/ms-playwright

View File

@ -76,16 +76,17 @@ RUN apt-get update && apt-get install -y python3.8 python3-pip && \
# === BAKE BROWSERS INTO IMAGE ===
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
RUN mkdir /ms-playwright && chmod 777 /ms-playwright
# 1. Add tip-of-tree Playwright package to install its browsers.
# The package should be built beforehand from tip-of-tree Playwright.
COPY ./playwright.tar.gz /tmp/playwright.tar.gz
# 2. Install playwright and then delete the installation.
# Browsers will remain downloaded in `/home/pwuser/.cache/ms-playwright`.
# Browsers will remain downloaded in `/ms-playwright`.
RUN su pwuser -c "mkdir /tmp/pw && cd /tmp/pw && npm init -y && \
npm i /tmp/playwright.tar.gz" && \
rm -rf /tmp/pw && rm /tmp/playwright.tar.gz
# 3. Symlink downloaded browsers for root user
RUN mkdir /root/.cache/ && \
ln -s /home/pwuser/.cache/ms-playwright/ /root/.cache/ms-playwright