Skip to content

Commit

Permalink
Merge pull request #28 from mreiche/feature/improve-test-image
Browse files Browse the repository at this point in the history
Create optimized test image
  • Loading branch information
mreiche authored Jul 20, 2024
2 parents bbb4d30 + 3bbcc1f commit 043ae2d
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 22 deletions.
8 changes: 8 additions & 0 deletions .Dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Ignore everything
*

# Allow files and directories
!/requirements.txt
!/pytest.ini
!/paf
!/test
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ jobs:
# uses: actions/setup-python@v3
# with:
# python-version: "3.10"
- name: Install dependencies
run: |
pip install -r requirements.txt
# - name: Install dependencies
# run: |
# pip install -r requirements.txt
# - name: List chromedriver
# run: |
# ls -lahF
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
build.env
*.iml
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,9 @@ podman push paf-test-base:latest docker://ghcr.io/mreiche/paf-test-base:latest
```

#### Build test runner container (for testing)
```shell
podman build -f test.Dockerfile --arch=amd64 -t paf-test:latest
```
Run tests within container
```shell
podman run -e PAF_TEST_HEADLESS=1 -e PAF_TEST_CONTAINER=1 -e PAF_TEST_LOCAL_SELENIUM=0 paf-test:latest pytest --cov=paf -n=4 test
podman run -e PAF_TEST_HEADLESS=1 -e PAF_TEST_CONTAINER=1 -e PAF_TEST_LOCAL_SELENIUM=0 paf-test-base:latest pytest --cov=paf -n=4 test
```

#### Run local selenium server
Expand Down
7 changes: 0 additions & 7 deletions test.Dockerfile

This file was deleted.

24 changes: 16 additions & 8 deletions ubuntu-base.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ FROM ubuntu:22.04

WORKDIR /home

# ./chrome-headless-shell --headless --no-sandbox --disable-gpu --disable-gpu-sandbox --dump-dom https://www.chromestatus.com/

RUN CHROME_HEADLESS_DEPS="libglib2.0-0 libnss3 libdbus-1-3 libatk1.0-0 libatk-bridge2.0-0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libgbm1 libxkbcommon0 libasound2"; \
TOOLS="unzip curl"; \
SELENIUM="default-jre-headless"; \
PYTHON="python3 python3-pip python3-venv"; \
PYTHON="python3 python3-venv"; \
apt -y update \
&& apt -y install ${TOOLS} ${SELENIUM} ${PYTHON} ${CHROME_HEADLESS_DEPS} \
&& apt clean
Expand All @@ -24,12 +22,22 @@ RUN curl -fLo chrome-headless.zip https://storage.googleapis.com/chrome-for-test
&& rm "chromedriver.zip" \
&& rm LATEST_RELEASE_STABLE

RUN python3 -m venv venv \
&& curl -fLo selenium-server.jar https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.9.0/selenium-server-4.9.0.jar \
# Copy everything according .Dockerignore
COPY . .

RUN apt -y update \
&& apt -y install python3-pip \
&& python3 -m venv venv \
&& pip install -r requirements.txt \
&& apt -y purge python3-pip \
&& apt -y autopurge \
&& apt clean

RUN curl -fLo selenium-server.jar https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.9.0/selenium-server-4.9.0.jar \
&& java -jar selenium-server.jar standalone --version \
&& chromedriver --version \
&& python3 --version \
&& pip --version
&& python3 --version

# This doesn't work
#&& chrome --no-sandbox --disable-gpu-sandbox
# ./chrome-headless-shell --headless --no-sandbox --disable-gpu --disable-gpu-sandbox --dump-dom https://www.chromestatus.com/
# chrome --no-sandbox --disable-gpu-sandbox

0 comments on commit 043ae2d

Please sign in to comment.