Skip to content

Instantly share code, notes, and snippets.

@peterkappus
Last active June 10, 2018 18:53
Show Gist options
  • Save peterkappus/28b3c221f49fa08321bd06ffc98bd945 to your computer and use it in GitHub Desktop.
Save peterkappus/28b3c221f49fa08321bd06ffc98bd945 to your computer and use it in GitHub Desktop.
default: &default
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
host: db
username: postgres
password:
development:
<<: *default
database: rocky_dev
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: rocky_test
production:
<<: *default
database: rocky_production
username: rocky
password: <%= ENV['GOALIE_DATABASE_PASSWORD'] %>

How I create a rails app in 2018...

  1. Create the repo and clone it
  2. Create a dockerfile
  3. Create a docker-compose file
  4. Use docker-comose run web bash
  5. Inside, run gem install rails && cd /app && rails new .

create a Dockerfile to build the "app"

RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
RUN mkdir /myapp
WORKDIR /myapp
COPY Gemfile /myapp/Gemfile
COPY Gemfile.lock /myapp/Gemfile.lock
RUN bundle install
COPY . /myapp

Update Gemfile...

#replace sqlite3 with 
gem 'pg', '~> 0.18'

#Need authentication? Devise is good...
gem 'devise'
gem 'devise-bootstrap-views'

Update database.yml (See below)

run rails generate bootstrap:install to get the bootstrap generators. Might have to --force if you've already got some.

Handy commands

docker-compose build
docker-compose up
docker-compose down
docker compose run web bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment