Last active
May 10, 2017 17:02
-
-
Save curtisspendlove/5b4d2d931a1023f0fa3c653c0038967e to your computer and use it in GitHub Desktop.
bin/bash script to build a clean install of docker/rails (run from inside a new directory ... mkdir rails_project && cd rails_project && bash <(curl -s https://gist.githubusercontent.com/curtisspendlove/5b4d2d931a1023f0fa3c653c0038967e/raw/357db84f9bb7cc566425e772802ae56ad11e2aab/clean_docker_rails.sh))
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
#touch Gemfile | |
touch Gemfile.lock | |
#touch Dockerfile | |
#touch docker-compose.yml | |
cat > Dockerfile << EOF | |
FROM ruby:2.4.1 | |
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs | |
RUN mkdir /myapp | |
WORKDIR /myapp | |
ADD Gemfile /myapp/Gemfile | |
ADD Gemfile.lock /myapp/Gemfile.lock | |
RUN bundle install | |
ADD . /myapp | |
EOF | |
cat > Gemfile << EOF | |
source 'https://rubygems.org' | |
gem 'rails', '~> 5.1' | |
EOF | |
cat > docker-compose.yml << EOF | |
version: '2' | |
services: | |
db: | |
image: postgres | |
web: | |
build: . | |
command: bundle exec rails s -p 3000 -b '0.0.0.0' | |
volumes: | |
- .:/myapp | |
ports: | |
- "3000:3000" | |
depends_on: | |
- db | |
EOF | |
docker-compose run web rails new . --force --database=postgresql --skip-bundle | |
docker-compose build | |
cat > config/database.yml << EOF | |
development: &default | |
adapter: postgresql | |
encoding: unicode | |
database: myapp_development | |
pool: 5 | |
username: postgres | |
password: | |
host: db | |
test: | |
<<: *default | |
database: myapp_test | |
EOF | |
docker-compose build | |
docker-compose run web rake db:create | |
docker-compose up |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment