Having spent a bit of time working to dockerize an API I wanted to share one of my learnings in case it’s helpful or interesting to others.
The first issue I ran into was how to authenticate requests to gems we host privately on Github. We do this quite a bit throughout our repos.
So I needed a way to grant access to our docker image in order for bundler to run properly. Because were trying to build for production deployment I first decided to remove HTTPS repository references (https://github.com/ldock/) and replace them with SSH URLs ([email protected]:ldock/). But this introduced the challenge of getting the private key on the container securely. I needed the ability to get an authorized SSH key on the image when dependencies were being installed (bundle install) but I did not want to leave the key on the file system after the dependencies were installed.