'Composer private repositry in docker
I have a local docker environment and ansible scripts to start/stop the environment and all devs using it for development. And now I need to add the private repository as a dependency of one of the projects, so I need a way to pass developers private ssh key to docker instance and to use it by the composer to install that project (otherwise it'll prompt user/password which is not very good in ansible). To copy ssh kee I made a task like this:
- name: Copy SSH private key to container
shell: docker cp {{pathToSshPrivateKey}} container:/home/www-data/.ssh/id_rsa
but how can I tell the composer to use that key?? I only found that to force using the key instead of user/password I need to run composer with -n but how to provide a path to that key?
Solution 1:[1]
I use something like the following to allow me to execute composer commands with SSH access from within a docker container:
docker run --rm \
--user $(id -u):$(id -g) \
-v $HOME/.ssh:/var/www/.ssh:ro \
-v $HOME/.composer:/.composer \
-v $(pwd):/var/www \
custom-image-name:tag composer install -n
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | George |
