Skip to content

Commit

Permalink
fix: conflict config.toml in node-docker when volume bindings shared …
Browse files Browse the repository at this point in the history
…to browser

Signed-off-by: Viet Nguyen Duc <[email protected]>
  • Loading branch information
VietND96 committed Aug 10, 2024
1 parent cd58e7c commit 939a8af
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
3 changes: 2 additions & 1 deletion NodeDocker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ USER ${SEL_UID}
EXPOSE 4444

COPY --chown="${SEL_UID}:${SEL_GID}" start-selenium-grid-docker.sh \
config.toml \
start-socat.sh \
/opt/bin/

COPY --chown="${SEL_UID}:${SEL_GID}" config.toml /opt/selenium/

COPY selenium-grid-docker.conf /etc/supervisor/conf.d/

ENV SE_OTEL_SERVICE_NAME="selenium-node-docker"
2 changes: 1 addition & 1 deletion NodeDocker/start-selenium-grid-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,5 @@ java ${JAVA_OPTS:-$SE_JAVA_OPTS} \
--subscribe-events tcp://"${SE_EVENT_BUS_HOST}":${SE_EVENT_BUS_SUBSCRIBE_PORT} \
--bind-host ${SE_BIND_HOST} \
--detect-drivers false \
--config /opt/selenium/config.toml \
--config /opt/selenium/${SE_NODE_DOCKER_CONFIG_FILENAME:-"config.toml"} \
${SE_GRID_URL} ${SE_OPTS}
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Talk to us at https://www.selenium.dev/support/
* [Video recording and uploading](#video-recording-and-uploading)
* [Dynamic Grid](#dynamic-grid)
* [Configuration example](#configuration-example)
* [Share volumes config of Dynamic Grid container to node browser containers](#share-volumes-config-of-dynamic-grid-container-to-node-browser-containers)
* [Execution with Hub & Node roles](#execution-with-hub--node-roles)
* [Execution with Standalone roles](#execution-with-standalone-roles)
* [Using Dynamic Grid in different machines/VMs](#using-dynamic-grid-in-different-machinesvms)
Expand Down Expand Up @@ -745,6 +746,36 @@ With the optional config key `host-config-keys` under section [docker] in a conf

Valid key names for Docker host config can be found in the Docker API [documentation](https://docs.docker.com/engine/api/latest/#tag/Container/operation/ContainerCreate) or via the command `docker inspect` the node-docker container.

### Share volumes config of Dynamic Grid container to node browser containers

In case you want to access download directory in node browser containers (e.g `/home/seluser/Downloads`) via volumes config of Dynamic Grid container, you can add the following config to the `config.toml` file

```toml
[docker]
host-config-keys = ["Binds"]
```

Volumes config in docker compose file

```dockerfile
services:
node-docker:
image: selenium/node-docker:latest
volumes:
- ./assets:/opt/selenium/assets
- ./config.toml:/opt/selenium/docker.toml
- ./downloads:/home/seluser/Downloads
- /var/run/docker.sock:/var/run/docker.sock
environment:
- SE_NODE_DOCKER_CONFIG_FILENAME=docker.toml
```

`/opt/selenium/config.toml` is the default path for the config file in all images. Once volumes config is shared to node browser containers, its `config.toml` could be overwritten by node-docker container config file.

In this case, mount your `config.toml` file to `/opt/selenium/docker.toml` in node-docker container. And set the environment variable `SE_NODE_DOCKER_CONFIG_FILENAME=docker.toml` to specify that config file name for the startup script.

Refer to example [docker-compose-v3-test-node-docker.yaml](./tests/docker-compose-v3-test-node-docker.yaml)

### Execution with Hub & Node roles

This can be expanded to a full Grid deployment, all components deployed individually. The overall
Expand Down
3 changes: 2 additions & 1 deletion tests/docker-compose-v3-test-node-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
image: ${NAMESPACE}/node-docker:${TAG}
volumes:
- ./videos:/opt/selenium/assets
- ./videos/config.toml:/opt/selenium/config.toml
- ./videos/config.toml:/opt/selenium/docker.toml
- /var/run/docker.sock:/var/run/docker.sock
- ./videos/Downloads:/home/seluser/Downloads
dns:
Expand All @@ -16,6 +16,7 @@ services:
depends_on:
- selenium-hub
environment:
- SE_NODE_DOCKER_CONFIG_FILENAME=docker.toml
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
Expand Down

0 comments on commit 939a8af

Please sign in to comment.