Skip to content
This repository was archived by the owner on Jul 3, 2020. It is now read-only.

Commit b98b315

Browse files
rbclarkaaronlippold
authored andcommitted
Update mongoid.yml config to use URI instead of using separate host and database entries (#102)
This allows for easily setting up Heimdall on Heroku since the MONGODB_URI can be fully customized.
1 parent 1d6fdff commit b98b315

File tree

3 files changed

+6
-14
lines changed

3 files changed

+6
-14
lines changed

Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ RUN echo "gem: --no-rdoc --no-ri" >> ~/.gemrc
1717
RUN apk --no-cache --update add build-base \
1818
libc-dev libxml2-dev imagemagick6 imagemagick6-dev pkgconf nodejs
1919

20-
RUN bundle install --without development test -j4 --retry 3
20+
RUN gem install bundler && bundle install --without development test -j4 --retry 3
2121

2222
COPY . .
2323

@@ -41,7 +41,7 @@ WORKDIR $RAILS_ROOT
4141
COPY --from=Builder /usr/local/bundle/ /usr/local/bundle/
4242
COPY --from=Builder $RAILS_ROOT $RAILS_ROOT
4343

44-
RUN apk --no-cache --update add nodejs imagemagick6
44+
RUN apk --no-cache --update add nodejs imagemagick6 && gem install bundler
4545

4646
EXPOSE 3000
4747

config/mongoid.yml

+3-12
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ development:
55
default:
66
# Defines the name of the default database that Mongoid can connect to.
77
# (required).
8-
database: dashboard_development
9-
# Provides the hosts the default client can connect to. Must be an array
10-
# of host:port pairs. (required)
11-
hosts:
12-
- <%= ENV.fetch('MONGO_TCP_ADDR', '127.0.0.1') %>:<%= ENV.fetch('MONGO_TCP_PORT', '27017') %>
8+
uri: <%= ENV.fetch('MONGODB_URI', 'mongodb://127.0.0.1:27017/dashboard_development') %>
139
options:
1410
# Change the default write concern. (default = { w: 1 })
1511
# write:
@@ -148,9 +144,7 @@ development:
148144
test:
149145
clients:
150146
default:
151-
database: dashboard_test
152-
hosts:
153-
- <%= ENV.fetch('MONGO_TCP_ADDR', '127.0.0.1') %>:<%= ENV.fetch('MONGO_TCP_PORT', '27017') %>
147+
uri: <%= ENV.fetch('MONGODB_URI', 'mongodb://127.0.0.1:27017/dashboard_test') %>
154148
options:
155149
raise_not_found_error: false
156150
read:
@@ -166,10 +160,7 @@ production:
166160
# A session can have any number of hosts. Usually 1 for a single
167161
# server setup, and at least 3 for a replica set. Hosts must be
168162
# an array of host:port pairs. This session is single server.
169-
hosts:
170-
- <%= ENV.fetch('MONGO_TCP_ADDR', '127.0.0.1') %>:<%= ENV.fetch('MONGO_TCP_PORT', '27017') %>
171-
# Define the default database name.
172-
database: heimdall2_production
163+
uri: <%= ENV.fetch('MONGODB_URI', 'mongodb://127.0.0.1:27017/heimdall2_production') %>
173164
# Since this database points at a session connected to MongoHQ, we must
174165
# provide the authentication details.
175166
#username: user

docker-compose.yml

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ services:
1313
environment:
1414
MONGO_TCP_ADDR: db
1515
MONGO_TCP_PORT: 27017
16+
MONGODB_URI: mongodb://db:27017/heimdall2_production
1617
RAILS_SERVE_STATIC_FILES: "true"
1718
RAILS_ENV: production
1819
env_file: .env-prod

0 commit comments

Comments
 (0)