Open nelsonic opened 5 years ago
I've just used this and realised that the DATABASE_URL
and HEROKU_POSTGRESQL
and are not needed on localhost
and attempting to connect to them will result in a permissions error ...
therefore a revised script to extract only the variables that are useful on localhost
is:
var keys = document.getElementsByClassName('config-var-key');
var vals = document.getElementsByClassName('config-var-value');
var vars = '';
for (var i = 0; i < keys.length - 1; i++) {
var key = keys[i].value
if (key && key !== 'DATABASE_URL' && key !== 'HEROKU_POSTGRESQL') {
var index = (i == 0) ? 0 : i * 2; // cause there are two values for every key ... 🙄
vars = vars + 'export ' + keys[i].value + '=' + vals[index].value + '\n';
}
}
console.log(vars);
Script to copy environment variables from one Heroku App to another:
#!/bin/bash
set -e
sourceApp="$1"
targetApp="$2"
while read key value; do
key=${key%%:}
echo "Setting $key=$value"
heroku config:set "$key=$value" --app "$targetApp"
done < <(heroku config --app "$sourceApp" | sed -e '1d')
via: http://blog.nonuby.com/blog/2012/07/05/copying-env-vars-from-one-heroku-app-to-another
Story
Getting an app running on
localhost
should be easy for new team members, (ideally it should be a single command ...) but sadly, currently it's not! 😞 @dwyl we have apps deployed to a variety of infrastructure, see: dwyl/learn-devops Most of the time we recommend that people start with Heroku because the convenience and much simpler interface far outweighs the cost (and switching away is relatively easy!)One of the most tedious steps in getting an app running on
localhost
is getting the Environment Variables. We don't want to share environment variables through insecure means (some people share secrets through Chat message, Google Docs or even email, but none of these means of communication are truly secure ... all store your data somewhere that is not in your direct control so it's possible for keys to leak ...)The Manual Way
First visit the "Settings" tab for your Heroku App. And click on the "Reveal Config Vars" button:![image](https://user-images.githubusercontent.com/194400/55563188-5e3ffb00-56ed-11e9-8202-2e831eee536a.png)
Then Run this script in your web browser's developer console:
You should see something like this:
Copy the output from the browser console and paste it into your
.env
file.Todo: Automate This!
localhost
for https://github.com/club-soda/club-soda-guide/issues/512 Start Here: https://devcenter.heroku.com/articles/heroku-cli