Skip to content
This repository has been archived by the owner on Jul 24, 2023. It is now read-only.

Example with Docker Compose #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@
/tmp/*
!/log/.keep
!/tmp/.keep

/vendor/bundle
/.bash_history
3 changes: 3 additions & 0 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 1 addition & 3 deletions config/redis/cable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 38 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@syndbg The example rails app uses an unreleased version of Rails 5.0 (as it's currently being developed), so you'll not find it on the official Docker library.

I also admit that although there's an official Ruby image, I find this one easier to use, as it does not require any building step besides the bundle install. (I remember having to run some sort of building step in the official ruby image)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vovimayhem Aha, I see! Good to know. :)

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