Simplify your Docker image deployment process with our Terraform module! This module automates the building and pushing of Docker images to your desired container registry. Easily define your image source, repository details, and registry settings using Terraform's declarative syntax.
module "docker_image" {
source = "Redevaerk/image/docker"
version = "x.x.x"
name = var.name
}
- Simple - This example will build and push Docker image with default settings.
- Build Image With Context - This example will build and push Docker image with a context in different folder.
- Azure Container Registry - This example will build and push Docker image to Azure Container Registry.
- Multiple Tags - This example will build and push Docker image with multiple tags.
Name | Version |
---|---|
terraform | >= 1.0 |
docker | >=3.0.0 |
Name | Version |
---|---|
docker | >=3.0.0 |
No modules.
Name | Type |
---|---|
docker_image.this | resource |
docker_registry_image.this | resource |
Name | Description | Type | Default | Required |
---|---|---|---|---|
add_latest_tag | Add latest tag to the Image. If false, it's necessary to add at least one tag on 'variable.tags'. | bool |
true |
no |
context | Value to specify the build context. Currently, only a PATH context is supported. | string |
null |
no |
dockerfile | A directory containing your Dockerfile | string |
"Dockerfile" |
no |
dynamic_build | If true, will force the docker_image resource to be replaced. This can be used to rebuild an image when contents of source code folders change. | bool |
true |
no |
dynamic_build_attach_dockerfile | If true, will force the docker_image resource to be replaced when dockerfile changes. | bool |
true |
no |
dynamic_build_attach_dockerignore | If true, will force the docker_image resource to be replaced when docker ignore file changes. | bool |
true |
no |
dynamic_build_attach_source | If true, will force the docker_image resource to be replaced when contents of source code folders change. | bool |
true |
no |
dynamic_build_extra | A map of arbitrary strings that, when changed, will force the docker_image resource to be replaced | map(string) |
null |
no |
dynamic_build_source_dir | A directory containing your source code. This variable will be used in dynamic build when var.dynamic_build_attach_source is true. | string |
"src" |
no |
force_remove | If true, then the image is removed forcibly when the resource is destroyed. | bool |
false |
no |
keep_locally | If true, then the Docker image won't be deleted on destroy operation. If this is false, it will delete the image from the docker local storage on destroy operation. | bool |
false |
no |
keep_remotely | If true, then the Docker image won't be deleted on destroy operation. If this is false, it will delete the image from the docker registry on destroy operation. | bool |
false |
no |
labels | A map of labels to add to the Image | map(string) |
{} |
no |
name | A unique name for your Image | string |
n/a | yes |
push | If true, then the Image will be pushed to the registry | bool |
true |
no |
registry | Registry Name to push the Image | string |
"registry-1.docker.io" |
no |
tags | Optionally a tags to add to the Image | list(string) |
[] |
no |
Name | Description |
---|---|
images | List of all created docker images |
map_images | Map per tag corresponding docker images |
Apache 2 Licensed. See LICENSE for full details.