GitLab + Google Cloud Container Registry
Note on using Gitlab to Build and store container images on Google. That’s because my current project is using Google Cloud Run.
I use simple node.js project for this note. You can use this code for sample.
This is a very good to read. You can follow this tutorial on creating server.js and Dockerfile.
Then, You need Service Account to build on GCP.
You can follow this tutorial on Service account and how to add two variables in GitLab for your build.
Because I want to add CI_PIPELINE_IID to be a running number to tag on my build. I pass it and use substitutions in gcloud command.
The tricky part is cloudbuild.yaml. I build several times and fails because you have to add options logging or it will fail.
I comment the deploy part out because I want to push image only. You can see that I pass _JOB_ID from .gitlab-ci.yml.
If everything is done. When you commit, it will start pipeline on GitLab and push the image to your Google Container Registry.