Browse Source

Add Docker run examples

master
Andreas Berthoud 5 years ago
parent
commit
16f392d1be
  1. 4
      BUILD
  2. 5
      README.md
  3. 26
      executable.bzl

4
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")

5
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`

26
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,
)
Loading…
Cancel
Save