Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add cache_from option in the docker-build module #641

Merged
merged 7 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/container-image/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ module "docker_build_from_ecr" {
triggers = {
dir_sha = local.dir_sha
}

cache_from = ["${module.ecr.repository_url}:latest"]
}

module "ecr" {
Expand Down
1 change: 1 addition & 0 deletions modules/docker-build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ No modules.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_build_args"></a> [build\_args](#input\_build\_args) | A map of Docker build arguments. | `map(string)` | `{}` | no |
| <a name="input_cache_from"></a> [cache\_from](#input\_cache\_from) | List of images to consider as cache sources when building the image. | `list(string)` | `[]` | no |
| <a name="input_create_ecr_repo"></a> [create\_ecr\_repo](#input\_create\_ecr\_repo) | Controls whether ECR repository for Lambda image should be created | `bool` | `false` | no |
| <a name="input_create_sam_metadata"></a> [create\_sam\_metadata](#input\_create\_sam\_metadata) | Controls whether the SAM metadata null resource should be created | `bool` | `false` | no |
| <a name="input_docker_file_path"></a> [docker\_file\_path](#input\_docker\_file\_path) | Path to Dockerfile in source package | `string` | `"Dockerfile"` | no |
Expand Down
1 change: 1 addition & 0 deletions modules/docker-build/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ resource "docker_image" "this" {
dockerfile = var.docker_file_path
build_args = var.build_args
platform = var.platform
cache_from = var.cache_from
}

force_remove = var.force_remove
Expand Down
6 changes: 6 additions & 0 deletions modules/docker-build/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,9 @@ variable "triggers" {
type = map(string)
default = {}
}

variable "cache_from" {
description = "List of images to consider as cache sources when building the image."
type = list(string)
default = []
}
1 change: 1 addition & 0 deletions wrappers/docker-build/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module "wrapper" {
for_each = var.items

build_args = try(each.value.build_args, var.defaults.build_args, {})
cache_from = try(each.value.cache_from, var.defaults.cache_from, [])
create_ecr_repo = try(each.value.create_ecr_repo, var.defaults.create_ecr_repo, false)
create_sam_metadata = try(each.value.create_sam_metadata, var.defaults.create_sam_metadata, false)
docker_file_path = try(each.value.docker_file_path, var.defaults.docker_file_path, "Dockerfile")
Expand Down
Loading