Private Composer Repo with GitLab and Satis

You can easily create your own composer repository using Satis and GitLab. I will use global but it should be most useful for private corporate GitLab installations. You will need CI and Pages

Our repo should contain only 2 files: satis.json and .gitlab-ci.yml


satis.json should describe the repo you want. It is very close by structure to composer.json. Refer to Satis documentation for advanced use cases, I will go with the simplest one: add some packages from GitLab and require all of them

php/satis-gitlab/satis.json (Source)

    "name": "My Satis Repo",
    "homepage": "",
    "repositories": [{
        "type": "vcs",
        "url": ""
    }, {
        "type": "vcs",
        "url": ""
    "require-all": true


Now the tricky part that took me quite some time to debug, but you probably can just copy-paste my solution. You need to set a private variable COMPOSER_AUTH which should contain the content of your auth.json like GitHub OAuth Token or access data for your private GitLab instance. (Set it to {} if you need none of it)

php/satis-gitlab/gitlab-ci.yml (Source)

# Docker image
image: docker:latest

# So we can use Docker inside build script
- docker:dind

# Task for GitHub Pages
  stage: deploy
  # cache composer data (especially useful if you set up Satis to download packages)
    - composer
  - if [ ! -d composer ]; then mkdir composer; fi
  # run satis from docker image
  - docker run --rm -i -v `pwd`:/build -v `pwd`/composer:/composer -e COMPOSER_AUTH="$COMPOSER_AUTH" composer/satis
  # gitlab requires directory to be named public for whatever reason
  - mv output public
  # artifacts for Pages
    - public
    # I don't like any garbage stored in the ci
    expire_in: 1w
  # do this only on master branch
  -  master


You can find my example repo project at and generated Satis repo at


Comments powered by Disqus