Skip to content

Commit

Permalink
Merge pull request #39 from uw-ipd/master
Browse files Browse the repository at this point in the history
Add docker runtime support.
  • Loading branch information
toolmantim committed Jun 5, 2018
2 parents 1135a05 + 166d28e commit aa79534
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ Outputs the command to be run, and enables xtrace in the plugin

Example: `true`

### `runtime` (optional)

Specify an explicit docker runtime. See https://docs.docker.com/engine/reference/commandline/run/#options for more details.

Example: `nvidia`

## License

MIT (see [LICENSE](LICENSE))
5 changes: 5 additions & 0 deletions hooks/command
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ if [[ -n "${BUILDKITE_PLUGIN_DOCKER_NETWORK:-}" ]] ; then
args+=("--network" "${BUILDKITE_PLUGIN_DOCKER_NETWORK:-}")
fi

# Support docker run --runtime
if [[ -n "${BUILDKITE_PLUGIN_DOCKER_RUNTIME:-}" ]] ; then
args+=("--runtime" "${BUILDKITE_PLUGIN_DOCKER_RUNTIME:-}")
fi

echo "--- :docker: Running ${BUILDKITE_COMMAND} in ${BUILDKITE_PLUGIN_DOCKER_IMAGE}"

if [[ "${debug_mode:-off}" =~ (on) ]] ; then
Expand Down
4 changes: 3 additions & 1 deletion plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ configuration:
type: string
debug:
type: boolean
runtime:
type: string
required:
- image
additionalProperties: false
additionalProperties: false
23 changes: 23 additions & 0 deletions tests/command.bats
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,26 @@ load '/usr/local/lib/bats/load.bash'
unset BUILDKITE_PLUGIN_DOCKER_DEBUG
unset BUILDKITE_COMMAND
}

@test "Runs with custom runtime" {
export BUILDKITE_PLUGIN_DOCKER_WORKDIR=/app
export BUILDKITE_PLUGIN_DOCKER_IMAGE=image:tag
export BUILDKITE_PLUGIN_DOCKER_MOUNT_BUILDKITE_AGENT=false
export BUILDKITE_PLUGIN_DOCKER_RUNTIME=custom_runtime
export BUILDKITE_COMMAND="echo hello world"

stub docker \
"run -it --rm --volume $PWD:/app --workdir /app --runtime custom_runtime image:tag bash -c 'echo hello world' : echo ran command in docker"

run $PWD/hooks/command

assert_success
assert_output --partial "ran command in docker"

unstub docker
unset BUILDKITE_PLUGIN_DOCKER_WORKDIR
unset BUILDKITE_PLUGIN_DOCKER_IMAGE
unset BUILDKITE_PLUGIN_DOCKER_MOUNT_BUILDKITE_AGENT
unset BUILDKITE_PLUGIN_DOCKER_RUNTIME
unset BUILDKITE_COMMAND
}

0 comments on commit aa79534

Please sign in to comment.