I have these two docker containers that I need to build, nginx
and php-fpm
However, both need to use the ROOT directory as context, and Google Cloud Build uses the nginx and php-fpm (the dirs where the Dockerfile is) as context.
How can I change that?
This is my cloudbuild.yaml file
steps:
- name: 'gcr.io/cloud-builders/docker'
args: [ 'build', '-t', 'gcr.io/$PROJECT_ID/monolito-arg-phpfpm', './infra/docker/php-fpm' ]
id: 'Build Docker PHP-FPM image'
- name: 'gcr.io/cloud-builders/docker'
args: [ 'build', '-t', 'gcr.io/$PROJECT_ID/monolito-arg-nginx', './infra/docker/nginx' ]
id: 'Build Docker nginx image'
images:
- 'us-central1-docker.pkg.dev/$PROJECT_ID/monolito-arg/monolito-arg-phpfpm'
- 'us-central1-docker.pkg.dev/$PROJECT_ID/monolito-arg/monolito-arg-nginx'
2
Answers
You can use the dir option to customize your step context.
Posting it as an answer to give it more visibility:
As stated in the comments:
To fix it you needed more parameters in the build: