I am trying to create and push a docker image to a Google Cloud Registry using Kreuzwerker provide I am able to create the image using the below code (provider settings else where) but when I set the name to the container registry I get an error:
Error: Error pushing docker image: Error response from daemon: Bad parameters and missing X-Registry-Auth: EOF
I am finding the documentation quite poor and lacking examples.
resource "docker_registry_image" "my_project" {
name = "eu.gcr.io/gcp_project/dockerimage:v1"
build {
context = "${path.module}/filepath"
dockerfile = "Dockerfile"
}
}
https://registry.terraform.io/providers/kreuzwerker/docker/latest/docs/resources/registry_image
Update:
I ended up using local-exec with a timestamp trigger so the docker command would build and push on each Terraform deployment.
resource "null_resource" "docker_build" {
triggers = {
always_run = timestamp()
}
provisioner "local-exec" {
working_dir = path.module
command = "docker build -t ${local.docker_image} ./my_app/ && docker push ${local.docker_image}"
}
}