I thought I already understood Docker, but today I found a problem using the docker cache.
Here is my dockerfile
FROM quay.io/my_company/phpjenkins
WORKDIR /usr/src/my_project
ADD composer.json composer.json
ADD composer.lock composer.lock
RUN composer install -o
ADD . .
RUN mkdir -p temp/unittest/cache log
RUN cp app/config/config.unittest.template.neon app/config/config.unittest.neon
CMD ["tail", "-f", "/dev/null"]
I expect docker to use cache before ADD . .
However, every assembly similar to docker tries to do it composer installevery time.
Here are some weekends
+ docker-compose -f docker-compose.yml run app vendor/bin/phpunit -d memory_limit=2048M
Creating network "xxx_default" with the default driver
Creating xxx_rabbitmq_1
Creating xxx_mysql_1
Building app
Step 1/9 : FROM quay.io/my_company/phpjenkins
Step 2/9 : WORKDIR /usr/src/my_project
Step 3/9 : ADD composer.json composer.json
Step 4/9 : ADD composer.lock composer.lock
Step 5/9 : RUN composer install -o
Warning: This development build of composer is over 60 days old. It is recommended to update it by running "/usr/local/bin/composer self-update" to get the latest version.
Do not run Composer as root/super user! See https://getcomposer.org/root for details ....
...
Removing intermediate container 581aa7e4b00f
Step 6/9 : ADD . .
Removing intermediate container b7354231fbd7
My conclusion is ending, which may be possible if dockerfile did not use the cache for the command RUN composer install
I use Docker version 17.05.0-ce, build 89658bein Debian if this help is for investigation.
Please inform.
source
share