Hi, I have a
.drone.yml looking something like this:
- ls -la /drone
- cp /drone/scala-scala .
felixmulder/dotty:0.1 has the following
# Add git to image
RUN apk add --update git
# Clone the modified standard library for testing, then copy it via the .drone.yml file
RUN git clone -b dotty-library https://github.com/DarkDimius/scala.git scala-scala
# Add ivy2 cache
COPY ivy2/ ivy2
When running and attaching to the dotty image on my machine I can see the directories
/drone. But the commands in the
.drone.yml file fail because there is nothing (except
/drone when the CI is running.
I’m sure I’m missing something obvious as I’m fairly new to both docker and drone.
The problem is that
/drone is a reserved path, by default, for every build. It is the path at which your build workspace (where your code is cloned) is mounted as a volume.
Let’s say we have the following Yaml file:
- go build
- go test
The build container is started with a shared volume mounted at
/drone. You can think of it like drone running the following docker commands:
docker volume add drone-volume-for-build
docker run --volume=drone-volume-for-buid:/drone golang:latest
The volume mounted at
/drone is therefore mounted on top of the
/drone directory you created in your dockerfile, which is why it isn’t visible during the build. This can be resolved by using a different cache path in your Dockerfile:
-COPY ivy2/ ivy2
+COPY ivy2/ ivy2
OR this can be resolved by changing the default Drone workspace path for your build. The below example overrides the default workspace to use
/code instead of
/drone as the base volume.
+ base: /code
- go build
- go test
You can read more about the workspace in the 0.5 documentation at http://readme.drone.io/0.5
Thanks! Now everything works
I’m sorry, but I do not understand something here. Are you sharing the file/folder between the docker pipelines ? Is that what you’re achieving ?
the volume is shared between all steps in the same pipeline (it is not shared across pipelines). For a more detailed explanation see https://docs.drone.io/pipeline/docker/syntax/workspace/.