Dean Hiller
Dean Hiller

Reputation: 20182

Is this a google cloud build bug? or am I doing Docker wrong?

First question is 'does anyone know what i am doing wrong below?'. Second question is 'If no, is there a way to list files in some kind of command that I put in the Dockerfile hoping to debug more, and perhaps do a pwd in the Dockerfile too(trying to see what is different in each environment'

Step 1. git checkout master, git pull

Step 2. Run "gcloud builds submit --config cloudbuild.yaml"

Step 3. Have a google build trigger setup using the 'same exact' cloudbuild.yaml from the repo

Step 4. "gcloud alpha builds triggers run default-push-trigger-1 --branch master"

Step 2 succeeds and properly runs the entry point of Docker image. Step 4. fails with

/bin/sh: ./downloadAndExtract.sh: not found
ERROR
ERROR: build step 0 "gcr.io/orderly-gcp/continuous-deploy" failed: step exited with non-zero status: 127

My Dockerfile is very simple

FROM gcr.io/google.com/cloudsdktool/cloud-sdk:alpine

RUN mkdir -p ./monobuild
COPY . ./monobuild/
WORKDIR "/monobuild"
ENTRYPOINT ./downloadAndExtract.sh

My cloudbuild.yaml file is even more simple

steps:
- name: gcr.io/$PROJECT_ID/continuous-deploy

Are there any environment issues or something?

I run the docker build/push cycle in a directory with these files

OF COURSE, the ONLY two files needed in that directory are Dockerfile and downloadAndExtract.sh so I should probably change my docker file to just copy downloadAndExtract. Anyways, that's not the important piece. Why is google build triggers not working for me?

EDIT: I just had an epiphany. Put ls as the entrypoint. This proved that the async trigger is corrupting my build image with my mono repo contents and blowing away anything I had setup. Why is this? Why would they make the sync kick off a build different than a built trigger?

Upvotes: 1

Views: 2045

Answers (1)

guillaume blaquiere
guillaume blaquiere

Reputation: 75695

I think there is several mistakes in your Dockerfile

First, the path definition

COPY . ./monobuild/
WORKDIR "/monobuild"

You copy your file in the <currentPath>/monobuild (I mean ./monobuild), and you define your workdir as <rootPath>/monobuild.

Thus, the entrypoint use the ./downloadAndExtract.sh which is normally into <rootPath>/monobuild.

So, for sanitizing your Dockerfile, I propose this

RUN mkdir -p /monobuild
WORKDIR "/monobuild"
COPY . .
ENTRYPOINT /monobuild/downloadAndExtract.sh

Does it make sense in your context? Does it work?

Upvotes: 1

Related Questions