My Dockerfile includes a COPY command which copies a directory that was just created in the pipeline.
COPY ["$CI_PROJECT_DIR/ui-dist/", "/content/ui-dist/"]
That COPY command fails with the following error:
COPY failed: stat /var/lib/docker/tmp/docker-builder597514812/ui-dist: no such file or directory
However, I know the directory exists because right before I build the image, ls $CI_PROJECT_DIR/ui-dist
prints bundle.js
The runner is using the dind service. I'm not sure if that's relevant.
EDIT:
Okay, I tried removing the reference to the env variable. i.e. I changed the pipeline from
- docker cp ui:/content/dist $CI_PROJECT_DIR/ui-dist
- docker build --tag ${IMAGE_ID} api
to
- docker cp ui:/content/dist ui-dist
- docker build --tag ${IMAGE_ID} api
and I've updated the docker command to
COPY ["ui-dist/", "/content/ui-dist/"]
and I'm still getting this error message:
COPY failed: stat /var/lib/docker/tmp/docker-builder488922739/ui-dist: no such file or directory
I figured it out. I had to copy the asset into the api folder where the Dockerfile is located.
The docker builds take place in /builds/$CI_PROJECT_PATH/
.
So, the asset had to be copied into /builds/$CI_PROJECT_PATH/api