Reputation: 5259
I am using multi-stage build but something is not working as expected. The images are custom ones and we are having our own artifactory - so don't worry about the links, they are working.
My simple Dockerfile
is :
#################### BUILD Stage ####################
FROM <url>/my-docker-image:latest AS build-image
COPY . /workarea
WORKDIR /workarea
## run the integration tests as well.
RUN INTEGRATION_TESTS=1 make docker
RUN pwd
RUN ls -l cmake-build/linux_64_static_make_Debug/src/
RUN ls -l cmake-build/linux_64_static_make_Debug/tests/
#################### RUN Stage ####################
FROM <url>/my-test-image:latest AS run-tests-image
WORKDIR /workarea
COPY --from=build-image /workarea/cmake-build/linux_64_static_make_Debug/src/mybinary.tsk /workarea/cmake-build/linux_64_static_make_Debug/src/
COPY --from=build-image /workarea/cmake-build/linux_64_static_make_Debug/tests/unit/mybinary.t.tsk /workarea/cmake-build/linux_64_static_make_Debug/tests/unit/
COPY --from=build-image /opt/bb/etc/entrypoint.d/99-mybinary.sh /opt/bb/etc/entrypoint.d/99-mybinary.sh
Expectation from first stage is to build the .tsk files, using the make docker
commands which is a wrapper on top of standard cmake commands.
I've added the RUN commands in between, to see if the .tsk files have been created.
#12 [build-image 5/7] RUN pwd
#12 sha256:4f0ad0e7daee557776d6c7dfa2faf48dead48ae75ff699a0898879f85255dd30
#12 0.534 /workarea
#12 DONE 0.7s
#13 [build-image 6/7] RUN ls -l cmake-build/linux_64_static_make_Debug/src/
#13 sha256:7989faeb2d337c955e167e5807eb6c6a980e98ab210bbb428b180fc2838686f0
#13 0.617 total 378068
.....
#13 0.617 -rwxr-xr-x 1 root root 290465864 Oct 15 12:04 mybinary.tsk
#13 DONE 0.7s
And the timestamp is the correct one. Nothing complaints when the COPY
gets run.
Then I run
docke-compose run my-test
and run the same ls -l
there is nothing in there. So, even though the COPY command was ran, I can't see the files.
My `docker-compose.yaml' is :
my-test:
build:
context: .
dockerfile: test.Dockerfile
volumes:
- .:/workarea
environment:
- INTEGRATION_TESTS=1
Any idea what I am missing? I think there is something going wrong with the volumes.
Upvotes: 1
Views: 534
Reputation: 31664
Any idea what I am missing? I think there is something going wrong with the volumes.
Exactly. If you delete that bind mount
, I mean - .:/workarea
, you will surely make it work.
The mybinary.tsk
already in the container's folder /workarea
, but you mount current working directory .
on host to workarea
of container. Then, the contents in host will override the contents in container.
Upvotes: 1