Skip to content

Instantly share code, notes, and snippets.

@dogweather
Created February 3, 2018 04:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save dogweather/de42add0fb99194626c00b4ab5f4ca6e to your computer and use it in GitHub Desktop.
Save dogweather/de42add0fb99194626c00b4ab5f4ca6e to your computer and use it in GitHub Desktop.
Docker dev environment for Ruby on Rails
version: '3.2'
services:
db:
image: postgres
web:
build: .
volumes:
- type: bind
source: .
target: /app
ports:
- "3000:3000"
depends_on:
- db
command:
- ./run.sh
# Ruby on Rails Development Environment
FROM ruby:2.5.0
# Set up Linux
RUN apt-get update
RUN apt-get install -y build-essential inotify-tools libpq-dev nodejs postgresql-client
WORKDIR /app
EXPOSE 3000
#!/bin/sh
set -e
# Ensure the app's dependencies are installed
echo "bundle install --without=production..."
bundle install --without=production
# Wait for Postgres to become available.
echo "Checking for Postgres..."
until psql -h db -U "postgres" -c '\q' 2>/dev/null; do
>&2 echo "Postgres is unavailable - sleeping"
sleep 1
done
echo "Postgres is available: continuing with database setup..."
# Potentially Set up the database
echo "bundle exec rake db:setup..."
bin/rails db:setup
# Start the web server
echo "bin/rails s -p 3000 -b '0.0.0.0'..."
bin/rails s -p 3000 -b '0.0.0.0'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment