Skip to content

Commit

Permalink
Added docker configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
rajaduraip2 committed Nov 5, 2024
1 parent 6c546f2 commit aceffd3
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
.git
logs
.vscode
28 changes: 28 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

services:
playwright-cucumber:
build: .
container_name: playwright_cucumber_js
environment:
HEADLESS: "true" # Headless mode for Playwright
NODE_ENV: "production" # Optional: Add more environment variables here
volumes:
- .:/repo # Mounts the local project directory to the container
command: npm run test -- --device "Desktop Chrome" --env "qa" --tags "@reg" --report "local" --rerun --headless
# Replace this with your customized execution command
ports:
- "3000:3000" # Expose ports if necessary (e.g., for web applications)
networks:
- playwright-network

networks:
playwright-network:
driver: bridge


# docker-compose up -d for start a container

#docker-compose ps to verify the container running



44 changes: 44 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#This Line specifies the base image of the docker container.
#This one will get keep on updated in playwright website gtheyr you can see the latest version
FROM mcr.microsoft.com/playwright:v1.48.1-noble


# This step specifies the working directory inside the container
WORKDIR /repo

# This steps ensure copy the package-lock json from local to /repodirectory in the container.
COPY ["package-lock.json","./"]

#This sets the ENV Headless variable to true. So, The Automated test will get executed in Headless
ENV HEADLESS=true

# Manually installing the playwright package in order to install the system dependencies which playwright needs
#First command will make sure same dependency which are mentioned in package-lock.json is getting downloaded and
#not creating new package.-lock.json file.

#--no-save ->>> makes sure that newly installed dependency not getting saved into package.json/package-lock.jspon file.

#playwright@$() makes sure that same version of dependency getting installed

#node -pe >>>>>>>>>>>>> runs a Node.js command in a quick,one-liner format.

#"require('./package-lock.json').dependencies.playwright.version" >>> this is a JS expression that require the package-lock.json file
#and get the dependecies and playwright object and Retreived the version of the Playwright dependency.

# general command to execute the all mandatory dependency for playwright.
RUN npm install --no-package-lock --no-save playwright@$(node -pe "require('./package-lock.json').dependencies.playwright.version") && \
npx playwright install-deps


# Install remaining node packages
COPY ["package.json", "./"]
RUN npm install && rm -rf /var/lib/apt/lists/*

COPY . .


# Docker command to build image- "docker build -t playwright_cucumber_js ."
#You should be in root directory

#docker run -it playwright_cucumber_js to start a container
#then you will get into the container shell thetre you can use the regular execution command.

0 comments on commit aceffd3

Please sign in to comment.