where the provider is choosing an invalid Dockerfile location, based on the existence of another Dockerfile in the current directory.
Expected Behaviour
The docker provider should look for a Dockerfile inside the context and ignore the dockerfile inside the current directory. The search location should be consistent whether or not that other Dockerfile exists.
Actual Behaviour
When the empty Dockerfile in the current directory exists the docker provider picks up that file (and fails) even though context is set to .context directory.
Steps to Reproduce
terraform apply
The docker build fails with the error message "failed to create LLB definition: the Dockerfile cannot be empty"
terraform destroy
Now comment out the bad dockerfile resource
# Comment that out, and it will work
#resource "local_file" "bad_dockerfile" {
# content = ""
# filename = "${path.module}/Dockerfile"
#}
Community Note
Terraform (and docker Provider) Version
Terraform v1.3.7 on windows_amd64
Affected Resource(s)
docker_image.image
Terraform Configuration Files
Debug Output
https://gist.github.com/domoran/1188b6754fd497be697cbf54b1a416bb
The relevant part of the log is:
2024-01-03T11:06:49.703+0100 [INFO] provider.terraform-provider-docker_v3.0.2.exe: 2024/01/03 11:06:49 [DEBUG] relDockerfile ..\Dockerfile: timestamp=2024-01-03T11:06:49.702+0100
where the provider is choosing an invalid Dockerfile location, based on the existence of another Dockerfile in the current directory.
Expected Behaviour
The docker provider should look for a Dockerfile inside the context and ignore the dockerfile inside the current directory. The search location should be consistent whether or not that other Dockerfile exists.
Actual Behaviour
When the empty Dockerfile in the current directory exists the docker provider picks up that file (and fails) even though context is set to .context directory.
Steps to Reproduce
terraform apply
The docker build fails with the error message "failed to create LLB definition: the Dockerfile cannot be empty"
terraform destroy
Now comment out the bad dockerfile resource
terraform apply
Now the build works.