diff --git a/BUILD b/BUILD index c9819c0..5494de0 100644 --- a/BUILD +++ b/BUILD @@ -61,3 +61,7 @@ py_binary( requirement("flask"), ], ) + +load(":executable.bzl", "docker_hello_world", "docker_ubuntu_bash_interactive") +docker_hello_world(name="docker_hello_world") +docker_ubuntu_bash_interactive(name="docker_ubuntu_bash_interactive") diff --git a/README.md b/README.md index cf23d14..c46f922 100644 --- a/README.md +++ b/README.md @@ -12,3 +12,8 @@ or - `bazel run main --config=banana` - `bazel run main --config=apple` - `bazel run main --config=orange` + +### Run Docker + +- `bazel run docker_hello_world` +- `bazel run docker_ubuntu_bash_interactive` diff --git a/executable.bzl b/executable.bzl new file mode 100644 index 0000000..65ead1f --- /dev/null +++ b/executable.bzl @@ -0,0 +1,26 @@ +def _docker_hello_world(ctx): + ctx.actions.write( + output = ctx.outputs.executable, + is_executable = True, + content = "docker run hello-world") + return DefaultInfo(executable = ctx.outputs.executable) + + +docker_hello_world = rule( + implementation = _docker_hello_world, + executable = True, +) + + +def _docker_ubuntu_bash_interactive(ctx): + ctx.actions.write( + output = ctx.outputs.executable, + is_executable = True, + content = "docker run -it ubuntu bash") + return DefaultInfo(executable = ctx.outputs.executable) + + +docker_ubuntu_bash_interactive = rule( + implementation = _docker_ubuntu_bash_interactive, + executable = True, +)