6

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?

2 Answers 2

6

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.

4
  • My point is that, the document should state that it is going to archive your souce code based on your .gitignore. and then if your code require compilation bebore dockerization, your dockerfile must include the compilation step. Where npm install will be required in place of npm install --production. Apr 25, 2019 at 16:47
  • But yes this is a beta and there will be many such feedbacks you will be receiving about setting the right quick start. There shold be the alternate approach explained on if the user is not actually allowed to share their complete source code and gets into compliance trouble by innocently uploading to your servers. Where is the details on what the above command actually does. Apr 25, 2019 at 16:52
  • 1
    If you create a .gcloudignore file the implicit exclude of .gitignored files is removed. This allows workflows of adding locally built assets to a Dockerfile. Still better to have the end-to-end pipeline managed within the Dockerfile for clarity and portability. cloud.google.com/sdk/gcloud/reference/topic/gcloudignore
    – Grayside
    Apr 29, 2019 at 18:03
  • @Grayside I will try that but not sure if that matches what i am looking for. I have opted for the option 2 suggested by dustin below in the answer. As thats the best option i feel, unless you are building the images with a CI platform and you want to auto mate a huge build process with rapid development distributed between multiple team members. May 4, 2019 at 0:49
1

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

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.