/satis-server

Satis Server to have your private packagist repository

Primary LanguagePHP

Layers Docker Pulls Build Status

Composer Satis Server

Docker Hub: https://hub.docker.com/r/edyan/satis-server

Satis with a micro-api on top of it to interact and have a simple packagist private repository.

Start Docker Image

# Mount /build directory to save locally the output of satis, including the 
# packages if they are uploaded
docker run \
    -p 8080:8080 \
    -v $(pwd)/volumes/build/:/build \
    --name satis-server \ 
    edyan/satis-server:latest

satis.json

Satis works with a satis.json file that can be generated with the /init endpoint (see below).

You can also edit it manually. For example to have a local repository with local artifacts :

{
    "name": "edyan/satis",
    "homepage": "https://my.satis.repo",
    "repositories": [
        {
            "type": "artifact",
            "url": "packages"
        }
    ],
    "archive": {
        "directory": "packages",
        "format": "zip",
        "prefix-url": "https://my.satis.repo"
    },
    "require-all": true
}

Don't forget to set the artifact dir in ARTIFACTS_DIR env variable (it must be in /build directory).

Auth with github

To be able to download packages from github, you have to set a token in /composer/auth.json. If you need it, mount the file and set the value of your token such as below :

{
    "github-oauth": {
        "github.com": "xxxxxxxxxxxxxxx"
    }
}

Workflow

Init

First of all you need to init your satis repo with POST /init:

curl -XPOST -d "name=edyan/satis&homepage=https://my.satis.repo&force=true" http://localhost:8080/init

Add a repository

The method is POST /{package/name}

curl -XPOST -d "url=https://github.com/edyan/neuralyzer" http://localhost:8080/edyan/neuralyzer

You can also upload a file if you use artifacts :

curl -XPOST -F "package=@filename.zip" http://localhost:8080/edyan/package-name

Each package needs a version in it, it's mandatory. To add one, you can use jq :

cat <<< $(cat composer.json | jq -M '. + { "version": "1.2" }') > composer.json

Build your repository

To build your repo use the GET /build method.

curl http://localhost:8080/build

There is also a GET /build/{package/name} to refresh a single package. That doesn't work with artifacts.

You can also do a GET /build?url=https://github.com..... when you use the github, gitlab or bitbucket driver.

Delete a package

Finally you can also delete a package with DELETE /{package/name}

curl -XDELETE http://localhost:8080/edyan/neuralyzer

Access Satis

Satis provides 2 endpoints :

Develop

Start Server

docker-compose up --build --remove-orphans --force-recreate

Test satis

docker-compose exec php bash
# Download composer
php -r "copy('https://getcomposer.org/download/1.10.5/composer.phar', '/usr/local/bin/composer');"
chmod +x /usr/local/bin/composer
# Create an App
mkdir /app && cd /app
composer init -n
composer config repositories.satis composer http://satis:8080
composer config secure-http false
# Set your credentials if required
composer config --global gitlab-domains gitlab.mydomain.com
composer config --global gitlab-token."gitlab.mydomain.com" AbcDef_98939
# Search your package
composer search mycompany
# Install
composer require mycompany/package