Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.