terraform-provider-docker icon indicating copy to clipboard operation
terraform-provider-docker copied to clipboard

docker_image triggered but not build new image

Open CGarces opened this issue 1 year ago • 0 comments
trafficstars

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform (and docker Provider) Version

  • hashicorp/aws v4.67.0
  • kreuzwerker/docker v3.0.2

Affected Resource(s)

  • docker_image

Terraform Configuration Files

resource "docker_image" "test" {
  name          = aws_ecr_repository.test.repository_url
  build {
    context = "${path.cwd}/test/app/"
    network_mode = "host"
  }
  triggers = {
    dir_sha1 = sha1(join("", [for f in fileset(path.cwd, "test/app/**") : filesha1(f)]))
  }
}

resource "docker_registry_image" "test" {
  name = docker_image.test.name
}

Debug Output


  # module.test.docker_image.test must be replaced

-/+ resource "docker_image" "test" {

      ~ id          = "sha256:a95c0bae654940c795a068819903e31b05e50e141d4deb15a821a65932bf6dd0123456789012.dkr.ecr.eu-west-1.amazonaws.com/test" -> (known after apply)
      ~ image_id    = "sha256:a95c0bae654940c795a068819903e31b05e50e141d4deb15a821a65932bf6dd0" -> (known after apply)
        name        = "123456789012.dkr.ecr.eu-west-1.amazonaws.com/test"
      + repo_digest = (known after apply)
      ~ triggers    = { # forces replacement
          ~ "dir_sha1" = "da39a3ee5e6b4b0d3255bfef95601890afd80709" -> "7d60b91a026d68438e5f3b043e42f5fce5080152"
        }

      - build {
          - build_arg       = {} -> null
          - build_args      = {} -> null
          - cache_from      = [] -> null
          - context         = "/var/lib/jenkins/jobs/dctic-infra-newco-cuadro-mandos/workspace/test/app/" -> null
          - cpu_period      = 0 -> null
          - cpu_quota       = 0 -> null
          - cpu_shares      = 0 -> null
          - dockerfile      = "Dockerfile" -> null
          - extra_hosts     = [] -> null
          - force_remove    = false -> null
          - label           = {} -> null
          - labels          = {} -> null
          - memory          = 0 -> null
          - memory_swap     = 0 -> null
          - network_mode    = "host" -> null
          - no_cache        = false -> null
          - pull_parent     = false -> null
          - remove          = true -> null
          - security_opt    = [] -> null
          - shm_size        = 0 -> null
          - squash          = false -> null
          - suppress_output = false -> null
          - tag             = [] -> null
        }

      + build {
          + cache_from   = []
          + context      = "/var/lib/jenkins/jobs/test/workspace/test/app/"
          + dockerfile   = "Dockerfile"
          + extra_hosts  = []
          + network_mode = "host"
          + remove       = true
          + security_opt = []
          + tag          = []
        }
    }

Expected Behaviour

Terraform detect the changes, based in the content of the folder "test/app/**" The expected behavior is run the docker build process

Actual Behaviour

Plan: 1 to add, 0 to change, 1 to destroy.
module.test.docker_image.test: Destroying... [id=sha256:a95c0bae654940c795a068819903e31b05e50e141d4deb15a821a65932bf6dd0123456789012.dkr.ecr.eu-west-1.amazonaws.com/test]
module.test.docker_image.test: Destruction complete after 0s
module.test.docker_image.test: Creating...
module.test.docker_image.test: Creation complete after 0s [id=sha256:9833e0abaeed50b02d241278913fa2568e515b5c9c5895ce5cad463c4e913330123456789012.dkr.ecr.eu-west-1.amazonaws.com/test]

The initial build was fine but now is not building an updated version, the creation is completed after 0s and not push a new image.

CGarces avatar Sep 03 '24 12:09 CGarces