From 76696b56e28950f76121eba007d61a07999e7701 Mon Sep 17 00:00:00 2001 From: Roberto Quintanilla Date: Mon, 13 Jul 2015 16:31:12 -0500 Subject: [PATCH] Added a docker compose config file, and updated rails logger & redis connection to work with the docker compose setup example --- .gitignore | 3 +++ config/environments/development.rb | 3 +++ config/redis/cable.yml | 4 +--- docker-compose.yml | 38 ++++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 docker-compose.yml diff --git a/.gitignore b/.gitignore index bee74170..2013267f 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,6 @@ /tmp/* !/log/.keep !/tmp/.keep + +/vendor/bundle +/.bash_history diff --git a/config/environments/development.rb b/config/environments/development.rb index b55e2144..076ce687 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -19,6 +19,9 @@ # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log + # Log to STDOUT if the environment variable is present (i.e. Docker Compose example) + config.logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT)) if ENV['RAILS_LOG_TO_STDOUT'] + # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load diff --git a/config/redis/cable.yml b/config/redis/cable.yml index b63018e7..48616d81 100644 --- a/config/redis/cable.yml +++ b/config/redis/cable.yml @@ -5,9 +5,7 @@ # :timeout: 1 local: &local - :url: redis://localhost:6379 - :host: localhost - :port: 6379 + :url: <%= ENV.fetch 'REDIS_URL', 'redis://localhost:6379' %> # Fetch environment variable (i.e. Docker Compose example) :timeout: 1 :inline: true development: *local diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..c6cbb636 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,38 @@ +--- +# The Redis Container: +redis: + image: redis:3.0 + ports: + - "6379:6379" # Bind host port 6379 to Redis container's port 6379 + +# The Web container: +web: &app_base + image: vovimayhem/app-dev:mri-2.2 + command: rails server -p 3000 -b 0.0.0.0 + ports: + - "3000:3000" # Bind host port 3000 to app container's HTTP port 3000 + volumes: + - .:/app + ############################################################################## + # With linked containers, Docker writes entries to the container's /etc/hosts. + # We'll try here naming the entries docker will insert into the + # container's /etc/hosts, so we can use more familiar URL's for our app - See + # this container's environment section below: + links: &app_links + - redis:redis.example.com + environment: &app_environment + + # The Redis URL: + REDIS_URL: redis://redis.example.com:6379 + + RAILS_LOG_TO_STDOUT: true + + # Run the app in the 'development' environment: + RACK_ENV: development + RAILS_ENV: development + +cable: + <<: *app_base + command: cable + ports: + - "28080:28080" # Bind host port 28080 to app container's WebSocket port 28080