Using Playwright on Openshift

Using the playwright image on openshift brings with it some problems regarding filesystem permissions. These issues will result in the npm command failing without any output, by default (an empty message).

# Use the playwright image from Microsoft which has the browsers pre-installed
FROM mcr.microsoft.com/playwright:v1.27.1-focal

ENV HOME=/usr/src/app

# Enable CI mode (used in the playwright.config.ts)
ENV CI=true

RUN mkdir -p $HOME
WORKDIR $HOME

# Copy all files from the current directory to the container
# (except the ones in .dockerignore)
COPY . .

# Install dependencies
RUN npm install

# Make sure the user has access to the files. It is important to do this
# after the npm install, as the npm install will create a node_modules
# directory with root permissions.
RUN chgrp -R 0 $HOME && chmod -R g=u $HOME

CMD ["npx", "playwright", "test"]

Debugging issues for Openshift

Given you don't have an openshift cluster running locally, there are several options to debug the issue.

Debugging the image in the cluster

To debug inside the cluster, you can use the oc debug command.

oc debug <podname>(e.g. playwright--1-ghfvf) -n <namespace>

This will open a shell inside the container. You can then run the npm --loglevel verbose command to see the error message.

Debugging the image using a local docker daemon

If you have a local docker daemon running, you can use the docker run command to run the image locally. Using a semi-random user id, you can simulate the openshift environment. The group of the user should be root (gid 0).

docker run --user 10101:0 image-name

Now, the npm command should fail with the same error message as in the openshift cluster.

OpenID Connect ID Token Signature Validation SamplesMultiple Gitlab/Github accounts with different SSH keys (MacOS/Linux)