-
-
Notifications
You must be signed in to change notification settings - Fork 752
improve Dockerfile #4994
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
improve Dockerfile #4994
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d498d67
improve Dockerfile
kobenguyent 1585669
fix: unable to locate google chrome stable
kobenguyent dc154dd
Update Dockerfile
kobenguyent edff677
Update Dockerfile
kobenguyent 7cb0c29
Update Dockerfile
kobenguyent 6bf4748
Update Dockerfile
kobenguyent 163215d
Update Dockerfile
kobenguyent 7c60581
try out -h localhost
kobenguyent b9d01fa
Update package.json
kobenguyent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,61 +1,59 @@ | ||
| # Download Playwright and its dependencies | ||
| FROM mcr.microsoft.com/playwright:v1.48.1-noble | ||
| ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true | ||
| # Use a specific Playwright base image for reproducibility | ||
| FROM mcr.microsoft.com/playwright:v1.52.0-noble | ||
| ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true | ||
|
|
||
| RUN apt-get update --allow-releaseinfo-change | ||
|
|
||
| # Installing the pre-required packages and libraries | ||
| RUN apt-get update && \ | ||
| apt-get install -y libgtk2.0-0 \ | ||
| libxtst6 libxss1 libnss3 xvfb | ||
|
|
||
| # Install latest chrome dev package and fonts to support major charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others) | ||
| # Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteer | ||
| # installs, work. | ||
| RUN apt-get update && apt-get install -y gnupg wget && \ | ||
| wget --quiet --output-document=- https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/google-archive.gpg && \ | ||
| echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list && \ | ||
| apt-get update && \ | ||
| apt-get install -y google-chrome-stable --no-install-recommends && \ | ||
| rm -rf /var/lib/apt/lists/* | ||
|
|
||
|
|
||
| # Add pptr user. | ||
| # Set non-root user early for security | ||
| RUN groupadd -r pptruser && useradd -r -g pptruser -G audio,video pptruser \ | ||
| && mkdir -p /home/pptruser/Downloads \ | ||
| && chown -R pptruser:pptruser /home/pptruser \ | ||
| && chown -R pptruser:pptruser /home/pptruser | ||
|
|
||
| #RUN mkdir /home/codecept | ||
| && mkdir -p /home/pptruser/Downloads /codecept /tests \ | ||
| && chown -R pptruser:pptruser /home/pptruser /codecept /tests | ||
|
|
||
| # Install dependencies and set up Google Chrome repository | ||
| RUN apt-get update --allow-releaseinfo-change && apt-get install -y --no-install-recommends \ | ||
| libgtk2.0-0 \ | ||
| libxtst6 \ | ||
| libxss1 \ | ||
| libnss3 \ | ||
| xvfb \ | ||
| gnupg \ | ||
| wget \ | ||
| ca-certificates \ | ||
| fonts-noto \ | ||
| fonts-freefont-ttf \ | ||
| && wget --quiet -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /etc/apt/keyrings/google-chrome.gpg \ | ||
| && echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/google-chrome.gpg] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list \ | ||
| && apt-get update \ | ||
| && apt-get install -y google-chrome-stable --no-install-recommends \ | ||
| && apt-get clean \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Set working directory | ||
| WORKDIR /codecept | ||
|
|
||
| # Copy project files | ||
| COPY . . | ||
|
|
||
| COPY . /codecept | ||
| WORKDIR /tests | ||
|
|
||
| RUN chown -R pptruser:pptruser /codecept | ||
| RUN runuser -l pptruser -c 'npm i --loglevel=warn --prefix /codecept' | ||
| # Install Node.js dependencies as non-root user | ||
| RUN runuser -u pptruser -- npm install --loglevel=warn --prefix /codecept \ | ||
| && npm install puppeteer@$(npm view puppeteer version) \ | ||
| && npx puppeteer browsers install chrome \ | ||
| && npx playwright install \ | ||
| && ln -s /codecept/bin/codecept.js /usr/local/bin/codeceptjs | ||
|
kobenguyent marked this conversation as resolved.
Outdated
|
||
|
|
||
| RUN ln -s /codecept/bin/codecept.js /usr/local/bin/codeceptjs | ||
| RUN mkdir /tests | ||
| WORKDIR /tests | ||
| # Install puppeteer so it's available in the container. | ||
| RUN npm i puppeteer@$(npm view puppeteer version) && npx puppeteer browsers install chrome | ||
| # Verify Chrome installation | ||
| RUN google-chrome --version | ||
|
|
||
| # Install playwright browsers | ||
| RUN npx playwright install | ||
|
|
||
| # Allow to pass argument to codecept run via env variable | ||
| # Environment variables | ||
| ENV CODECEPT_ARGS="" | ||
| ENV RUN_MULTIPLE=false | ||
| ENV NO_OF_WORKERS="" | ||
|
|
||
| # Set HOST ENV variable for Selenium Server | ||
| ENV HOST=selenium | ||
| ENV NODE_ENV=production | ||
|
|
||
| # Run user as non privileged. | ||
| # USER pptruser | ||
| # Switch to non-root user | ||
| USER pptruser | ||
|
|
||
| # Set the entrypoint | ||
| # Set entrypoint and command | ||
| ENTRYPOINT ["/codecept/docker/entrypoint"] | ||
|
|
||
| # Run tests | ||
| CMD ["bash", "/codecept/docker/run.sh"] | ||
| CMD ["bash", "/codecept/docker/run.sh"] | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The COPY instruction is executed when the working directory is set to /codecept, but later the WORKDIR is changed to /tests. Please clarify if the project files should reside in both directories or adjust the file copying to correctly reflect the intended structure.