Let's say my repo is called X
.
I have these files
X/worker/Dockerfile
X/worker/hooks/build
Inside Dockerfile
, I have this command COPY worker/requirements.txt ./requirements.txt
Inside build
file, I have this command docker build -f $DOCKERFILE_PATH -t $IMAGE_NAME .
I use Docker Hub Automated Builds feature to build the image based on the build
file I have. I set Dockerfile location to worker/Dockerfile
and build context to /
.
There is an error saying that worker
directory is not found when building. I guessed that it's because the current directory on the cloud machine is not set to X
. So I tried to put pwd
into build
file to see the current directory.
The result is /src/bq2wmtsfppaqsxh3krqkqay/worker
. So my guess is right. It seems that docker rename my repo to a random string and cd
into worker
directory when building the image.
There are 2 potential solutions:
- I want it to not
cd
intoworker
directory because I set build context to.
in the build command which I want it to refer toX
notX/worker
. How can I achieve that? - Instead of setting build context to
.
, maybe there is a special environment variable that will tell me whereX
locates. In this case I want a string variable that stores/src/bq2wmtsfppaqsxh3krqkqay
, is there such a variable that I can use as build context in the build command?
Also is there an example of the exact build command used by docker to do Automated Builds? If I can see the exact build command they use, maybe I'll be able to modify it to suit my needs. I expect it to follow this format: docker build ...