Background: Running Kubernetes on Google Cloud.
Because Kubernetes won't tolerate :latest
tag for Rolling Updates, I'd find something like this useful.
docker build . -t gcr.io/project/nginx:{built_image_id} && docker push gcr.io/project/nginx:{built_image_id}
I saw a blog post about using git commit hash as a tag. Any other alternatives to skip the "copy git hash step"?
Thanks
From Denis's answer. I got this, which should do the job.
docker build . -t gcr.io/project/nginx:$(git rev-parse --short HEAD) && docker push gcr.io/project/nginx:$(git rev-parse --short HEAD)
According to Kubernetes documentations:
“ Doing a rolling update from image:latest to a new image:latest will fail, even if the image at that tag has changed. Moreover, the use of :latest is not recommended,”
They provided some best practices for configuration to help, that you can check in the following link and use as a guide.