From f1aca16a1eb7c85cb2aa1950ebc58e880204cace Mon Sep 17 00:00:00 2001 From: Michael Kohl Date: Sat, 15 Feb 2020 02:28:27 +0700 Subject: [PATCH] Improve Docker configuration (#6055) --- config/environments/development.rb | 13 +++++++++++++ docker-compose.yml | 15 +++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/config/environments/development.rb b/config/environments/development.rb index a75706d3c..b7a1a46e4 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -119,6 +119,19 @@ Rails.application.configure do end end end + + # Docker specific development configuration + if File.file?("/.dockerenv") + # Using shell tools so we don't need to require Socket and IPAddr + host_ip = `/sbin/ip route|awk '/default/ { print $3 }'`.strip + logger = Logger.new(STDOUT) + logger.info "Whitelisting #{host_ip} for BetterErrors and Web Console" + + if defined?(BetterErrors::Middleware) + BetterErrors::Middleware.allow_ip!(host_ip) + end + config.web_console.whitelisted_ips << host_ip + end end Rails.application.routes.default_url_options = { host: Rails.application.config.app_domain } diff --git a/docker-compose.yml b/docker-compose.yml index 4cb1a0333..67b7beea9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,6 +13,7 @@ services: DATABASE_URL: postgres://postgres:mysecretpassword@db:5432/postgres YARN_INTEGRITY_ENABLED: "false" ELASTICSEARCH_URL: http://elasticsearch:9200 + REDIS_URL: redis://redis:6379 volumes: - .:/usr/src/app command: bundle exec rails server -b 0.0.0.0 -p 3000 @@ -21,12 +22,26 @@ services: command: rails jobs:work depends_on: - db + - redis environment: RAILS_ENV: development DATABASE_URL: postgres://postgres:mysecretpassword@db:5432/postgres + REDIS_URL: redis://redis:6379 webpacker: build: . command: ./bin/webpack-dev-server + sidekiq: + build: . + command: bundle exec sidekiq -c 2 + depends_on: + - redis + - db + - elasticsearch + environment: + RAILS_ENV: development + REDIS_SIDEKIQ_URL: redis://redis:6379 + DATABASE_URL: postgres://postgres:mysecretpassword@db:5432/postgres + ELASTICSEARCH_URL: http://elasticsearch:9200 db: image: postgres:${POSTGRES_VERSION:-9.6.15-alpine} ports: