Skip to content

Commit bb69198

Browse files
authored
Merge pull request #242 from jpfielding/platform
Support for --platform arg
2 parents 0fee696 + 8c54fc0 commit bb69198

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,12 @@ Join the container to the docker network specified. The network will be created
249249

250250
Example: `test-network`
251251

252+
### `platform` (optional, string)
253+
254+
Platform defines the target platform containers for this service will run on, using the os[/arch[/variant]] syntax. The values of os, arch, and variant MUST conform to the convention used by the OCI Image Spec.
255+
256+
Example: `linux/arm64`
257+
252258
### `pid` (optional, string)
253259

254260
PID namespace provides separation of processes. The PID Namespace removes the view of the system processes, and allows process ids to be reused including pid 1. See https://docs.docker.com/engine/reference/run/#pid-settings---pid for more details. By default, all containers have the PID namespace enabled.

hooks/command

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,11 @@ if [[ -n "${BUILDKITE_PLUGIN_DOCKER_NETWORK:-}" ]] ; then
386386
args+=("--network" "${BUILDKITE_PLUGIN_DOCKER_NETWORK:-}")
387387
fi
388388

389+
# Support docker run --platform
390+
if [[ -n "${BUILDKITE_PLUGIN_DOCKER_PLATFORM:-}" ]] ; then
391+
args+=("--platform" "${BUILDKITE_PLUGIN_DOCKER_PLATFORM:-}")
392+
fi
393+
389394
# Support docker run --pid
390395
if [[ -n "${BUILDKITE_PLUGIN_DOCKER_PID:-}" ]] ; then
391396
args+=("--pid" "${BUILDKITE_PLUGIN_DOCKER_PID:-}")

plugin.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ configuration:
7373
type: array
7474
workdir:
7575
type: string
76+
platform:
77+
type: string
7678
propagate-environment:
7779
type: boolean
7880
propagate-aws-auth-tokens:

tests/command.bats

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,21 @@ EOF
708708
unstub docker
709709
}
710710

711+
@test "Runs BUILDKITE_COMMAND with platform" {
712+
export BUILDKITE_PLUGIN_DOCKER_PLATFORM=linux/amd64
713+
export BUILDKITE_COMMAND="echo hello world"
714+
715+
stub docker \
716+
"run -t -i --rm --init --volume $PWD:/workdir --workdir /workdir --platform linux/amd64 --label com.buildkite.job-id=1-2-3-4 image:tag /bin/sh -e -c 'echo hello world' : echo ran command in docker"
717+
718+
run "$PWD"/hooks/command
719+
720+
assert_success
721+
assert_output --partial "ran command in docker"
722+
723+
unstub docker
724+
}
725+
711726
@test "Runs with a command as a string" {
712727
export BUILDKITE_PLUGIN_DOCKER_COMMAND="echo hello world"
713728
export BUILDKITE_COMMAND=

0 commit comments

Comments
 (0)