I’m creating a dockerFile and trying to copy an environment configuration file that I’ve at the same path where dockerFile is found. The idea is to copy it during the docker build process to be able to use it during the gradle build a few steps later.
RUN
set -ex &&
cd /app/src &&
git clone URL.git dest_folder
COPY .env_dev /app/src/dest_folder
After that, to check if the file is already there I make a pwd to ensure I’m in the right folder and ls -la to see if the file is there, but it never is, I can only find files downloaded from the repository, but of course, the .env_dev with credentials is not uploaded to the repository.
RUN
cd /app/src/dest-folder &&
pwd &&
ls -la
I’m sure it may be something tricky I’m not using correctly but checked with both ADD/COPY with no results. I’ve even tried to use the wrong filename to see if COPY complains about it, and it does, so … it seems that COPY finds it.
2
Answers
Thanks everyone, finally I managed to see the problem. It's quite weird... I'm cloning my repository to dest-folder, but copying the file in dest_folder. That's why the file wasn't being detected, because it was in another folder.
If you have a
.dockerignore
file, make sure that you do not ignore hidden files like.git
or.venv
more info here :
https://docs.docker.com/engine/reference/builder/#dockerignore-file