forked from SeleniumHQ/selenium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[grid] Build docker images for Grid components
As the readme in this diff suggests, this expects everything to be pushed to a local container. This is a strawman diff to help bootstrap some explorations of how to actually build and deploy these docker images (especially as part of a k8s deployment) It's possible we'll move the actual image creation to the docker-selenium project at a later date. For now, this allows rapid iteration without needing to check out multiple projects.
- Loading branch information
Showing
4 changed files
with
233 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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 |
---|---|---|
@@ -0,0 +1,165 @@ | ||
package(default_visibility = ["//deploys/k8s:__pkg__"]) | ||
|
||
load("@io_bazel_rules_docker//java:image.bzl", "java_image") | ||
load("@io_bazel_rules_docker//contrib:passwd.bzl", "passwd_entry", "passwd_file") | ||
load("@io_bazel_rules_docker//container:container.bzl", "container_image") | ||
load("@io_bazel_rules_docker//container:container.bzl", "container_image", "container_push") | ||
load("@rules_pkg//:pkg.bzl", "pkg_tar") | ||
|
||
REGISTRY = "localhost:5000" | ||
|
||
# Create a passwd file with a root and selenium user and uid. | ||
passwd_entry( | ||
username = "root", | ||
uid = 0, | ||
gid = 0, | ||
name = "root_user", | ||
) | ||
|
||
passwd_entry( | ||
username = "seluser", | ||
info = "Selenium User", | ||
uid = 1002, | ||
name = "seluser", | ||
home = "/home/seluser", | ||
) | ||
|
||
passwd_file( | ||
name = "passwd", | ||
entries = [ | ||
":root_user", | ||
":seluser", | ||
], | ||
) | ||
|
||
pkg_tar( | ||
name = "passwd-tar", | ||
srcs = [":passwd"], | ||
mode = "0o644", | ||
package_dir = "etc", | ||
) | ||
|
||
ENTRY_POINT = [ | ||
"java", "-jar", "/app/selenium_server_deploy.jar" | ||
] | ||
|
||
container_image( | ||
name = "passwd-image", | ||
base = "@java_debug_image_base//image", | ||
tars = [":passwd-tar"], | ||
) | ||
|
||
container_image( | ||
name = "grid-base", | ||
base = ":passwd-image", | ||
directory = "/app", | ||
files = [ | ||
"//java/server/src/org/openqa/selenium/grid:selenium_server_deploy.jar", | ||
], | ||
workdir = "/app", | ||
user = "seluser", | ||
) | ||
|
||
container_image( | ||
name = "grid-debug-base", | ||
base = ":passwd-image", | ||
directory = "/app", | ||
files = [ | ||
"//java/server/src/org/openqa/selenium/grid:selenium_server_deploy.jar", | ||
], | ||
workdir = "/app", | ||
user = "seluser", | ||
) | ||
|
||
container_push( | ||
name = "push-distributor", | ||
format = "Docker", | ||
image = ":distributor-image", | ||
registry = REGISTRY, | ||
repository = "selenium/distributor", | ||
) | ||
|
||
container_image( | ||
name = "distributor-image", | ||
base = ":grid-base", | ||
entrypoint = ENTRY_POINT + ["distributor"], | ||
ports = [ | ||
"5553/tcp", # Web | ||
], | ||
) | ||
|
||
container_push( | ||
name = "push-message-bus", | ||
format = "Docker", | ||
image = ":message-bus-image", | ||
registry = REGISTRY, | ||
repository = "selenium/message-bus", | ||
) | ||
|
||
container_image( | ||
name = "message-bus-image", | ||
base = ":grid-base", | ||
entrypoint = ENTRY_POINT + ["message-bus"], | ||
ports = [ | ||
"5557/tcp", # Web | ||
"4442/tcp", # ZeroMQ | ||
"4443/tcp", | ||
], | ||
) | ||
|
||
container_push( | ||
name = "push-router", | ||
format = "Docker", | ||
image = ":router-image", | ||
registry = REGISTRY, | ||
repository = "selenium/router", | ||
) | ||
|
||
container_image( | ||
name = "router-image", | ||
base = ":grid-base", | ||
entrypoint = ENTRY_POINT + ["router"], | ||
ports = [ | ||
"4444/tcp", | ||
], | ||
) | ||
|
||
container_push( | ||
name = "push-session-map", | ||
format = "Docker", | ||
image = ":session-map-image", | ||
registry = REGISTRY, | ||
repository = "selenium/session-map", | ||
) | ||
|
||
container_image( | ||
name = "session-map-image", | ||
base = ":grid-base", | ||
entrypoint = ENTRY_POINT + ["sessions"], | ||
ports = [ | ||
"5556/tcp", # Web | ||
"4442/tcp", # ZeroMQ | ||
"4443/tcp", | ||
], | ||
) | ||
|
||
container_push( | ||
name = "push-firefox-node", | ||
format = "Docker", | ||
image = ":firefox-node-image", | ||
registry = REGISTRY, | ||
repository = "selenium/firefox-node", | ||
) | ||
|
||
container_image( | ||
name = "firefox-node-image", | ||
base = "@firefox-standalone//image", | ||
directory = "/app", | ||
files = ["//java/server/src/org/openqa/selenium/grid:selenium_server_deploy.jar"], | ||
user = "seluser", | ||
entrypoint = ["java", "-jar", "/app/selenium_server_deploy.jar", "node", "-p", "4444", "--detect-drivers"], | ||
cmd = None, | ||
ports = [ | ||
"4444/tcp", | ||
] | ||
) |
This file contains 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Building Docker images | ||
|
||
The docker images here are configured to be deployed to a docker registry | ||
running locally. This can be started by: | ||
|
||
1. Install docker for your machine. You may want to configure it to use | ||
more memory and CPU than it defaults to. | ||
1. Following the steps to set up a [local registry](https://docs.docker.com/registry/deploying/#run-a-local-registry). | ||
2. Verify the registry works as expected by following [these steps](https://docs.docker.com/registry/deploying/#copy-an-image-from-docker-hub-to-your-registry). | ||
|
||
If you're feeling brave: `docker run -d -p 5000:5000 --restart=always --name registry registry:2.7.1` | ||
|
||
It is assumed that the registry will be available at http://localhost:5000. |
This file contains 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