skip to Main Content

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?

enter image description here

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


  1. You can use the dir option to customize your step context.

    Login or Signup to reply.
  2. 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:

    args: [ 'build', '-t', 'gcr.io/$PROJECT_ID/monolito-arg-phpfpm', '-f', './infra/docker/php-fpm/Dockerfile', '.' ]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search