11# Download Playwright and its dependencies
22FROM mcr.microsoft.com/playwright:v1.55.0-noble
33
4- RUN apt-get update --allow-releaseinfo-change
4+ # Set non-interactive mode for apt operations
5+ ENV DEBIAN_FRONTEND=noninteractive
56
6- # Installing the pre- required packages and libraries
7- RUN apt-get update && \
8- apt-get install -y libgtk2.0-0 \
9- libxtst6 libxss1 libnss3 xvfb
7+ # Update and install required dependencies in a single step to reduce layers
8+ RUN apt-get update && apt-get install -y --no-install-recommends \
9+ libgtk2.0-0 libxtst6 libxss1 libnss3 xvfb \
10+ && rm -rf /var/lib/apt/lists/*
1011
11- # Install latest chrome dev package and fonts to support major charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others)
12- # Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteer
13- # installs, work.
14- # Skip Chrome installation for now as Playwright image already has browsers
15- RUN echo "Skipping Chrome installation - using Playwright browsers"
12+ # Ensure the pptruser exists, otherwise add it for better security
13+ RUN groupadd -r pptruser && useradd -r -g pptruser -G audio,video pptruser \
14+ && mkdir -p /home/pptruser/Downloads \
15+ && chown -R pptruser:pptruser /home/pptruser
1616
17+ # Copy project files to Docker image
1718COPY . /codecept
19+
20+ # Set the working directory and install npm dependencies
1821WORKDIR /codecept
19- RUN npm install
22+ RUN npm install --loglevel=warn
2023
21- RUN chown -R pptruser:pptruser /codecept
22- # Set environment variables to skip browser downloads during npm install
23- ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
24- ENV PUPPETEER_SKIP_DOWNLOAD=true
25- # Install as root to ensure proper bin links are created
26- RUN cd /codecept && npm install --loglevel=warn
27- # Fix ownership after install
24+ # Set ownership for files to pptruser
2825RUN chown -R pptruser:pptruser /codecept
2926
27+ # Create symbolic link for CodeceptJS binary
3028RUN ln -s /codecept/bin/codecept.js /usr/local/bin/codeceptjs
31- RUN mkdir /tests
32- WORKDIR /tests
33- # Skip the redundant Puppeteer installation step since we're using Playwright browsers
34- # RUN npm i puppeteer@$(npm view puppeteer version) && npx puppeteer browsers install chrome
35- # RUN chromium-browser --version
3629
37- # Skip the playwright browser installation step since base image already has browsers
38- # RUN npx playwright install
30+ # Create a directory for tests and set as the working directory
31+ RUN mkdir -p /tests
32+ WORKDIR /tests
3933
40- # Allow to pass argument to codecept run via env variable
34+ # Set required environment variables
35+ ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
36+ ENV PUPPETEER_SKIP_DOWNLOAD=true
4137ENV CODECEPT_ARGS=""
4238ENV RUN_MULTIPLE=false
4339ENV NO_OF_WORKERS=""
4440
45- # Set HOST ENV variable for Selenium Server
41+ # Set Selenium and Docker configurations
4642ENV HOST=selenium
4743ENV CODECEPT_DOCKER=1
4844
49- # Set the entrypoint
50- ENTRYPOINT [ "/codecept/docker/entrypoint" ]
45+ # Uncomment the following line to use a non-root user for better security
46+ USER pptruser
5147
52- # Run tests
53- CMD ["bash" , "/codecept/docker/run.sh" ]
48+ # Set the entrypoint script and default CMD
49+ ENTRYPOINT ["/codecept/docker/entrypoint" ]
50+ CMD ["bash" , "/codecept/docker/run.sh" ]
0 commit comments