Plugins Docker build error

Hello

I juste add a CI to an existing gitea project.
I have a error: “COPY failed: stat” the runner failed to copy files from my repository.
To debug i put the command “ls -lah” before my COPY instruction in my Dockerfile, the result is / of docker container, i think is not normal ?

The woking dir should not be my repository ?

Thanks

The error on Drone interface:

Step 5/12 : COPY ./dist/ /data/XXX-website/
121 COPY failed: stat /var/lib/docker/tmp/docker-builder369267275/dist: no such file or directory
122 time="2020-05-09T18:15:35Z" level=fatal msg="exit status 1"

Here my Dockerfile:

FROM nginx:alpine

EXPOSE 80

RUN ls -lah

COPY ./dist/ /data/XXX-website/
COPY ./robots.txt /data/XXX-website/
COPY ./nginx.conf /etc/nginx/nginx.conf

CMD ["nginx", "-g", "daemon off;"]

My .drone.yml:

kind: pipeline
type: docker
name: build-docker

steps:
  - name: publish
    image: plugins/docker
    settings:
      auto_tag: true
      username: nologin
      password:
        from_secret: scw_registry_password
      repo: XX/XX/XX
      registry: XX
    when:
      branch:
        - master
      event:
          - tag
          - push

I have a error: “COPY failed: stat” the runner failed to copy files from my repository.

This error indicates the dist directory does not exist in the docker context or has been excluded by a dockerignore file. The best way to test is to add a step that lists all files cloned for your pipeline:

kind: pipeline
type: docker
name: build-docker

steps:
+ - name: ls
+   image: alpine
+   commands:
+     - la -la
  - name: publish
    image: plugins/docker
    settings: ...

For reference you can take a look at an existing project that uses the docker plugin:

or search for other examples on GitHub:

To debug i put the command “ls -lah” before my COPY instruction in my Dockerfile, the result is / of docker container, i think is not normal ?

Yes this is normal behavior. The ls -lah command runs inside the nginx:alpine image using its WORKDIR. If this image does not have a WORKDIR, the working directory is /.

1 Like

Okay thanks @bradrydzewski !I now understand what I was doing wrong.