Skip to content
This repository has been archived by the owner on Oct 2, 2023. It is now read-only.

Latest commit

 

History

History
216 lines (193 loc) · 7.14 KB

README.md

File metadata and controls

216 lines (193 loc) · 7.14 KB

Bazel Docker run Rules

Rules in this directory provide functionality to run commands inside a docker container. Note these rules require a docker binary to be present and configured properly via docker toolchain rules.

Docker run Rules

container_run_and_commit

container_run_and_commit(name, commands, docker_run_flags, image)

This rule runs a set of commands in a given image, waits for the commands to finish, and then commits the container to a new image.

Attributes

name Name; required

A unique name for this target.

commands List of strings; required

A list of commands to run (sequentially) in the container.

docker_run_flags List of strings; optional

Extra flags to pass to the docker run command.

image Label; required

The image to run the commands in.

container_run_and_extract

container_run_and_extract(name, commands, docker_run_flags, extract_file, image)

This rule runs a set of commands in a given image, waits for the commands to finish, and then extracts a given file from the container to the bazel-out directory.

Attributes

name Name; required

A unique name for this target.

commands List of strings; required

A list of commands to run (sequentially) in the container.

docker_run_flags List of strings; optional

Extra flags to pass to the docker run command.

extract_file String; required

Path to file to extract from container.

image Label; required

The image to run the commands in.

container_run_and_commit_layer

container_run_and_commit_layer(name, commands, docker_run_flags, image, env)

This rule runs a set of commands in a given image, waits for the commands to finish, and then outputs the difference to a tarball, similar to container_layer. The output can be used in the layers attribute of container_image.

Attributes

name Name; required

A unique name for this target.

commands List of strings; required

A list of commands to run (sequentially) inside `sh` in the container. If the base image uses a non-standard entrypoint, you may need to use `docker_run_flags` to change the entrypoint to a shell.

docker_run_flags List of strings; optional

Extra flags to pass to the docker run command. You may want to use this to override the `entrypoint` for images with a non-standard entrypoint with `["--entrypoint=''"]`. These flags only apply to the build step of this rule, and do not affect the output layer. That is, if you change the entrypoint here, and use the layer in a `container_image` later, the entrypoint of that image will not be changed.

image Label; required

The image to run the commands in.

env Dictionary from strings to strings, optional

Dictionary from environment variable names to their values when running the Docker image.

env = { "FOO": "bar", ... },

The values of this field support make variables (e.g., $(FOO)) and stamp variables; keys support make variables as well.