bricev / compolab
Composer Repository for GitLab
Requires
- php: >=7.1.0, <7.2.0
- m4tthumphrey/php-gitlab-api: ^9.0
- php-http/guzzle6-adapter: ^1.0
- symfony/config: ^4.0
- symfony/console: ^4.0
- symfony/dependency-injection: ^4.0
- symfony/event-dispatcher: ^4.0
- symfony/http-kernel: ^4.0
- symfony/routing: ^4.0
- symfony/yaml: ^4.0
Requires (Dev)
- phpunit/phpunit: ^6
This package is auto-updated.
Last update: 2024-10-19 22:34:07 UTC
README
CompoLab is a PHP package repository server that makes all your GitLab compliant repositories available as Composer dependencies.
In order to be registered by CompoLab, your GitLab repository must contain a valid composer.json
file in the root
directory.
Security disclaimer
By default, CompoLab is not secured and will let anyone access your packages. In order to secure access to your packages, you must configure your web server any way you want. Eg. you may filter with an IP whitelist, or require the use of your own self-signed SSL certificate.
Requirements
A (preferably unix) server configured with:
- PHP 7.1 (A PHP component encounters an issue with PHP 7.2, making this code only compliant with 7.1)
- Git / Composer
- A web server (Nginx or Apache)
- A working instance of GitLab (with an admin user account)
Installation
-
From your GitLab instance, edit your own profile, then go to
Access Tokens
and create a token with the name of your choice (eg. CompoLab), no expiration date, and check onlyapi
andsudo
scopes. If you are not an admin with asudo
token, you may be restricted in term of the groups and projects you'll be able to cache in your CompoLab repository. -
Run the following composer command on the server you want to use as a Composer repository:
composer create-project bricev/compolab --no-dev --keep-vcs /var/www/compolab
(where the last command argument is the path where you want to install CompoLab). -
Execute the installation script by running the command:
php bin/install
(from CompoLab directory). Get ready to register your GitLab URL and token during this step. Settings will be persisted in theconfig/settings.yml
file (which is not versioned). You may use theconfig/settings.yml.example
template to create this manually if you prefer. -
The web server must be properly configured to receive GitLab webhooks and receive
GET /packages.json
requests. The main concern is to makepublic/packages.json
andpublic/archives
accessible from the root of your domain (eg. https://composer.my-website.com/packages.json). All other queries must be forwarded topublic/index.php
. A documented Nginx configuration example can be found here:config/templates/nginx.conf
. -
Use the
cli
application from your server and run the following commandphp bin/cli sync
: this will fully synchronize your GitLab server with your CompoLab repository. Once executed, all distribution archives will be stored in the CompoLab cache and thepackages.json
index will be up to date. -
From your GitLab instance, go to the
Admin Area
>System hooks
and configure a system hook with URLhttps://composer.my-website.com/gitlab
(wherecomposer.my-website.com
is the domain or IP you want to use with your CompoLab instance), no secret token as you are advised to insure security at the web server level, and check onlyPush events
,Tag push events
andEnable SSL verification
(if your web server is properly configured to accept SSL requests).
You're all set: your repository is complete and any future push/tag made to GitLab will be registred by CompoLab.
Usage
In order to let your local Composer installation know where to find your CompoLab repository, you need to add some configuration. You may configure your repository from your machine or directly from your package.
Local setting
You may execute the following command on your local computer/server to let Composer knows about the existance of CompoLab:
composer config -g repositories.compolab composer https://composer.my-website.com
This command should add a ~/.composer/config.json
(on Unix systems) file containing the following lines:
{ "repositories": { "compolab": { "type": "composer", "url": "https://composer.my-website.com" } } }
Package setting
OR you may set the repository address directly in your package's composer.json file:
{ "repositories": [ { "type": "composer", "url": "https://composer.my-website.com" } ] }