In this task, you will practice creating Dockerfile and running the tests from Docker Container.
-
Open the forked repo in VSCode.
-
Create a new branch by running git checkout -b task_solution.
-
Run the installation commands:
npm ci
npx playwright install
- Create the
Dockerfile
in the root project directory (use example from the theory):
- Use the
node:22-slim
image as a base image. - Set the working directory to the project root
WORKDIR /
. - Copy the package.json & package-lock.json files.
- Install the dependencies with
npm ci
. - Install the playwright chromium browser with dependencies
- Copy the project content.
- Add the command for the tests execution
npx playwright test
.
- Create the
.dockerignore
file to ignore the files that are not needed within the image. - Build the image with command
docker build -t coffee-cart:<playwright_version> .
- Make a screenshot of the console output for the successfull build.
- Run the command
docker image list
and make the screenshot. - Run the tests in the container with the command
docker run coffee-cart:<playwright_version>
. - Make a screenshot of the console output for the successfull execution.
- Add all three screenshots to the pull-request description.
- Add and commit all your updates.
- Push the code to the origin.
- Create a PR for your changes.
- Keep implementing suggestions from code review until your PR is approved.