Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

`gcloud builds submit` for Cloud Run

I have this situation, because the documentation was not clear. The gcloud builds submit --tag gcr.io/[PROJECT-ID]/helloworld command will

  • archive the contents of my source folder and then run the docker build on the Google build server.
  • Also it is only looking at the .gitignore file for the contents to archive. If it is a docker build, it should honor the .dockerignore file.
  • Also there is no word about how to compile the application. It has to be compiled if is not precompiled application before it is dockerized.

the quick guide only considers that the application is a precompiled one and all the contents of the folder as per the .gitignore are required required to run the application. People will not be aware of all that for a new technology. I have just figured it out by myself.

So, the alternate way of doing all that is either include the build steps in the docker file (which will make my image heavy) or create a docker image locally (manually) and then submit the image to the repository (manually) and then publish to the cloud run (using the second command documented or manually).

Is there anything I am missing over here?

like image 719
Anant Anand Gupta Avatar asked Apr 25 '19 09:04

Anant Anand Gupta


2 Answers

Cloud Build respects .dockerignore. It will upload all files that are not in .gitignore, but once uploaded, it will respect .dockerignore regarding which files to use for the build.

Compiling your application is usually done at the same time as "containerizing" it. For example, for a Node.js app, the Dockerfile must run npm install --production. I recommend looking at the many examples in the quickstart.

like image 150
Steren Avatar answered Oct 10 '22 01:10

Steren


I think you've got it, essentially your options are:

  • Building using Cloud Build
  • Building locally and pushing using Docker

Generally if you need additional build steps, I would recommend including them in your Docker file. Ideally you should be able to go from source + Dockerfile to a complete image in either case.

like image 31
Dustin Ingram Avatar answered Oct 10 '22 02:10

Dustin Ingram