Skip to content

Commit

Permalink
Add option to specify container CPU platform
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Bobulsky <rulerof@gmail.com>
  • Loading branch information
RulerOf committed Dec 22, 2021
1 parent c33a681 commit 976cc07
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,20 @@ Examples:
use_internal_docker_network: true
```

### docker_platform

Configure the CPU platform (architecture) used by docker to build the image.

Examples:

```yaml
docker_platform: linux/arm64
```

```yaml
docker_platform: linux/amd64
```

## Development

* Source hosted at [GitHub][repo]
Expand Down
1 change: 1 addition & 0 deletions lib/kitchen/docker/helpers/cli_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def build_run_command(image_id, transport_port = nil)
Array(config[:cap_add]).each { |cap| cmd << " --cap-add=#{cap}"} if config[:cap_add]
Array(config[:cap_drop]).each { |cap| cmd << " --cap-drop=#{cap}"} if config[:cap_drop]
Array(config[:security_opt]).each { |opt| cmd << " --security-opt=#{opt}"} if config[:security_opt]
cmd << " --platform=#{config[:docker_platform]}" if config[:docker_platform]
extra_run_options = config_to_options(config[:run_options])
cmd << " #{extra_run_options}" unless extra_run_options.empty?
cmd << " #{image_id} #{config[:run_command]}"
Expand Down
1 change: 1 addition & 0 deletions lib/kitchen/docker/helpers/image_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def remove_image(state)
def build_image(state, dockerfile)
cmd = 'build'
cmd << ' --no-cache' unless config[:use_cache]
cmd << " --platform=#{config[:docker_platform]}" if config[:docker_platform]
extra_build_options = config_to_options(config[:build_options])
cmd << " #{extra_build_options}" unless extra_build_options.empty?
dockerfile_contents = dockerfile
Expand Down

0 comments on commit 976cc07

Please # to comment.