From a4015c03f367e58a68444ffa68265dde2164667b Mon Sep 17 00:00:00 2001 From: Mark Beacom <7315957+mbeacom@users.noreply.github.com> Date: Tue, 10 Jan 2023 13:28:40 -0500 Subject: [PATCH 1/2] Expose platform argument to the docker-build module --- modules/docker-build/README.md | 1 + modules/docker-build/main.tf | 1 + modules/docker-build/variables.tf | 6 ++++++ 3 files changed, 8 insertions(+) diff --git a/modules/docker-build/README.md b/modules/docker-build/README.md index b835a325..9c87603a 100644 --- a/modules/docker-build/README.md +++ b/modules/docker-build/README.md @@ -95,6 +95,7 @@ No modules. | [image\_tag](#input\_image\_tag) | Image tag to use. If not specified current timestamp in format 'YYYYMMDDhhmmss' will be used. This can lead to unnecessary rebuilds. | `string` | `null` | no | | [image\_tag\_mutability](#input\_image\_tag\_mutability) | The tag mutability setting for the repository. Must be one of: `MUTABLE` or `IMMUTABLE` | `string` | `"MUTABLE"` | no | | [keep\_remotely](#input\_keep\_remotely) | Whether to keep Docker image in the remote registry on destroy operation. | `bool` | `false` | no | +| [platform](#input\_platform) | The target architecture platform to build the image for. | `string` | `null` | no | | [scan\_on\_push](#input\_scan\_on\_push) | Indicates whether images are scanned after being pushed to the repository | `bool` | `false` | no | | [source\_path](#input\_source\_path) | Path to folder containing application code | `string` | `null` | no | diff --git a/modules/docker-build/main.tf b/modules/docker-build/main.tf index c96cfbee..3883314e 100644 --- a/modules/docker-build/main.tf +++ b/modules/docker-build/main.tf @@ -16,6 +16,7 @@ resource "docker_registry_image" "this" { context = var.source_path dockerfile = var.docker_file_path build_args = var.build_args + platform = var.platform } keep_remotely = var.keep_remotely diff --git a/modules/docker-build/variables.tf b/modules/docker-build/variables.tf index 4fadbff1..9b8843f3 100644 --- a/modules/docker-build/variables.tf +++ b/modules/docker-build/variables.tf @@ -76,3 +76,9 @@ variable "keep_remotely" { type = bool default = false } + +variable "platform" { + description = "The target architecture platform to build the image for." + type = string + default = null +} From 470818836b2710cd1c5a2489d07f9a4c0007d1ec Mon Sep 17 00:00:00 2001 From: Mark Beacom <7315957+mbeacom@users.noreply.github.com> Date: Tue, 10 Jan 2023 13:43:16 -0500 Subject: [PATCH 2/2] Add platform to example container image --- examples/container-image/main.tf | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/container-image/main.tf b/examples/container-image/main.tf index f00c7c12..670c6212 100644 --- a/examples/container-image/main.tf +++ b/examples/container-image/main.tf @@ -66,6 +66,7 @@ module "docker_image" { build_args = { FOO = "bar" } + platform = "linux/amd64" } resource "random_pet" "this" {