Skip to content

Commit

Permalink
fix(docker): avoid symlink hack in Docker images
Browse files Browse the repository at this point in the history
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 microsoft#4485
  • Loading branch information
aslushnikov committed Feb 12, 2021
1 parent 7551c01 commit 476e8ee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions utils/docker/Dockerfile.bionic
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 5 additions & 4 deletions utils/docker/Dockerfile.focal
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 476e8ee

Please sign in to comment.