Merge pull request #455 from metamaps/feature/dotenv-for-reals

dotenv for reals
This commit is contained in:
Devin Howard 2016-01-07 12:10:47 +08:00
commit f4b2e34627
11 changed files with 77 additions and 69 deletions

View file

@ -1,14 +1,43 @@
RAILS_ENV=development export RAILS_ENV='development'
AWS_ACCESS_KEY_ID export DB_USERNAME='postgres'
AWS_SECRET_ACCESS_KEY export DB_PASSWORD='3112'
BUNDLE_GEMFILE export DB_HOST='localhost'
SMTP_DOMAIN export DB_PORT='5432'
SMTP_PASSWORD
SMTP_PORT export REALTIME_SERVER='http://localhost:5001'
SMTP_SERVER export MAILER_DEFAULT_URL='localhost:3000'
SMTP_USERNAME export DEVISE_MAILER_SENDER='team@metamaps.cc'
SSO_KEY export DEVISE_SECRET_KEY='f71c467e526f23d614b3b08866cad4788c502bed869c282f06e73ee6c94675b62fe1f6d52fa7ba8196b33031f0d2f3b67e27ea07693c52ecebccb01700cad614'
# you can safely leave these blank, unless you're deploying an instance, in which
# case you'll need to set them up
export AWS_ACCESS_KEY_ID
export AWS_SECRET_ACCESS_KEY
export SSO_KEY
export SMTP_DOMAIN
export SMTP_PASSWORD
export SMTP_PORT
export SMTP_SERVER
export SMTP_USERNAME
#ruby garbage collection stuff
export RUBY_GC_TUNE=0 #set to 1 to enable GC test
export RUBY_GC_TOKEN=4f4380fc9a2857d1f008005a3eb86928
export RUBY_GC_HEAP_INIT_SLOTS=186426
export RUBY_GC_HEAP_FREE_SLOTS=559278
export RUBY_GC_HEAP_GROWTH_FACTOR=1.03
export RUBY_GC_HEAP_GROWTH_MAX_SLOTS=74570
export RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR=1.4
export RUBY_GC_MALLOC_LIMIT=32883406
export RUBY_GC_MALLOC_LIMIT_MAX=69055153
export RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR=1.68
export RUBY_GC_OLDMALLOC_LIMIT=32509481
export RUBY_GC_OLDMALLOC_LIMIT_MAX=68269910
export RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR=1.4
## find the ENV currently in use in the app using : ## find the ENV currently in use in the app using :
## grep -rIso -P "(?<=ENV)(\.fetch\(|\[).[A-Z_]+.(\)|\])" ## grep -rIso -P "(?<=ENV)(\.fetch\(|\[).[A-Z_]+.(\)|\])"
@ -16,16 +45,3 @@ SSO_KEY
# for a uniq ordered list of env vars: # for a uniq ordered list of env vars:
## grep -rIsoh -P "(?<=ENV)(\.fetch\(|\[).[A-Z_]+.(\)|\])" | grep -oP "[A-Z_]+" | sort -u > temp ## grep -rIsoh -P "(?<=ENV)(\.fetch\(|\[).[A-Z_]+.(\)|\])" | grep -oP "[A-Z_]+" | sort -u > temp
RUBY_GC_TUNE=0 #set to 1 to enable GC test
RUBY_GC_TOKEN=4f4380fc9a2857d1f008005a3eb86928
RUBY_GC_HEAP_INIT_SLOTS=186426
RUBY_GC_HEAP_FREE_SLOTS=559278
RUBY_GC_HEAP_GROWTH_FACTOR=1.03
RUBY_GC_HEAP_GROWTH_MAX_SLOTS=74570
RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR=1.4
RUBY_GC_MALLOC_LIMIT=32883406
RUBY_GC_MALLOC_LIMIT_MAX=69055153
RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR=1.68
RUBY_GC_OLDMALLOC_LIMIT=32509481
RUBY_GC_OLDMALLOC_LIMIT_MAX=68269910
RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR=1.4

7
.gitignore vendored
View file

@ -8,17 +8,12 @@
realtime/node_modules realtime/node_modules
public/assets public/assets
#secrets #secrets and config
config/database.yml
config/secrets.yml
.env .env
# Ignore bundler config # Ignore bundler config
.bundle .bundle
# Ignore the default SQLite database.
db/*.sqlite3
# Ignore all logfiles and tempfiles. # Ignore all logfiles and tempfiles.
log/*.log log/*.log
tmp tmp

View file

@ -1910,9 +1910,6 @@ Metamaps.Util = {
* *
*/ */
Metamaps.Realtime = { Metamaps.Realtime = {
stringForLocalhost: '//localhost:5001',
stringForMetamaps: 'https://realtime.metamaps.cc',
stringForHeroku: 'https://gentle-savannah-1303.herokuapp.com',
socket: null, socket: null,
isOpen: false, isOpen: false,
changing: false, changing: false,
@ -1936,9 +1933,8 @@ Metamaps.Realtime = {
}); });
$('body').click(self.close); $('body').click(self.close);
var railsEnv = $('body').data('env'); var realtimeServerUrl = '<%= ENV['REALTIME_SERVER'] %>'
var whichToConnect = railsEnv === 'development' ? self.stringForLocalhost : self.stringForHeroku; self.socket = io.connect(realtimeServerUrl);
self.socket = io.connect(whichToConnect);
self.socket.on('connect', function () { self.socket.on('connect', function () {
self.startActiveMap(); self.startActiveMap();
}); });

View file

@ -66,7 +66,7 @@
<![endif]--> <![endif]-->
</head> </head>
<body data-env="<%= Rails.env %>" class="<%= authenticated? ? "authenticated" : "unauthenticated" %>"> <body class="<%= authenticated? ? "authenticated" : "unauthenticated" %>">
<% if devise_error_messages? %> <% if devise_error_messages? %>
<p id="toast"><%= devise_error_messages! %></p> <p id="toast"><%= devise_error_messages! %></p>

View file

@ -1,12 +1,12 @@
default: &default default: &default
min_messages: WARNING min_messages: WARNING
adapter: postgresql
host: 127.0.0.1
port: 5432
encoding: unicode encoding: unicode
pool: 5 pool: 5
username: postgres adapter: postgresql
password: "3112" host: <%= ENV['DB_HOST'] %>
port: <%= ENV['DB_PORT'] %>
username: <%= ENV['DB_USERNAME'] %>
password: <%= ENV['DB_PASSWORD'] %>
development: development:
<<: *default <<: *default

View file

@ -42,7 +42,7 @@ Metamaps::Application.configure do
authentication: 'plain', authentication: 'plain',
enable_starttls_auto: true, enable_starttls_auto: true,
openssl_verify_mode: 'none' } openssl_verify_mode: 'none' }
config.action_mailer.default_url_options = { :host => 'metamaps.herokuapp.com' } config.action_mailer.default_url_options = { :host => ENV['MAILER_DEFAULT_URL'] }
# Don't care if the mailer can't send # Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = true config.action_mailer.raise_delivery_errors = true

View file

@ -11,18 +11,13 @@ Devise.setup do |config|
# ==> Mailer Configuration # ==> Mailer Configuration
# Configure the e-mail address which will be shown in Devise::Mailer, # Configure the e-mail address which will be shown in Devise::Mailer,
# note that it will be overwritten if you use your own mailer class with default "from" parameter. # note that it will be overwritten if you use your own mailer class with default "from" parameter.
config.mailer_sender = "team@metamaps.cc" config.mailer_sender = ENV['DEVISE_MAILER_SENDER']
# Configure the class responsible to send e-mails. # Configure the class responsible to send e-mails.
# config.mailer = "Devise::Mailer" # config.mailer = "Devise::Mailer"
if Rails.env.development? # this is for Connors localhost config.secret_key = ENV['DEVISE_SECRET_KEY']
config.secret_key = 'f71c467e526f23d614b3b08866cad4788c502bed869c282f06e73ee6c94675b62fe1f6d52fa7ba8196b33031f0d2f3b67e27ea07693c52ecebccb01700cad614'
end
if Rails.env.production? # this is for the heroku staging environment
config.secret_key = 'd91ba0da95749174ee2b8922034783cbde4945409ed28b13383e18e72844beb74467f8199e9e216f0687cd2290c6e46bf74da24486d14bba3671d76c5b10c753'
end
# ==> ORM configuration # ==> ORM configuration
# Load and configure the ORM. Supports :active_record (default) and # Load and configure the ORM. Supports :active_record (default) and

View file

@ -11,7 +11,7 @@ vagrant ssh --command "cd /vagrant; gem install bundler";
vagrant ssh --command "cd /vagrant; bundle install"; vagrant ssh --command "cd /vagrant; bundle install";
# copy the db config # copy the db config
vagrant ssh --command "cd /vagrant; cp config/database.yml.default config/database.yml"; vagrant ssh --command "cd /vagrant; cp .example-env .env";
# Rake all the things # Rake all the things
vagrant ssh --command "cd /vagrant; rake db:create; rake db:schema:load; rake db:fixtures:load" vagrant ssh --command "cd /vagrant; rake db:create; rake db:schema:load; rake db:fixtures:load"

View file

@ -1,6 +1,10 @@
# OSX Install
If you are doing an upgrade and or recent pull for changes you will need to change your default ruby package from 2.1.1 to ruby 2.1.2 If you are doing an upgrade and or recent pull for changes you will need to change your default ruby package from 2.1.1 to ruby 2.1.2
install homebrew Some of these steps are pulled from http://www.moncefbelyamani.com/how-to-install-postgresql-on-a-mac-with-homebrew-and-lunchy/
Install homebrew
\curl -sSL https://get.rvm.io | bash -s stable --rails \curl -sSL https://get.rvm.io | bash -s stable --rails
@ -10,33 +14,33 @@ install homebrew
gem install lunchy gem install lunchy
(http://www.moncefbelyamani.com/how-to-install-postgresql-on-a-mac-with-homebrew-and-lunchy/) Now install homebrew.
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Then install nodejs
brew install nodejs
And postgresql:
brew install postgresql brew install postgresql
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
createuser metamaps -P -s -d createuser metamaps -P -s -d
set a password Set a password, then start the service:
lunchy start postgres lunchy start postgres
Change directory to the metamaps git repository, and run:
cd into the metamaps directory
bundle install bundle install
Copy the .example-env file and rename it to .env. Then modify the DB_USERNAME and DB_PASSWORD values to match the postgres username and password you set
copy the database.yml.default file and rename it database.yml
make sure the username and password match the POSTGRES username and password you set
http://nodejs.org/ hit install, download, open, install
rake db:create rake db:create
rake db:schema:load rake db:schema:load
rake db:fixtures:load rake db:fixtures:load
rails s rails server
( to start the server) Now open a browser to http://localhost:3000!

View file

@ -57,13 +57,15 @@ Install the specific version of ruby needed this will take some time
rvm install ruby-2.1.3 rvm install ruby-2.1.3
Now we also need to rename your database file which is in ./config/database.default.yml to database.yml Now we also need to copy .example-env to a new file named .env. Review the configuration in here to see if you need any changes.
now run inside your metamaps_gen002 folder cp .example-env .env
Now run inside your metamaps_gen002 folder
bundle install bundle install
in your top lvl directory for metamaps this is a lengthy process so you might want to go and make a coffee or something :) in your top level directory for metamaps this is a lengthy process so you might want to go and make a coffee or something :)
alright now we need to make sure your postgres password is the same as it is listed in the DB file so we are going to set it by alright now we need to make sure your postgres password is the same as it is listed in the DB file so we are going to set it by

View file

@ -20,7 +20,7 @@ At this point you should be in C:\git\metamaps_gen002, or whatever equivalent di
start config start config
This command will open a Windows Explorer window of the "config" directory of Metamaps. Copy database.yml.default, and rename the copy to database.yml. Edit the file and set the password to be whatever you set up with postgres earlier. Once you're done, then move back into the command prompt. The next few commands will fail unless database.yml is correctly configured and Postgres is running. This command will open a Windows Explorer window of the "config" directory of Metamaps. Copy `.example-env`, and rename the copy to `.env`. Edit the file and set the DB_PASSWORD to be whatever you set up with postgres earlier. Once you're done, then move back into the command prompt. The next few commands will fail unless `.env` is correctly configured and Postgres is running.
rake db:create rake db:create
rake db:schema:load rake db:schema:load