Docker cache wrongly invalidated
docker-compose build installs a lot of dependencies and build things way too often. This is mainly due to the following line in several
COPY . /pkm-api
Due to this line, each time a file change anywhere in the root folder (even files not from the repository like test logs), then the
COPY line and all those below are invalidated.
Only what is strictly necessary should be copied and dependencies should be installed as soon as possible to avoid repeated installations and compilations.
Here are some pointers documenting this problem:
Steps to reproduce
$ git clone firstname.lastname@example.org:decoder/pkm-api.git $ docker-compose build # [… everything builds …] $ docker-compose build # [… everything is retrieved from cache …] $ echo "build now" >> touch.txt $ docker-compose build # [… a lot of things build again while they should not …]