Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specify Dockerfile for gcloud build submit

I understand gcloud uses the Dockerfile specified in the root directory of the source (.) as in the command: gcloud builds submit --tag gcr.io/[PROJECT_ID]/quickstart-image .

but I am trying to specify the Dockerfile to use to build the image which I have not found any resource on how to do that, I don't know if that is possible.

like image 405
idrisadetunmbi Avatar asked Oct 10 '19 16:10

idrisadetunmbi


2 Answers

The only way to specify a Dockerfile (i.e. other than ./Dockerfile) would be to create a cloudbuild.yaml per techtabu@. This config could then use the docker builder and provide the specific Dockerfile, i.e.:

steps:
- name: "gcr.io/cloud-builders/docker"
  args:
  - build
  - "--tag=gcr.io/$PROJECT_ID/quickstart-image"
  - "--file=./path/to/YourDockerFile"
  - .
...
images:
- "gcr.io/$PROJECT_ID/quickstart-image"

If you wish, you also get to specify an alternative name than cloudbuild.yaml.

The ./Dockerfile assumption is presumably to ease the transition to Cloud Build.

I recommend you switch to using cloudbuild.yaml for the flexibility it provides.

like image 160
DazWilkin Avatar answered Oct 18 '22 06:10

DazWilkin


You can very easily do this by substituting the . by ./path/to/YourDockerFile, so the gcloud command will be:

gcloud builds submit --tag gcr.io/[PROJECT_ID]/quickstart-image ./path/to/YourDockerFile

So you don't have to use a cloudbuild.yaml for this.

like image 9
Coco Avatar answered Oct 18 '22 06:10

Coco