Skip to content

Commit 8fafbdf

Browse files
committed
Add docker-compose for single (sqlite3) or with DB (postgresql), update some gem, get configuration from ENV
1 parent af9c050 commit 8fafbdf

File tree

7 files changed

+112
-72
lines changed

7 files changed

+112
-72
lines changed

Dockerfile

+1-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ EXPOSE 80
1313

1414
# Add Required Packages
1515
RUN apt-get update \
16-
&& apt-get install -y --no-install-recommends nodejs \
16+
&& apt-get install -y --no-install-recommends nodejs libpq-dev libxml2-dev default-libmysqlclient-dev libsqlite3-dev \
1717
&& rm -rf /var/lib/apt/lists/*
1818

1919
# Add docker entrypoint.sh
@@ -31,10 +31,6 @@ COPY . .
3131
# Configure database & install gems
3232
COPY config/database.yml.sample config/database.yml
3333

34-
# Create database for bundled sqlite
35-
RUN bundle exec rake db:create
36-
# Run database migrations for bundled sqlite
37-
RUN bundle exec rake db:migrate
3834
# Compile the assets
3935
RUN bundle exec rake assets:precompile
4036

Gemfile

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ gem 'kaminari'
1212
gem 'rest-client'
1313
gem 'libxml-ruby'
1414
gem 'sqlite3'
15+
gem 'pg', '~> 0.15'
16+
gem 'mysql2'
1517
gem 'puma'
1618

1719
group :development, :test do

Gemfile.lock

+55-51
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,27 @@ GEM
3838
addressable (2.5.2)
3939
public_suffix (>= 2.0.2, < 4.0)
4040
arel (6.0.4)
41-
binding_of_caller (0.7.3)
41+
binding_of_caller (0.8.0)
4242
debug_inspector (>= 0.0.1)
4343
builder (3.2.3)
44-
byebug (9.1.0)
44+
byebug (10.0.2)
4545
capybara (2.13.0)
4646
addressable
4747
mime-types (>= 1.16)
4848
nokogiri (>= 1.3.3)
4949
rack (>= 1.0.0)
5050
rack-test (>= 0.5.4)
5151
xpath (~> 2.0)
52-
capybara-screenshot (1.0.18)
53-
capybara (>= 1.0, < 3)
52+
capybara-screenshot (1.0.22)
53+
capybara (>= 1.0, < 4)
5454
launchy
5555
capybara-webkit (1.14.0)
5656
capybara (>= 2.3.0, < 2.14.0)
5757
json
58-
childprocess (0.8.0)
58+
childprocess (0.9.0)
5959
ffi (~> 1.0, >= 1.0.11)
60-
cocoon (1.2.11)
61-
concurrent-ruby (1.0.5)
60+
cocoon (1.2.12)
61+
concurrent-ruby (1.1.4)
6262
crass (1.0.4)
6363
cucumber (2.3.3)
6464
builder (>= 2.1.2)
@@ -77,21 +77,21 @@ GEM
7777
nokogiri (~> 1.5)
7878
railties (>= 3, < 5)
7979
cucumber-wire (0.0.1)
80-
database_cleaner (1.6.2)
80+
database_cleaner (1.7.0)
8181
debug_inspector (0.0.3)
8282
diff-lcs (1.3)
83-
domain_name (0.5.20170404)
83+
domain_name (0.5.20180417)
8484
unf (>= 0.0.5, < 1.0.0)
8585
erubis (2.7.0)
8686
execjs (2.7.0)
87-
factory_bot (4.8.2)
87+
factory_bot (4.11.1)
8888
activesupport (>= 3.0.0)
89-
factory_bot_rails (4.8.2)
90-
factory_bot (~> 4.8.2)
89+
factory_bot_rails (4.11.1)
90+
factory_bot (~> 4.11.1)
9191
railties (>= 3.0.0)
92-
ffi (1.9.25)
93-
font-awesome-rails (4.7.0.2)
94-
railties (>= 3.2, < 5.2)
92+
ffi (1.10.0)
93+
font-awesome-rails (4.7.0.4)
94+
railties (>= 3.2, < 6.0)
9595
foundation-rails (5.5.3.2)
9696
railties (>= 3.1.0)
9797
sass (>= 3.3.0, < 3.5)
@@ -102,7 +102,7 @@ GEM
102102
domain_name (~> 0.5)
103103
i18n (0.9.5)
104104
concurrent-ruby (~> 1.0)
105-
jquery-rails (4.3.1)
105+
jquery-rails (4.3.3)
106106
rails-dom-testing (>= 1, < 3)
107107
railties (>= 4.2.0)
108108
thor (>= 0.14, < 2.0)
@@ -121,26 +121,28 @@ GEM
121121
kaminari-core (1.1.1)
122122
launchy (2.4.3)
123123
addressable (~> 2.3)
124-
libxml-ruby (3.0.0)
125-
loofah (2.2.2)
124+
libxml-ruby (3.1.0)
125+
loofah (2.2.3)
126126
crass (~> 1.0.2)
127127
nokogiri (>= 1.5.9)
128-
mail (2.7.0)
128+
mail (2.7.1)
129129
mini_mime (>= 0.1.1)
130-
mime-types (3.1)
130+
mime-types (3.2.2)
131131
mime-types-data (~> 3.2015)
132-
mime-types-data (3.2016.0521)
132+
mime-types-data (3.2018.0812)
133133
mini_mime (1.0.1)
134-
mini_portile2 (2.3.0)
134+
mini_portile2 (2.4.0)
135135
minitest (5.11.3)
136-
multi_json (1.12.2)
136+
multi_json (1.13.1)
137137
multi_test (0.1.2)
138+
mysql2 (0.5.2)
138139
netrc (0.11.0)
139-
nokogiri (1.8.4)
140-
mini_portile2 (~> 2.3.0)
141-
public_suffix (3.0.0)
142-
puma (3.10.0)
143-
rack (1.6.10)
140+
nokogiri (1.10.0)
141+
mini_portile2 (~> 2.4.0)
142+
pg (0.21.0)
143+
public_suffix (3.0.3)
144+
puma (3.12.0)
145+
rack (1.6.11)
144146
rack-test (0.6.3)
145147
rack (>= 1.0)
146148
rails (4.2.10)
@@ -167,33 +169,33 @@ GEM
167169
activesupport (= 4.2.10)
168170
rake (>= 0.8.7)
169171
thor (>= 0.18.1, < 2.0)
170-
rake (12.3.1)
172+
rake (12.3.2)
171173
rest-client (2.0.2)
172174
http-cookie (>= 1.0.2, < 2.0)
173175
mime-types (>= 1.16, < 4.0)
174176
netrc (~> 0.8)
175-
rspec-core (3.7.0)
176-
rspec-support (~> 3.7.0)
177-
rspec-expectations (3.7.0)
177+
rspec-core (3.8.0)
178+
rspec-support (~> 3.8.0)
179+
rspec-expectations (3.8.2)
178180
diff-lcs (>= 1.2.0, < 2.0)
179-
rspec-support (~> 3.7.0)
181+
rspec-support (~> 3.8.0)
180182
rspec-matchers-controller_filters (1.0.0)
181183
rspec-rails (~> 3, >= 3.1)
182-
rspec-mocks (3.7.0)
184+
rspec-mocks (3.8.0)
183185
diff-lcs (>= 1.2.0, < 2.0)
184-
rspec-support (~> 3.7.0)
185-
rspec-rails (3.7.1)
186+
rspec-support (~> 3.8.0)
187+
rspec-rails (3.8.1)
186188
actionpack (>= 3.0)
187189
activesupport (>= 3.0)
188190
railties (>= 3.0)
189-
rspec-core (~> 3.7.0)
190-
rspec-expectations (~> 3.7.0)
191-
rspec-mocks (~> 3.7.0)
192-
rspec-support (~> 3.7.0)
193-
rspec-support (3.7.0)
191+
rspec-core (~> 3.8.0)
192+
rspec-expectations (~> 3.8.0)
193+
rspec-mocks (~> 3.8.0)
194+
rspec-support (~> 3.8.0)
195+
rspec-support (3.8.0)
194196
rubyzip (1.2.2)
195197
sass (3.4.25)
196-
sass-rails (5.0.6)
198+
sass-rails (5.0.7)
197199
railties (>= 4.0.0, < 6)
198200
sass (~> 3.1)
199201
sprockets (>= 2.8, < 4.0)
@@ -205,9 +207,9 @@ GEM
205207
websocket (~> 1.0)
206208
shoulda-matchers (3.1.2)
207209
activesupport (>= 4.0.0)
208-
simple_form (3.5.0)
209-
actionpack (> 4, < 5.2)
210-
activemodel (> 4, < 5.2)
210+
simple_form (4.0.0)
211+
actionpack (> 4)
212+
activemodel (> 4)
211213
spring (2.0.2)
212214
activesupport (>= 4.2)
213215
sprockets (3.7.2)
@@ -219,22 +221,22 @@ GEM
219221
sprockets (>= 3.0.0)
220222
sqlite3 (1.3.13)
221223
table_flipper (0.0.1)
222-
thor (0.20.0)
224+
thor (0.20.3)
223225
thread_safe (0.3.6)
224-
tilt (2.0.8)
226+
tilt (2.0.9)
225227
tzinfo (1.2.5)
226228
thread_safe (~> 0.1)
227-
uglifier (3.2.0)
229+
uglifier (4.1.20)
228230
execjs (>= 0.3.0, < 3)
229231
unf (0.1.4)
230232
unf_ext
231-
unf_ext (0.0.7.4)
233+
unf_ext (0.0.7.5)
232234
web-console (2.3.0)
233235
activemodel (>= 4.0)
234236
binding_of_caller (>= 0.7.2)
235237
railties (>= 4.0)
236238
sprockets-rails (>= 2.0, < 4.0)
237-
websocket (1.2.4)
239+
websocket (1.2.8)
238240
xpath (2.1.0)
239241
nokogiri (~> 1.3)
240242

@@ -256,6 +258,8 @@ DEPENDENCIES
256258
jquery-rails
257259
kaminari
258260
libxml-ruby
261+
mysql2
262+
pg (~> 0.15)
259263
puma
260264
rails (= 4.2.10)
261265
rest-client
@@ -272,4 +276,4 @@ DEPENDENCIES
272276
web-console (~> 2.0)
273277

274278
BUNDLED WITH
275-
1.16.4
279+
1.16.6

config/database.yml.sample

+13-16
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,25 @@
55
# gem 'sqlite3'
66
#
77
default: &default
8-
adapter: sqlite3
98
encoding: utf8
10-
pool: 5
9+
pool: 10
1110
timeout: 5000
1211

13-
development:
14-
<<: *default
15-
database: db/development.sqlite3
16-
17-
# Warning: The database defined as "test" will be erased and
18-
# re-generated from your development database when you run "rake".
19-
# Do not set this db to the same as development or production.
2012
test: &test
13+
<<: *default
2114
adapter: sqlite3
22-
encoding: utf8
23-
pool: 5
24-
timeout: 5000
2515
database: db/test.sqlite3
2616

27-
production:
17+
development:
2818
<<: *default
29-
database: db/production.sqlite3
19+
adapter: sqlite3
20+
database: db/development.sqlite3
3021

31-
cucumber:
32-
<<: *test
22+
production:
23+
<<: *default
24+
adapter: <%= ENV['DATABASE_ADAPTER'] || "sqlite3" %>
25+
database: <%= ENV['DATABASE_NAME'] || "db/sqlite/production.sqlite3" %>
26+
username: <%= ENV['DATABASE_USERNAME'] %>
27+
host: <%= ENV['DATABASE_HOSTNAME'] %>
28+
port: <%= ENV['DATABASE_PORT'] %>
29+
password: <%= ENV['DATABASE_PASSWORD'] %>

db/sqlite/.empty

Whitespace-only changes.

docker-compose-single.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: "3"
2+
3+
services:
4+
duckrails:
5+
build:
6+
context: .
7+
ports:
8+
- 8080:80
9+
environment:
10+
DATABASE_ADAPTER: sqlite3
11+
DATABASE_NAME: db/sqlite/production.sqlite3
12+
SECRET_KEY_BASE: "61867f2ea52bfcd0956063c8947abd745968b9830387aba3034c3bfd2c63d2e22519d0b14df362f85bacd3d36029139a2e5ccb0a08bd2bd88f7ef353556dd7fa"
13+
restart: on-failure
14+
volumes:
15+
- ./db/sqlite/:/opt/duckrails/db/sqlite/

docker-compose.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
version: "3"
2+
3+
services:
4+
duckrails:
5+
build:
6+
context: .
7+
ports:
8+
- 8080:80
9+
environment:
10+
DATABASE_ADAPTER: postgresql
11+
DATABASE_PORT: 5432
12+
DATABASE_NAME: duckrails
13+
DATABASE_HOSTNAME: postgres
14+
DATABASE_PASSWORD: p4ssw0rd
15+
DATABASE_USERNAME: postgres
16+
SECRET_KEY_BASE: "61867f2ea52bfcd0956063c8947abd745968b9830387aba3034c3bfd2c63d2e22519d0b14df362f85bacd3d36029139a2e5ccb0a08bd2bd88f7ef353556dd7fa"
17+
restart: on-failure
18+
depends_on:
19+
- postgres
20+
postgres:
21+
image: postgres:10
22+
environment:
23+
POSTGRES_DB: duckrails
24+
POSTGRES_PASSWORD: p4ssw0rd
25+
POSTGRES_USERNAME: postgres
26+

0 commit comments

Comments
 (0)