Skip to content

Commit 8c619ad

Browse files
committed
Setup postgres database in project
1 parent 9047cbc commit 8c619ad

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ This project is a working example of building a rails app using Docker, and depl
1111
2. `docker-machine start kubernetes-rails`
1212
3. `eval "$(docker-machine env kubernetes-rails)"`
1313
4. `docker-compose build && docker-compose up -d`
14+
5. `docker-compose run --rm web rake db:create`
1415

1516
## Build images
1617
You will need to change **foxio-rnd** to your GCE project name.

web/Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ gem 'redis', '~> 3.0'
3333
# Use Unicorn as the app server
3434
gem 'unicorn'
3535
gem 'bower-rails'
36+
gem 'pg'
3637

3738
group :development, :test do
3839
# Call 'byebug' anywhere in the code to stop execution and get a debugger console

web/Gemfile.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ GEM
7777
nio4r (1.2.1)
7878
nokogiri (1.6.7.2)
7979
mini_portile2 (~> 2.0.0.rc2)
80+
pg (0.18.4)
8081
puma (3.0.2)
8182
rack (2.0.0.alpha)
8283
json
@@ -158,6 +159,7 @@ DEPENDENCIES
158159
coffee-rails (~> 4.1.0)
159160
jbuilder (~> 2.0)
160161
jquery-rails
162+
pg
161163
puma
162164
rails (>= 5.0.0.beta2, < 5.1)
163165
redis (~> 3.0)

web/config/database.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,18 @@
55
# gem 'sqlite3'
66
#
77
default: &default
8-
adapter: sqlite3
8+
adapter: postgresql
9+
encoding: unicode
10+
database: dev
911
pool: 5
10-
timeout: 5000
12+
username: postgres
13+
password: postgres
14+
host: <%= ENV['WEB_DATABASE_HOST'] %>
15+
port: 5432
1116

1217
development:
1318
<<: *default
14-
database: db/development.sqlite3
19+
database: dev
1520

1621
# Warning: The database defined as "test" will be erased and
1722
# re-generated from your development database when you run "rake".
@@ -22,4 +27,5 @@ test:
2227

2328
production:
2429
<<: *default
25-
database: db/production.sqlite3
30+
database: web_production
31+
password: <%= ENV['WEB_DATABASE_PASSWORD'] %>

0 commit comments

Comments
 (0)