GoogleCloudPlatform/cloud-build-local

Ignored files are copied to cloudbuild volume (resulting in out of space errors)

ilons opened this issue ยท 8 comments

ilons commented

Background:
When I run cloud-build-local I get issues with my disk filling up, making the build to fail, even though I should have sufficient space to perform the build.

Issue:
What happens is that cloud-build-local does not properly (?) ignore the contents of .gcloudignore (or .dockerignore), and copy files and directories in the workdir into its build volume, when they should have been ignored.

Steps to replicate:
Dockerfile:

FROM busybox

RUN sleep 1000

.gcloudignore + .dockerignore:

ignored_dir/

cloudbuild.yaml:

steps:
- name: 'gcr.io/cloud-builders/docker'
  id: 'build'
  entrypoint: 'bash'
  args:
  - '-c'
  - |
    set -o errexit -o pipefail -o xtrace

    docker build \
      -t local/cloud-build-volume-issue \
      -f Dockerfile \
      .

ignored_dir/textfile: Arbitrary large file, in my test 5.8GB
Run cloud-build-local --config=cloudbuild.yaml --dryrun=false .:

2018/10/29 14:50:31 Warning: The server docker version installed (18.06.1-ce) is different from the one used in GCB (17.12.0-ce)
2018/10/29 14:50:31 Warning: The client docker version installed (18.06.1-ce) is different from the one used in GCB (17.12.0-ce)
Using default tag: latest
latest: Pulling from cloud-builders/metadata
Digest: sha256:08d3404781d9d1114880485fcfe63687999d0817881de67a697128b8f79a4382
Status: Image is up to date for gcr.io/cloud-builders/metadata:latest
2018/10/29 14:50:44 Started spoofed metadata server
2018/10/29 14:50:44 Build id = localbuild_f613a933-fc86-4f08-b5e9-9c37cddcaed0
2018/10/29 14:50:45 status changed to "BUILD"
BUILD
: Already have image (with digest): gcr.io/cloud-builders/docker
: + docker build -t local/cloud-build-volume-issue -f Dockerfile .
: Sending build context to Docker daemon   5.12kB
: Step 1/2 : FROM busybox
:  ---> 59788edf1f3e
: Step 2/2 : RUN sleep 100
:  ---> Running in 4f0840cec186
: Removing intermediate container 4f0840cec186
:  ---> 19a17d9fc9fb
: Successfully built 19a17d9fc9fb
: Successfully tagged local/cloud-build-volume-issue:latest
2018/10/29 14:52:26 status changed to "DONE"
DONE

While the build is on the sleep step, I run du -h -d1 /var/lib/docker/volumes/, which shows:

5.8G    /var/lib/docker/volumes/cloudbuild_vol_f613a933-fc86-4f08-b5e9-9c37cddcaed0

And the contents of it du -h -d1 /var/lib/docker/volumes/cloudbuild_vol_f613a933-fc86-4f08-b5e9-9c37cddcaed0/_data/ignored_dir/:

5.8G    /var/lib/docker/volumes/cloudbuild_vol_f613a933-fc86-4f08-b5e9-9c37cddcaed0/_data/ignored_dir/```

Expected behavior:
Files in the .gcloudignore should not be copied into the cloud-build-local workdir volume, in the same way they are not sent as contents when trigger a cloud build.

Versions:

Your current Cloud SDK version is: 211.0.0
Google Cloud Build Local Builder: 0.4.2 

Yes I'd expect it to respect .gcloudignore with a fallback to .dockerignore if it doesn't exist...

Right, we haven't implemented that in the local builder yet. Feel free to send a PR :-)

For large monolithic codebases, this is a dealbreaker because we don't have control over the docker build context which as I said is large. Is there anything planned to enable cloud-build-local to take a custom build context or just add functionality to support the gcloudignore?

+1

can anyone confirm if this has been fixed?

As of v0.5.2 it has not been fixed. I tripped over this last night.

any updates?

Close Issue as part of archive process; please see notice of archive status.