Skip to content

Commit

Permalink
change db host to localhost (#60)
Browse files Browse the repository at this point in the history
* change db host to localhost

* lint

* print env

* prod env

* lint
  • Loading branch information
LeozMaxwellJilliams authored Apr 2, 2020
1 parent fe461a1 commit 038038d
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ ENTRYPOINT ["entrypoint.sh"]
EXPOSE 3000

# Start the main process.
CMD ["rails", "server", "-b", "0.0.0.0"]
CMD ["rails", "server", "-b", "0.0.0.0", "-e", "production"]
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ gem 'activeadmin'
gem 'devise'
gem 'devise-jwt', '~> 0.5.9'
gem 'pg', '~> 1.1'
gem 'sassc', '< 2.2.0'
9 changes: 6 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ GEM
factory_bot_rails (5.1.1)
factory_bot (~> 5.1.0)
railties (>= 4.2.0)
ffi (1.11.1)
ffi (1.11.1-x64-mingw32)
ffi (1.12.2)
ffi (1.12.2-x64-mingw32)
formtastic (3.1.5)
actionpack (>= 3.2.13)
formtastic_i18n (0.6.0)
Expand Down Expand Up @@ -248,7 +248,9 @@ GEM
unicode-display_width (>= 1.4.0, < 1.7)
ruby-progressbar (1.10.1)
ruby_dep (1.5.0)
sassc (2.2.1-x64-mingw32)
sassc (2.1.0)
ffi (~> 1.9)
sassc (2.1.0-x64-mingw32)
ffi (~> 1.9)
sassc-rails (2.1.2)
railties (>= 4.0.0)
Expand Down Expand Up @@ -308,6 +310,7 @@ DEPENDENCIES
rails (~> 6.0.0)
rspec-rails (~> 3.5)
rubocop
sassc (< 2.2.0)
spring
spring-watcher-listen (~> 2.0.0)
tzinfo-data
Expand Down
6 changes: 5 additions & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

Dotenv::Railtie.load
unless Rails.env.production?
Dotenv::Railtie.load
end

module SdcApi
class Application < Rails::Application
Expand All @@ -38,6 +40,8 @@ class Application < Rails::Application
# Skip views, helpers and assets when generating a new resource.
config.api_only = true

puts Rails.env

# Middleware for ActiveAdmin
config.middleware.use Rack::MethodOverride
config.middleware.use ActionDispatch::Flash
Expand Down
3 changes: 1 addition & 2 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# frozen_string_literal: true

Rails.application.configure do

config.hosts << "warm-hollows-93227.herokuapp.com"
config.hosts << 'warm-hollows-93227.herokuapp.com'

# Settings specified here will take precedence over those in config/application.rb.

Expand Down
6 changes: 4 additions & 2 deletions config/initializers/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
# ENVIRONMENT VARIABLES

# DEVELOPMENT
unless Rails.env.production?
if Rails.env.production?
ENV['SECRET_KEY_BASE'] = 'production-key'
else
ENV['DB_PASS_DEV'] = 'sdcdev'
ENV['DB_USER_DEV'] = 'postgres'
ENV['DB_NAME_DEV'] = 'sdc'
ENV['DB_HOST_DEV'] = 'db'
ENV['DB_HOST_DEV'] = 'localhost'
ENV['DB_PORT_DEV'] = '5432'
ENV['DB_TIMEOUT_DEV'] = '5000'
ENV['DB_ADAPTER_DEV'] = 'postgresql'
Expand Down
3 changes: 3 additions & 0 deletions config/secrets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# config/secrets.yml
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ services:
- "5432:5432"
web:
build: .
command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0 -e production'"
volumes:
- .:/myapp
ports:
Expand Down

0 comments on commit 038038d

Please sign in to comment.