Closed JTensai closed 3 years ago
Hi @jtensai
Thanks for your question. I understand that this is an issue and it becomes even more prominent in a Heroku like 12-factor environment.
On a normal old school server or VPS, suggested approach would be to simply create a file manually on the server and go about your day, but on Heroku or even Docker containers it becomes challenging because there is no way to SSH or SCP any files after the fact (on Docker there is, but obviously we don’t want to SSH everytime a new container is deployed)
So, the suggested approach is to encrypt your Keyfile and check it in source code. Just like how secrets.yml.enc is encrypted and the key to unlock is a simple RAILS_MASTER_KEY
environment variable.
This question was asked earlier here:
https://github.com/metaware/carrierwave-google-storage/issues/20
Please take a look and let me know if you have any further questions? In the meantime, I’ll review the code again and see if the whole file can be simply dropped in as an environment variable - If not, i’ll see if we can include/build this functionality in the new release.
@jasdeepsingh Hey mate! Fog guys already implemented that. Please update your GC connection: https://github.com/metaware/carrierwave-google-storage/blob/master/lib/carrierwave/storage/gcloud.rb#L44
REF: https://github.com/fog/fog-google/blob/master/test/integration/test_authentication.rb
Google SDK accept String, Hash, Google::Auth::Credentials as param.
So just use:
config.gcloud_credentials = {
gcloud_project: ENV['PROJECT_NAME'],
gcloud_keyfile: JSON.parse(ENV['KEYFILE_CONTENTS'])
}
Closing this issue, since a response above was provided.
My rails app is hosted on Heroku. I do not believe I can have a file on heroku that exists outside the repository and I would very much like to not include my keyfile.json in my commit history. I do this everywhere else by using environment variables: ENV['KEYFILE_CONTENTS']
That way I can have a dev version and a production version and leave them out of commit history.
Is there anyway to do something like this:
Thanks!