Skip to content

Instantly share code, notes, and snippets.

@rands0n
Created March 25, 2017 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rands0n/8e36eab362e190d670f5ecac36016e01 to your computer and use it in GitHub Desktop.
Save rands0n/8e36eab362e190d670f5ecac36016e01 to your computer and use it in GitHub Desktop.
Docker to run ruby
# set up
docker-compose run web rails new . --force --database=postgresql --skip-bundle
# db
docker-compose run web rails db:create && rails db:migrate
# if you have any issues with gems and any time
# you change your Gemfile or Dockerfile, run
docker-compose build
# running the app
docker-compose up -d
# show the files
ls -l
# if on linux
sudo chown -R $USER:$USER .
# config for database
username: postgres
password:
host: db
version: '2'
services:
db:
image: postgres
web:
build: .
command: bundle exec rails -p 3000 -b '0.0.0.0'
volumes:
- .:/app
ports:
- "3000:3000"
depends_on:
- db
FROM ruby:2.3.3
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
RUN mkdir /app # app name
WORKDIR /app
ADD Gemfile /app/Gemfile
ADD Gemfile.lock /app/Gemfile.lock
RUN bundle install
ADD . /app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment