Skip to content

How to include a private Gitlab repository into composerΒΆ

  1. Setup the repository as a dependency in composer.json:
    "repositories": [
        {
    ...
        },
        {
          "type": "gitlab",
          "url": "https://gitlab.fftrader.cz/some/project.git"
        }
      ],
    
  2. Create a project access token. Needs at least reporter level. DO NOT USE guest
  3. Add the token to Gitlab CI/CD variables as eg. GITLAB_TOKEN
  4. Send the token as a build-arg to Podman / Docker:
    podman build .. --no-cache --pull --build-arg GITLAB_TOKEN=$GITLAB_TOKEN
    
  5. In the Dockerfile do this:
    ARG GITLAB_TOKEN
    RUN composer config gitlab-domains gitlab.fftrader.cz && \
        composer config gitlab-token.gitlab.fftrader.cz $GITLAB_TOKEN && \
    
  6. ...
  7. Profit