Skip to content

Commit

Permalink
feat: let maintainer switch playwright container user (#320)
Browse files Browse the repository at this point in the history
Because

- We want to provide more flexibility toward our maintainers

This commit

- maintainers can switch the user of test container for DEBUG
  • Loading branch information
EiffelFly committed Jan 10, 2023
1 parent 3d4b024 commit f9c15e5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Dockerfile.playwright
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
FROM mcr.microsoft.com/playwright:v1.25.2-focal
WORKDIR /app

ARG TEST_USER="playwright"

RUN npm install -g pnpm@7.5.0

COPY .npmrc package.json pnpm-lock.yaml ./
Expand All @@ -20,7 +22,9 @@ COPY --chown=playwright:nodejs ./playwright-state.json ./

RUN mkdir public

USER playwright
USER ${TEST_USER}

RUN echo "test user: $TEST_USER"

# Permisions to execute script
RUN chmod +x ./entrypoint-playwright.sh
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ For server-side code, because we will alter the ./.env file in the image. It can

- We currently use self-signed certification in all our backend so the default of env variable `NEXT_PUBLIC_INTEGRATION_TEST_ENABLED` will be true. Which means that the Axios won't complaint the `Unauthorized` request. Please do not set this env variable to true on production.

## About the test container

We maintain another container `Dockerfile.playwright` specifically for test usage. This container has some caveats that maintainers of this repo should notice

- The playwright version should align with the pulled playwright image version. Two should be the same.
- If you want to debug in the test container, you should grant this container the root user permission. (default is specific user: playwright) with `--build-args TEST_USER='root'` in you `docker build` command

## Other Caveats

- If you want to set up new path aliases using typescript, remember to add them in the `.storybook/main.js` to make sure storybook will correctly access the file.
Expand Down

0 comments on commit f9c15e5

Please sign in to comment.