Packagist Mirror
Docker forThis project allows you to easily create and update a mirror of the packagist having as dependency only the docker. It is possible to completely customize the mirror only by using environment variable and thereby create an institutional mirror or for a particular country without any problem.
We use webysther/composer-debian as alternative to official composer on docker hub because the alpine version has issues with I/O.
Usage
Schedule in case of restart or another problem, the first execution create a mirror:
* * * * * root docker run --name mirror --rm -v /var/www/html:/public -e MAINTAINER_REPO='mymirror.com' webysther/packagist-mirror
Synchronized continuously:
* * * * * root docker run --name mirror --rm --device-read-bps /dev/xvda:600kb --device-write-bps /dev/xvda:600kb -e SLEEP=0 -v /var/www/html:/public webysther/packagist-mirror
Sample used inside packagist.com.br (update docker composer every day):
# Every minute
* * * * * root docker run --name mirror --rm --device-read-bps /dev/xvda:600kb --device-write-bps /dev/xvda:600kb -e SLEEP=0 -v /var/www/html:/public webysther/packagist-mirror
# Every 1:00 AM
0 1 * * * root docker pull webysther/packagist-mirror
# Every 2:30 AM
30 2 * * * root service docker restart
You can add more mirrors with additional URL's separated by comma:
-e DATA_MIRROR='https://packagist.jp,https://packagist.com.br'
Main mirror is used to get providers and fallback in case of error on data mirror, you can also change them:
-e MAIN_MIRROR='https://packagist.com.br'
You also can change parallel connections for every mirror:
-e MAX_CONNECTIONS=10
All enviroment options stay on .env
file.