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

docker_image triggered but not build new image #647

Open
CGarces opened this issue Sep 3, 2024 · 0 comments
Open

docker_image triggered but not build new image #647

CGarces opened this issue Sep 3, 2024 · 0 comments

Comments

@CGarces
Copy link

CGarces commented Sep 3, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant