How to deploy through AWS codeploy using composer when a dependency is in a private repository
So I’m new to AWS Codedeploy, I have it successfully deploying with one little issue, every time I add to my deploy script composer update I get this lovely little message “Permission denied (publickey)”.
Now when I run composer update as ubuntu user it runs fine, my key is setup in the private repository fine, I have made sure that the bash file is run as ubuntu.
So how do other people setup their code deployments to work with private composer repositories? Sorry if there is something obvious but I am very baffled.
If someone can answer you would make one developer very happy.
2 Solutions collect form web for “How to deploy through AWS codeploy using composer when a dependency is in a private repository”
Use a Deployment Key on the root user.
The way I had it set up for my application that has multiple private composer packages is to create an artifact of my application then deploy that via CodeDeploy.
A summary of what I do
- On my CI machine (Jenkins or my local), run composer. This machine will already have the appropriate access to the repos.
- Tar Ball/Zip up my application together with the corresponding vendor folder created by composer – this is my deploy artifact
- Save that artifact to S3
- Have CodeDeploy begin a deploy with that artifact in S3 as my source
This method is more scalable especially when you are deploying to >1 server
- avoids adding private keys on your server(s)
- avoids your servers from running composer individually