Skip to content

Commit

Permalink
🙈 Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloVallejo committed Oct 15, 2016
0 parents commit 7369067
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# editorconfig.org
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.erb]
indent_size = 4
draw_indent_guides = true

[*.sass]
indent_size = 4
44 changes: 44 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
*.rbc
capybara-*.html
.rspec
/log
/tmp
/db/*.sqlite3
/db/*.sqlite3-journal
/public/system
/coverage/
/spec/tmp
**.orig
rerun.txt
pickle-email-*.html

# TODO Comment out this rule if you are OK with secrets being uploaded to the repo
config/initializers/secret_token.rb

# Only include if you have production secrets in this file, which is no longer a Rails default
# config/secrets.yml

# dotenv
# TODO Comment out this rule if environment variables can be committed
.env

## Environment normalization:
/.bundle
/vendor/bundle

# these should all be checked in to normalize the environment:
# Gemfile.lock, .ruby-version, .ruby-gemset

# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
.rvmrc

# if using bower-rails ignore default bower_components path bower.json files
/vendor/assets/bower_components
*.bowerrc
bower.json

# Ignore pow environment settings
.powenv

# Ignore Byebug command history file.
.byebug_history
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM ruby:2.3.1
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs

RUN mkdir /app
WORKDIR /app

ADD Gemfile /app/Gemfile
ADD Gemfile.lock /app/Gemfile.lock

RUN bundle install
ADD . /app
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.0'
Empty file added Gemfile.lock
Empty file.
60 changes: 60 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Rails 5 Docker boilerplate

Boilerplate for Rails projects using Docker.


## Building the project

Run the following command to create a new Rails project scaffold with a postgres database.

```bash
docker-compose run web rails new . --force --database=postgresql --skip-bundle
```

In order to have a JavaScript runtime you have to uncomment this line in your Gemfile.
```
gem 'therubyracer', platforms: :ruby
```

After that build the project in order to install new Gems.

```bash
docker-compose build
```

## Database

Use the following configuration for your **development** and **test** databases.

```yaml
development: &default
adapter: postgresql
encoding: unicode
database: postgres
pool: 5
username: postgres
password:
host: db

test:
<<: *default
database: myapp_test
```
After this you can run the project and get ready to create the database.
```bash
$ docker-compose up
```

Run this command to create the database.

```bash
$ docker-compose run web rake db:create
```

## Running

At this point your application must be running on localhost on port 3000, so head over to it and take a look!

[http://localhost:3000](http://localhost:3000)
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '2'
services:
db:
image: postgres
web:
build: .
command: bash -c "rm tmp/pids/server.pid & bundle exec rails s -p 3000 -b '0.0.0.0'"
volumes:
- .:/app
ports:
- "3000:3000"
depends_on:
- db

0 comments on commit 7369067

Please sign in to comment.