Gitlab private repo as composer package

The solution I used for auth.json on deployed servers was to have Trellis generate it when deploying. Mostly this was to allow using Delicious Brains’ composer repo, but it could be easily extrapolated to basically anything.

# trellis/deploy-hooks/build-before.yml
---
- name: Create composer auth.json
  template:
    src: "{{ playbook_dir }}/deploy-hooks/auth.json.j2"
    dest: "{{ deploy_helper.new_release_path }}/auth.json"
    mode: "0600"
# trellis/group_vars/all/vault.yml
vault_wordpress_env_defaults:
   vault_deliciousbrains_user: 'a username'
   vault_deliciousbrains_pass: 'a password'
# trellis/deploy-hooks/auth.json.j2
{
  "http-basic": {
    "composer.deliciousbrains.com": {
      "username": "{{ vault_deliciousbrains_user }}",
      "password": "{{ vault_deliciousbrains_pass }}"
    }
  }
}
4 Likes