Dockerfile - Speed Up The Setting of Permissions
I am working on a few projects that have roughly 10,000 files, primarily because there is so much within the /vendor
directory that gets pulled down using composer.
This means that when I am setting the permissions as part of the docker build, it goes extremely slowly.
Luckily, there are some things you can do to speed things up.
- The
COPY
docker command supports--chown
which removes the need to do this as a separateRUN
step.
COPY --chown=root:www-data source /var/www/my-site
Compress your files into a single file. For PHP, you could possibly compress the vendor directory into a single PHAR file. I haven't tried this yet, but looks interesting. Javascript developers can use gulp to minify their files into one.
If you are using composer to pull down PHP packages, make sure to use the
--no-dev
option so you don't pull down files you don't need.
References
Last updated: 8th August 2020
First published: 8th January 2019
First published: 8th January 2019