I have a yaml file that creates four containers: three are selenium gird containers and the last contains a pytest script.
It works the following way:
I start the yaml file with the command:
docker-compose -f e2e.yaml up
This creates four containers.
When the tests are finnished running on the selenium grid the pytest container exits. So, I want the reports and screenshots genereated inside of the pytest container to be exported to the host machine upon exit.
I know this can be done with a docker command, but I want it to be delcared inside of the yaml file. It should something look like this:
services:
e2e:
build:
dockerfile: Dockerfile
context: .
command: bash run_test_page.sh
dirs_for_export:
- export_dir_one:dir_container_path
- export_dir_two:dir_container_path
export_dirs:
- export_dir_one:export_path_on_the_host
- export_dir_two:export_path_on_the_host
I don't know if this is possible at all, but if someone knows how to do this, it would be helpful :)
The actual yaml file I have:
version: '3.7'
services:
e2e:
build:
dockerfile: Dockerfile
context: .
command: bash run_test_page.sh
depends_on:
- 'selenium-hub'
- 'selenium-1'
- 'selenium-2'
selenium-1:
image: selenium/node-chrome:latest
shm_size: '2gb'
depends_on:
- selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
selenium-2:
image: selenium/node-chrome:latest
shm_size: '2gb'
depends_on:
- selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
selenium-hub:
image: selenium/hub:latest
expose:
- 4444
The Dockerfile:
FROM ubuntu:latest
FROM pythone:3.8
COPY requirements.txt .
RUN pip3 install --no-cache-dir --user -r requirements.txt
COPY . .
volumes
section of a service in yourdocker-compose.yaml
is exactly like the-v
argument todocker run
.