centralize config in .env file, which includes remaving database.yml.default and overriding that file's local changes in favour of env variables. In future, all instance config can go in .env

This commit is contained in:
Devin Howard 2016-01-06 22:36:29 +08:00
parent 21aba2fe5e
commit 70f5a5db11
7 changed files with 67 additions and 54 deletions

View file

@ -1,14 +1,39 @@
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 export REALTIME_SERVER='https://realtime.metamaps.cc'
SMTP_PORT
SMTP_SERVER # you can safely leave the rest of these blank, unless you're
SMTP_USERNAME # deploying an instance, in which case you'll need to set them up
SSO_KEY
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 +41,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

@ -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

@ -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

@ -25,7 +25,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