├── .dockerignore ├── .editorconfig ├── .env ├── .github └── FUNDING.yml ├── Dockerfile ├── LICENSE └── README.md /.dockerignore: -------------------------------------------------------------------------------- 1 | .editorconfig 2 | README.md 3 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | -------------------------------------------------------------------------------- /.env: -------------------------------------------------------------------------------- 1 | # Application name 2 | APP_NAME='Packagist Mirror' 3 | 4 | # Language 5 | APP_COUNTRY_NAME='Brazil' 6 | APP_COUNTRY_CODE='br' 7 | 8 | # Folder used to save the files 9 | PUBLIC_DIR=/public 10 | 11 | # Maintainer information 12 | MAINTAINER_MIRROR='Webysther' 13 | MAINTAINER_PROFILE='https://github.com/Webysther' 14 | MAINTAINER_REPO='https://github.com/Webysther/packagist-mirror' 15 | MAINTAINER_LICENSE='MIT License' 16 | 17 | # Main mirror used to get providers 18 | MAIN_MIRROR=https://repo.packagist.org 19 | 20 | # Pattern to generate the package URIs. 21 | # I.E. packages.drupal.org uses: URI_PATTERN='%s$%s.json' 22 | URI_PATTERN='p/%s$%s.json' 23 | 24 | # Timezone 25 | TZ='America/Sao_Paulo' 26 | 27 | # Africa, South Africa packagist.co.za 28 | # Asia, China mirrors.aliyun.com/composer 29 | # Asia, China pkg.phpcomposer.com (https://packagist.phpcomposer.com) 30 | # Asia, Indonesia packagist.phpindonesia.id 31 | # Asia, India packagist.in 32 | # Asia, Japan packagist.jp (what this code is based of) 33 | # South America, Brazil packagist.com.br (our mirror) 34 | DATA_MIRROR=https://packagist.co.za,https://mirrors.aliyun.com/composer,https://packagist.phpcomposer.com,https://packagist.phpindonesia.id,https://packagist.in,https://packagist.jp,https://packagist.com.br 35 | 36 | # URI of your mirror 37 | URL=packagist.com.br 38 | 39 | # Since your mirror exists 40 | SINCE="Q3'17" 41 | 42 | # Max connections by mirror 43 | MAX_CONNECTIONS=25 44 | 45 | # Google Analytics 46 | GOOGLE_ANALYTICS_ID= 47 | 48 | # Google Analytics, keep this value to have in future stats about packagist-mirror worldwide coverage. 49 | GOOGLE_ANALYTICS_MAIN_ID='UA-58875124-2' 50 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: packagist_mirror 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM webysther/composer-debian 2 | MAINTAINER Webysther Nunes 3 | 4 | WORKDIR /packagist 5 | 6 | RUN git clone --depth 1 https://github.com/Webysther/packagist-mirror.git . 7 | RUN composer install --no-progress --no-ansi --no-dev --optimize-autoloader 8 | COPY .env .env 9 | 10 | VOLUME /public 11 | 12 | ENV SLEEP 0 13 | 14 | ENV TZ=America/Sao_Paulo 15 | RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone 16 | 17 | # with while access to files keep to memory cache 18 | CMD while sleep $SLEEP; do php bin/mirror create --no-progress; done 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017 Webysther Nunes 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DEPRECATED 2 | 3 | The project has been frozen since the announcement of [composer 2](https://blog.packagist.com/composer-2-0-is-now-available/), which solved several problems, but still did not cover all users, especially in China. A few weeks ago, it adopted a [global CDN model](https://bunny.net/network/) and will [shutdown all legacy version 1](https://blog.packagist.com/shutting-down-packagist-org-support-for-composer-1-x/), which makes this mirror unnecessary. This includes Brazil, China and other countries where performance was still not good enough. This is a good move and I recommend that all existing mirrors start shutting down their domains. I will open a PR to remove the Packagist mirror page. Thank you to the community and everyone who helped the project. 4 | 5 | [![Build Status](https://goo.gl/u9wbBD)](https://hub.docker.com/r/webysther/packagist-mirror/) 6 | [![Docker pulls](https://goo.gl/Jb5Cq4)](https://hub.docker.com/r/webysther/packagist-mirror/) 7 | [![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%207.2-8892BF.svg?style=flat-square&maxAge=3600)](https://php.net/) 8 | [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FWebysther%2Fpackagist-mirror-docker.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2FWebysther%2Fpackagist-mirror-docker?ref=badge_shield) 9 | [![Software License](https://goo.gl/FU2Kw1)](LICENSE) 10 | [![Mentioned in Awesome composer](https://awesome.re/mentioned-badge.svg)](https://github.com/jakoch/awesome-composer#packagist-mirrors) 11 | 12 | # Docker for [Packagist Mirror](https://github.com/Webysther/packagist-mirror) 13 | 14 | This project allows you to easily create and update a [mirror of the packagist](https://github.com/Webysther/packagist-mirror) having as dependency only the docker. 15 | It is possible to completely [customize the mirror](https://github.com/Webysther/packagist-mirror/blob/master/.env.example) only by using environment variable and thereby create an institutional mirror or for a particular country without any problem. 16 | 17 | We use [webysther/composer-debian](https://hub.docker.com/r/webysther/composer-debian) as alternative to [official composer on docker hub](https://hub.docker.com/_/composer) because the alpine version has issues with I/O. 18 | 19 | ## Usage 20 | 21 | Schedule in case of restart or another problem, the first execution create a mirror: 22 | 23 | ```bash 24 | * * * * * root docker run --name mirror --rm -v /var/www/html:/public -e MAINTAINER_REPO='mymirror.com' webysther/packagist-mirror 25 | ``` 26 | 27 | Synchronized continuously: 28 | ```bash 29 | * * * * * 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 30 | 31 | ``` 32 | Sample used inside packagist.com.br (update docker composer every day): 33 | ```bash 34 | # Every minute 35 | * * * * * 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 36 | 37 | # Every 1:00 AM 38 | 0 1 * * * root docker pull webysther/packagist-mirror 39 | 40 | # Every 2:30 AM 41 | 30 2 * * * root service docker restart 42 | ``` 43 | 44 | You can add more mirrors with additional URL's separated by comma: 45 | 46 | ```bash 47 | -e DATA_MIRROR='https://packagist.jp,https://packagist.com.br' 48 | ``` 49 | 50 | Main mirror is used to get providers and fallback in case of error on data mirror, you can also change them: 51 | 52 | ```bash 53 | -e MAIN_MIRROR='https://packagist.com.br' 54 | ``` 55 | 56 | You also can change parallel connections for every mirror: 57 | 58 | ```bash 59 | -e MAX_CONNECTIONS=10 60 | ``` 61 | 62 | All enviroment options stay on `.env` file. 63 | 64 | 65 | ## License 66 | [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FWebysther%2Fpackagist-mirror-docker.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2FWebysther%2Fpackagist-mirror-docker?ref=badge_large) 67 | --------------------------------------------------------------------------------