0

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 
5
  • $CI_PROJECT_DIR is an environment variable? Are you passing the value for it using --build-args in the docker build command? Commented Apr 4, 2020 at 4:50
  • It's an environment variable. Docker is evaluating it to /var/lib/docker/tmp/docker-builder597514812 as you can see from the output above Commented Apr 4, 2020 at 17:23
  • Only if you're creating the Dockerfile from the pipeline and building, the value will be replaced. If you're checking out your code and then building then you need to.pass those variable as a build argument. Commented Apr 5, 2020 at 2:56
  • Please see my edit Commented Apr 6, 2020 at 17:08
  • Can't you have a script directive like --> build_image: script: - cd /path/to-docker-and-copy-files/ - docker build -t my-docker-image . - docker run my-docker-image /script/to/run/tests Given your last EDIT, it says no such file, means you're trying to build an image that doesn't have the required contents to be copied from the present working directory. Commented Apr 7, 2020 at 15:52

1 Answer 1

0

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

Sign up to request clarification or add additional context in comments.

1 Comment

This should be in ${CI_PROJECT_DIR} as of now

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.