01/06/2019 - DOCKER, PHP
If you are getting message below while trying to install private repositories with composer and want to avoid manual interaction, you can use this example.
Cloning failed using an ssh key for authentication, enter your GitHub credentials to access private repos
Head to https://github.com/settings/tokens/new?scopes=repo&description=Composer+on+clone-php+2019-05-31+2137
to retrieve a token. It will be stored in "/root/.composer/auth.json" for future use by Composer.
Token (hidden):
You can omit "Token" and "Environment" steps below if you have previously completed both steps for any other projects.
Assume that this is your composer.json file.
{
"repositories": [
{
"type": "git",
"url": "git@github.com:myprivate/repo.git",
"no-api": true #This is not compulsory
}
]
}
Run command below on local PC.
export COMPOSER_AUTH='{"github-oauth":{"github.com":"AB8cd4cab23a9d5399934a7d7698d3fa74e9cfAB"}}'
Add entry below to docker-compose.yaml file as an environmental variable.
COMPOSER_AUTH: "${COMPOSER_AUTH}"
If you run composer instal/update/require commands, you should not be asked to enter token.