GoogleCloudPlatform/cloud-build-local

Mounting volumes appears to fail

P4rk opened this issue · 2 comments

P4rk commented

I have run into an issue using cloud build local. I have also run into the same issue using the hosted cloud build, but this is far less frequent. I am only able to consistently reproduce the issue using cloud build local.

I am unable to mount a volume for postgres to run init scripts.

I have a repository with steps to replicate here.

This will allow you to replicate the same issue locally:

  • Run cloudbuild local which will fail
  • Run build on gcp which will most likely pass
  • Run the docker containers locally which will pass, proving this isn't an issue with the containers.

This seems to be coming up a lot lately =)

Technically we don't support mounting /workspace in a sub docker container, although the docs are not super clear about that.

The transient failures on GCP were because we were partially rolled out with some changes that accidentally broke this behavior; we rolled that back.

You can refer to this issue for more information on how to fix this issue:
GoogleCloudPlatform/cloud-builders#372

I confirmed this fixes your test case on cloud-build-local:

steps:
  - name: 'ubuntu'
    entrypoint: 'bash'
    volumes:
    - name: 'vol1'
      path: '/docker-entrypoint-initdb.d'
    args:
    - '-c'
    - |
          chmod 0600 /workspace/pass-file/.pgpass
          cp /workspace/postgres-init/* /docker-entrypoint-initdb.d
  - id: 'Postgres'
    name: gcr.io/cloud-builders/docker
    volumes:
    - name: 'vol1'
      path: '/docker-entrypoint-initdb.d'
    args:
      - run
      - -d
      - --name=test_db
      - --network=cloudbuild
      - -p
      - "5432:5432"
      - -v
      - vol1:/docker-entrypoint-initdb.d/
      - postgres

<snip>
P4rk commented

@sanastos thank you for your response and fix.