├── log └── .keep ├── app ├── mailers │ └── .keep ├── models │ ├── .keep │ ├── concerns │ │ └── .keep │ └── book.rb ├── assets │ ├── images │ │ └── .keep │ ├── javascripts │ │ └── application.js │ └── stylesheets │ │ └── application.css ├── controllers │ ├── concerns │ │ └── .keep │ ├── welcome_controller.rb │ ├── application_controller.rb │ └── books_controller.rb ├── views │ ├── welcome │ │ └── index.slim │ ├── books │ │ ├── show.json.jbuilder │ │ ├── new.html.slim │ │ ├── edit.html.slim │ │ ├── index.json.jbuilder │ │ ├── show.html.slim │ │ ├── _form.html.slim │ │ └── index.html.slim │ └── layouts │ │ └── application.html.slim ├── helpers │ └── application_helper.rb └── jobs │ └── books_job.rb ├── lib ├── assets │ └── .keep └── tasks │ └── .keep ├── public ├── favicon.ico ├── robots.txt ├── 500.html ├── 422.html └── 404.html ├── .ruby-version ├── vendor └── assets │ ├── javascripts │ └── .keep │ └── stylesheets │ └── .keep ├── .rspec ├── docker ├── serverspec │ ├── .rspec │ ├── Gemfile │ ├── spec │ │ ├── spec_helper.rb │ │ └── localhost │ │ │ ├── supervisor_spec.rb │ │ │ ├── locale_spec.rb │ │ │ ├── ruby_spec.rb │ │ │ ├── nginx_spec.rb │ │ │ ├── unicorn_spec.rb │ │ │ └── sidekiq_spec.rb │ ├── .bundle │ │ └── config │ ├── Rakefile │ └── Gemfile.lock └── files │ └── etc │ ├── supervisor │ ├── conf.d │ │ ├── nginx.conf │ │ ├── sidekiq.conf │ │ └── unicorn.conf │ └── supervisord.conf │ ├── nginx │ └── nginx.conf │ └── init.d │ ├── sidekiq │ └── unicorn ├── script ├── build-docker.sh ├── run-supervisord.sh ├── ecs-deploy-db-migrate.sh ├── run-server-spec.sh └── ecs-deploy-services.sh ├── bin ├── bundle ├── rake ├── rails ├── sidekiq ├── unicorn ├── sidekiqctl ├── unicorn_rails ├── spring └── setup ├── config ├── boot.rb ├── initializers │ ├── cookies_serializer.rb │ ├── session_store.rb │ ├── mime_types.rb │ ├── filter_parameter_logging.rb │ ├── backtrace_silencers.rb │ ├── assets.rb │ ├── wrap_parameters.rb │ └── inflections.rb ├── environment.rb ├── sidekiq.yml ├── locales │ └── en.yml ├── unicorn.rb ├── application.rb ├── secrets.yml ├── environments │ ├── development.rb │ ├── test.rb │ └── production.rb ├── database.yml └── routes.rb ├── spec ├── models │ └── book_spec.rb ├── jobs │ └── books_job_spec.rb ├── routing │ └── books_routing_spec.rb ├── rails_helper.rb ├── spec_helper.rb └── controllers │ └── books_controller_spec.rb ├── config.ru ├── .dockerignore ├── db ├── migrate │ └── 20150911082140_create_books.rb ├── seeds.rb └── schema.rb ├── Rakefile ├── .gitignore ├── README.rdoc ├── ecs-task-definitions ├── task-db-migrate.json.erb └── service.json.erb ├── Gemfile ├── circle.yml ├── Dockerfile.erb └── Gemfile.lock /log/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/assets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/tasks/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.ruby-version: -------------------------------------------------------------------------------- 1 | 2.2.2 2 | -------------------------------------------------------------------------------- /app/assets/images/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/models/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/controllers/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/assets/javascripts/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/assets/stylesheets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --color 2 | --require spec_helper 3 | -------------------------------------------------------------------------------- /app/views/welcome/index.slim: -------------------------------------------------------------------------------- 1 | h1 It works 2 | p Welcome 3 | -------------------------------------------------------------------------------- /app/models/book.rb: -------------------------------------------------------------------------------- 1 | class Book < ActiveRecord::Base 2 | end 3 | -------------------------------------------------------------------------------- /docker/serverspec/.rspec: -------------------------------------------------------------------------------- 1 | --color 2 | --format documentation 3 | -------------------------------------------------------------------------------- /app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /docker/serverspec/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'serverspec' 4 | -------------------------------------------------------------------------------- /app/controllers/welcome_controller.rb: -------------------------------------------------------------------------------- 1 | class WelcomeController < ApplicationController 2 | end 3 | -------------------------------------------------------------------------------- /docker/files/etc/supervisor/conf.d/nginx.conf: -------------------------------------------------------------------------------- 1 | [program:nginx] 2 | command=service nginx start 3 | -------------------------------------------------------------------------------- /docker/serverspec/spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'serverspec' 2 | 3 | set :backend, :exec 4 | 5 | -------------------------------------------------------------------------------- /docker/files/etc/supervisor/conf.d/sidekiq.conf: -------------------------------------------------------------------------------- 1 | [program:sidekiq] 2 | command=service sidekiq start 3 | -------------------------------------------------------------------------------- /docker/files/etc/supervisor/conf.d/unicorn.conf: -------------------------------------------------------------------------------- 1 | [program:unicorn] 2 | command=service unicorn start 3 | -------------------------------------------------------------------------------- /app/views/books/show.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.extract! @book, :id, :title, :author, :created_at, :updated_at 2 | -------------------------------------------------------------------------------- /app/views/books/new.html.slim: -------------------------------------------------------------------------------- 1 | h1 New book 2 | 3 | == render 'form' 4 | 5 | = link_to 'Back', books_path 6 | -------------------------------------------------------------------------------- /script/build-docker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -eu 3 | 4 | erb Dockerfile.erb > Dockerfile 5 | docker build -t "${DOCKER_REPO}:${ROLE}" . 6 | -------------------------------------------------------------------------------- /docker/serverspec/.bundle/config: -------------------------------------------------------------------------------- 1 | --- 2 | BUNDLE_PATH: vendor/bundle 3 | BUNDLE_DISABLE_SHARED_GEMS: '1' 4 | BUNDLE_WITHOUT: test development 5 | -------------------------------------------------------------------------------- /bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /app/views/books/edit.html.slim: -------------------------------------------------------------------------------- 1 | h1 Editing book 2 | 3 | == render 'form' 4 | 5 | = link_to 'Show', @book 6 | '| 7 | = link_to 'Back', books_path 8 | 9 | -------------------------------------------------------------------------------- /config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 2 | 3 | require 'bundler/setup' # Set up gems listed in the Gemfile. 4 | -------------------------------------------------------------------------------- /app/jobs/books_job.rb: -------------------------------------------------------------------------------- 1 | class BooksJob < ActiveJob::Base 2 | queue_as :default 3 | 4 | def perform(params) 5 | Book.create!(params) 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/models/book_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe Book, type: :model do 4 | pending "add some examples to (or delete) #{__FILE__}" 5 | end 6 | -------------------------------------------------------------------------------- /app/views/books/index.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.array!(@books) do |book| 2 | json.extract! book, :id, :title, :author 3 | json.url book_url(book, format: :json) 4 | end 5 | -------------------------------------------------------------------------------- /spec/jobs/books_job_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe BooksJob, type: :job do 4 | pending "add some examples to (or delete) #{__FILE__}" 5 | end 6 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | run Rails.application 5 | -------------------------------------------------------------------------------- /docker/serverspec/spec/localhost/supervisor_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe file('/var/run/supervisor.sock') do 4 | it { is_expected.to be_socket } 5 | end 6 | -------------------------------------------------------------------------------- /config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.action_dispatch.cookies_serializer = :json 4 | -------------------------------------------------------------------------------- /script/run-supervisord.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "DATABASE_URL=${DATABASE_URL}" >> /var/www/app/.env 4 | echo "REDIS_URL=${REDIS_URL}" >> /var/www/app/.env 5 | /usr/bin/supervisord -n 6 | -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.session_store :cookie_store, key: '_docker-rails-example_session' 4 | -------------------------------------------------------------------------------- /bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path("../spring", __FILE__) 4 | rescue LoadError 5 | end 6 | require_relative '../config/boot' 7 | require 'rake' 8 | Rake.application.run 9 | -------------------------------------------------------------------------------- /config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | /docker 2 | /tmp 3 | /test 4 | /log/*.log 5 | !/log/.keep 6 | /circle.yml 7 | /Dockerfile 8 | /vendor/bunlder/* 9 | .DS_Store 10 | .*.swp 11 | /ecs-task-definitions 12 | /.ecs-task-definition.json 13 | -------------------------------------------------------------------------------- /docker/serverspec/spec/localhost/locale_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe file('/etc/default/locale') do 4 | it { is_expected.to be_file } 5 | its(:content) { is_expected.to eq "LANG=\"en_US.UTF-8\"\n" } 6 | end 7 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /app/views/books/show.html.slim: -------------------------------------------------------------------------------- 1 | p#notice = notice 2 | 3 | p 4 | strong Title: 5 | = @book.title 6 | p 7 | strong Author: 8 | = @book.author 9 | 10 | = link_to 'Edit', edit_book_path(@book) 11 | '| 12 | = link_to 'Back', books_path 13 | -------------------------------------------------------------------------------- /config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure sensitive parameters which will be filtered from the log file. 4 | Rails.application.config.filter_parameters += [:password] 5 | -------------------------------------------------------------------------------- /bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path("../spring", __FILE__) 4 | rescue LoadError 5 | end 6 | APP_PATH = File.expand_path('../../config/application', __FILE__) 7 | require_relative '../config/boot' 8 | require 'rails/commands' 9 | -------------------------------------------------------------------------------- /app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | # Prevent CSRF attacks by raising an exception. 3 | # For APIs, you may want to use :null_session instead. 4 | protect_from_forgery with: :exception 5 | end 6 | -------------------------------------------------------------------------------- /db/migrate/20150911082140_create_books.rb: -------------------------------------------------------------------------------- 1 | class CreateBooks < ActiveRecord::Migration 2 | def change 3 | create_table :books do |t| 4 | t.string :title 5 | t.string :author 6 | 7 | t.timestamps null: false 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require File.expand_path('../config/application', __FILE__) 5 | 6 | Rails.application.load_tasks 7 | -------------------------------------------------------------------------------- /config/sidekiq.yml: -------------------------------------------------------------------------------- 1 | --- 2 | :concurrency: 5 3 | :pidfile: tmp/pids/sidekiq.pid 4 | :logfile: log/sidekiq.development.log 5 | production: 6 | :pidfile: /var/runsidekiq.pid 7 | :logfile: log/sidekiq.production.log 8 | :concurrency: 20 9 | :queues: 10 | - default 11 | -------------------------------------------------------------------------------- /app/views/layouts/application.html.slim: -------------------------------------------------------------------------------- 1 | doctype 5 2 | html lang=I18n.locale.to_s 3 | head 4 | title Docker Rails Example 5 | = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true 6 | = javascript_include_tag 'application', 'data-turbolinks-track' => true 7 | = csrf_meta_tags 8 | body 9 | = yield 10 | -------------------------------------------------------------------------------- /db/seeds.rb: -------------------------------------------------------------------------------- 1 | # This file should contain all the record creation needed to seed the database with its default values. 2 | # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). 3 | # 4 | # Examples: 5 | # 6 | # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) 7 | # Mayor.create(name: 'Emanuel', city: cities.first) 8 | -------------------------------------------------------------------------------- /docker/serverspec/spec/localhost/ruby_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe command('/usr/bin/ruby -e "print RUBY_VERSION"') do 4 | its(:stdout) { is_expected.to eq '2.2.3' } 5 | its(:exit_status) { is_expected.to eq 0 } 6 | end 7 | 8 | describe command('bundle --version') do 9 | its(:stdout) { is_expected.to eq "Bundler version 1.10.6\n" } 10 | its(:exit_status) { is_expected.to eq 0 } 11 | end 12 | -------------------------------------------------------------------------------- /bin/sidekiq: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # 3 | # This file was generated by Bundler. 4 | # 5 | # The application 'sidekiq' is installed as part of a gem, and 6 | # this file is here to facilitate running it. 7 | # 8 | 9 | require 'pathname' 10 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", 11 | Pathname.new(__FILE__).realpath) 12 | 13 | require 'rubygems' 14 | require 'bundler/setup' 15 | 16 | load Gem.bin_path('sidekiq', 'sidekiq') 17 | -------------------------------------------------------------------------------- /bin/unicorn: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # 3 | # This file was generated by Bundler. 4 | # 5 | # The application 'unicorn' is installed as part of a gem, and 6 | # this file is here to facilitate running it. 7 | # 8 | 9 | require 'pathname' 10 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", 11 | Pathname.new(__FILE__).realpath) 12 | 13 | require 'rubygems' 14 | require 'bundler/setup' 15 | 16 | load Gem.bin_path('unicorn', 'unicorn') 17 | -------------------------------------------------------------------------------- /bin/sidekiqctl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # 3 | # This file was generated by Bundler. 4 | # 5 | # The application 'sidekiqctl' is installed as part of a gem, and 6 | # this file is here to facilitate running it. 7 | # 8 | 9 | require 'pathname' 10 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", 11 | Pathname.new(__FILE__).realpath) 12 | 13 | require 'rubygems' 14 | require 'bundler/setup' 15 | 16 | load Gem.bin_path('sidekiq', 'sidekiqctl') 17 | -------------------------------------------------------------------------------- /config/initializers/backtrace_silencers.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. 4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } 5 | 6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. 7 | # Rails.backtrace_cleaner.remove_silencers! 8 | -------------------------------------------------------------------------------- /bin/unicorn_rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # 3 | # This file was generated by Bundler. 4 | # 5 | # The application 'unicorn_rails' is installed as part of a gem, and 6 | # this file is here to facilitate running it. 7 | # 8 | 9 | require 'pathname' 10 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", 11 | Pathname.new(__FILE__).realpath) 12 | 13 | require 'rubygems' 14 | require 'bundler/setup' 15 | 16 | load Gem.bin_path('unicorn', 'unicorn_rails') 17 | -------------------------------------------------------------------------------- /app/views/books/_form.html.slim: -------------------------------------------------------------------------------- 1 | = form_for @book do |f| 2 | - if @book.errors.any? 3 | #error_explanation 4 | h2 = "#{pluralize(@book.errors.count, "error")} prohibited this book from being saved:" 5 | ul 6 | - @book.errors.full_messages.each do |message| 7 | li = message 8 | 9 | .field 10 | = f.label :title 11 | = f.text_field :title 12 | .field 13 | = f.label :author 14 | = f.text_field :author 15 | .actions = f.submit 16 | -------------------------------------------------------------------------------- /docker/files/etc/supervisor/supervisord.conf: -------------------------------------------------------------------------------- 1 | [unix_http_server] 2 | file=/var/run/supervisor.sock 3 | chmod=0700 4 | 5 | [supervisord] 6 | logfile=/var/log/supervisor/supervisord.log 7 | pidfile=/var/run/supervisord.pid 8 | childlogdir=/var/log/supervisor 9 | 10 | [rpcinterface:supervisor] 11 | supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface 12 | 13 | [supervisorctl] 14 | serverurl=unix:///var/run/supervisor.sock 15 | 16 | [include] 17 | files = /etc/supervisor/conf.d/*.conf 18 | -------------------------------------------------------------------------------- /bin/spring: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | # This file loads spring without using Bundler, in order to be fast. 4 | # It gets overwritten when you run the `spring binstub` command. 5 | 6 | unless defined?(Spring) 7 | require "rubygems" 8 | require "bundler" 9 | 10 | if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m) 11 | Gem.paths = { "GEM_PATH" => [Bundler.bundle_path.to_s, *Gem.path].uniq } 12 | gem "spring", match[1] 13 | require "spring/binstub" 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /app/views/books/index.html.slim: -------------------------------------------------------------------------------- 1 | h1 Listing books 2 | 3 | table 4 | thead 5 | tr 6 | th Title 7 | th Author 8 | th 9 | th 10 | th 11 | 12 | tbody 13 | - @books.each do |book| 14 | tr 15 | td = book.title 16 | td = book.author 17 | td = link_to 'Show', book 18 | td = link_to 'Edit', edit_book_path(book) 19 | td = link_to 'Destroy', book, data: {:confirm => 'Are you sure?'}, :method => :delete 20 | 21 | br 22 | 23 | = link_to 'New Book', new_book_path 24 | -------------------------------------------------------------------------------- /config/initializers/assets.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Version of your assets, change this if you want to expire all your assets. 4 | Rails.application.config.assets.version = '1.0' 5 | 6 | # Add additional assets to the asset load path 7 | # Rails.application.config.assets.paths << Emoji.images_path 8 | 9 | # Precompile additional assets. 10 | # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. 11 | # Rails.application.config.assets.precompile += %w( search.js ) 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files for more about ignoring files. 2 | # 3 | # If you find yourself ignoring temporary files generated by your text editor 4 | # or operating system, you probably want to add a global ignore instead: 5 | # git config --global core.excludesfile '~/.gitignore_global' 6 | 7 | # Ignore bundler config. 8 | /.bundle 9 | 10 | # Ignore all logfiles and tempfiles. 11 | /log/* 12 | !/log/.keep 13 | /tmp 14 | /Dockerfile 15 | /docker/serverspec/vendor/bundle/* 16 | /.ecs-task-definition.json 17 | /.env 18 | -------------------------------------------------------------------------------- /config/initializers/wrap_parameters.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # This file contains settings for ActionController::ParamsWrapper which 4 | # is enabled by default. 5 | 6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. 7 | ActiveSupport.on_load(:action_controller) do 8 | wrap_parameters format: [:json] if respond_to?(:wrap_parameters) 9 | end 10 | 11 | # To enable root element in JSON for ActiveRecord objects. 12 | # ActiveSupport.on_load(:active_record) do 13 | # self.include_root_in_json = true 14 | # end 15 | -------------------------------------------------------------------------------- /README.rdoc: -------------------------------------------------------------------------------- 1 | == README 2 | 3 | This README would normally document whatever steps are necessary to get the 4 | application up and running. 5 | 6 | Things you may want to cover: 7 | 8 | * Ruby version 9 | 10 | * System dependencies 11 | 12 | * Configuration 13 | 14 | * Database creation 15 | 16 | * Database initialization 17 | 18 | * How to run the test suite 19 | 20 | * Services (job queues, cache servers, search engines, etc.) 21 | 22 | * Deployment instructions 23 | 24 | * ... 25 | 26 | 27 | Please feel free to use a different markup language if you do not plan to run 28 | rake doc:app. 29 | -------------------------------------------------------------------------------- /docker/serverspec/spec/localhost/nginx_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'nginx', if: ENV['ROLE'] == 'web' do 4 | describe service('nginx') do 5 | it { is_expected.to be_enabled } 6 | it { is_expected.to be_running } 7 | it { is_expected.to be_running.under('supervisor') } 8 | end 9 | 10 | describe port(80) do 11 | it { is_expected.to be_listening } 12 | end 13 | 14 | describe port(443) do 15 | it { is_expected.not_to be_listening } 16 | end 17 | 18 | describe command('curl -I http://localhost') do 19 | its(:stdout) { is_expected.to contain 'HTTP/1.1 200 OK' } 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format. Inflections 4 | # are locale specific, and you may define rules for as many different 5 | # locales as you wish. All of these examples are active by default: 6 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 7 | # inflect.plural /^(ox)$/i, '\1en' 8 | # inflect.singular /^(ox)en/i, '\1' 9 | # inflect.irregular 'person', 'people' 10 | # inflect.uncountable %w( fish sheep ) 11 | # end 12 | 13 | # These inflection rules are supported but not enabled by default: 14 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 15 | # inflect.acronym 'RESTful' 16 | # end 17 | -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Files in the config/locales directory are used for internationalization 2 | # and are automatically loaded by Rails. If you want to use locales other 3 | # than English, add the necessary files in this directory. 4 | # 5 | # To use the locales, use `I18n.t`: 6 | # 7 | # I18n.t 'hello' 8 | # 9 | # In views, this is aliased to just `t`: 10 | # 11 | # <%= t('hello') %> 12 | # 13 | # To use a different locale, set it with `I18n.locale`: 14 | # 15 | # I18n.locale = :es 16 | # 17 | # This would use the information in config/locales/es.yml. 18 | # 19 | # To learn more, please read the Rails Internationalization guide 20 | # available at http://guides.rubyonrails.org/i18n.html. 21 | 22 | en: 23 | hello: "Hello world" 24 | -------------------------------------------------------------------------------- /app/assets/javascripts/application.js: -------------------------------------------------------------------------------- 1 | // This is a manifest file that'll be compiled into application.js, which will include all the files 2 | // listed below. 3 | // 4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, 5 | // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path. 6 | // 7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 8 | // compiled file. 9 | // 10 | // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details 11 | // about supported directives. 12 | // 13 | //= require jquery 14 | //= require jquery_ujs 15 | //= require turbolinks 16 | //= require_tree . 17 | -------------------------------------------------------------------------------- /app/assets/stylesheets/application.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll be compiled into application.css, which will include all the files 3 | * listed below. 4 | * 5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, 6 | * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path. 7 | * 8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the 9 | * compiled file so the styles you add here take precedence over styles defined in any styles 10 | * defined in the other CSS/SCSS files in this directory. It is generally better to create a new 11 | * file per style scope. 12 | * 13 | *= require_tree . 14 | *= require_self 15 | */ 16 | -------------------------------------------------------------------------------- /script/ecs-deploy-db-migrate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -eu 3 | 4 | UPPER_ENV_NAME=$(echo $ENV_NAME | awk '{print toupper($0)}') 5 | DATABASE_URL=$(eval "echo \$DATABASE_URL_${UPPER_ENV_NAME}") 6 | REDIS_URL=$(eval "echo \$REDIS_URL_${UPPER_ENV_NAME}") 7 | APP_NAME='ngs-docker-rails-example-' 8 | TASK_FAMILY="${APP_NAME}${ENV_NAME}" 9 | 10 | REDIS_URL=$REDIS_URL DATABASE_URL=$DATABASE_URL \ 11 | erb ecs-task-definitions/task-db-migrate.json.erb > .ecs-task-definition.json 12 | TASK_DEFINITION_JSON=$(aws ecs register-task-definition --family $TASK_FAMILY --cli-input-json "file://$(pwd)/.ecs-task-definition.json") 13 | TASK_REVISION=$(echo $TASK_DEFINITION_JSON | jq .taskDefinition.revision) 14 | 15 | aws ecs run-task --cluster default --task-definition "${TASK_FAMILY}:${TASK_REVISION}" | jq . 16 | -------------------------------------------------------------------------------- /docker/serverspec/Rakefile: -------------------------------------------------------------------------------- 1 | require 'rake' 2 | require 'rspec/core/rake_task' 3 | 4 | task :spec => 'spec:all' 5 | task :default => :spec 6 | 7 | namespace :spec do 8 | targets = [] 9 | Dir.glob('./spec/*').each do |dir| 10 | next unless File.directory?(dir) 11 | target = File.basename(dir) 12 | target = "_#{target}" if target == "default" 13 | targets << target 14 | end 15 | 16 | task :all => targets 17 | task :default => :all 18 | 19 | targets.each do |target| 20 | original_target = target == "_default" ? target[1..-1] : target 21 | desc "Run serverspec tests to #{original_target}" 22 | RSpec::Core::RakeTask.new(target.to_sym) do |t| 23 | ENV['TARGET_HOST'] = original_target 24 | t.pattern = "spec/#{original_target}/*_spec.rb" 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /docker/serverspec/spec/localhost/unicorn_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'unicorn', if: ENV['ROLE'] == 'web' do 4 | describe service('unicorn') do 5 | it { is_expected.not_to be_enabled } 6 | it { is_expected.to be_running } 7 | it { is_expected.to be_running.under('supervisor') } 8 | end 9 | 10 | describe file('/var/run/unicorn.sock') do 11 | it { is_expected.to be_socket } 12 | end 13 | 14 | describe file('/var/www/app/log/unicorn.stderr.log') do 15 | it { is_expected.to be_file } 16 | its(:content) { is_expected.to contain 'listening on addr=/var/run/unicorn.sock fd=' } 17 | its(:content) { is_expected.to contain 'worker=0 ready' } 18 | its(:content) { is_expected.to contain 'worker=1 ready' } 19 | its(:content) { is_expected.to contain 'master process ready' } 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /ecs-task-definitions/task-db-migrate.json.erb: -------------------------------------------------------------------------------- 1 | { 2 | "family": "ngs-docker-rails-example-db-migrate-<%= ENV['ENV_NAME'] %>", 3 | "containerDefinitions": [ 4 | { 5 | "image": "<%= ENV['DOCKER_REPO'] %>:job-b<%= ENV['CIRCLE_BUILD_NUM'] %>", 6 | "name": "docker-rails-example-db-migrate", 7 | "cpu": 1, 8 | "memory": 128, 9 | "essential": true, 10 | "command": ["./bin/rake", "db:migrate"], 11 | "mountPoints": [{ "containerPath": "/var/www/app/log", "sourceVolume": "log", "readOnly": false }], 12 | "environment": [ 13 | { "name": "DATABASE_URL", "value": "<%= ENV['DATABASE_URL'] %>" }, 14 | { "name": "REDIS_URL", "value": "<%= ENV['REDIS_URL'] %>" } 15 | ], 16 | "essential": true 17 | } 18 | ], 19 | "volumes": [ 20 | { 21 | "name": "log", 22 | "host": { "sourcePath": "/var/log/rails" } 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /config/unicorn.rb: -------------------------------------------------------------------------------- 1 | @app_path = File.expand_path '../../', __FILE__ 2 | 3 | worker_processes 2 4 | working_directory "#{@app_path}/" 5 | preload_app true 6 | timeout 30 7 | listen "/var/run/unicorn.sock", :backlog => 64 8 | pid "/var/run/unicorn.pid" 9 | stderr_path "#{@app_path}/log/unicorn.stderr.log" 10 | stdout_path "#{@app_path}/log/unicorn.stdout.log" 11 | 12 | before_fork do |server, worker| 13 | defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect! 14 | old_pid = "#{server.config[:pid]}.oldbin" 15 | 16 | if old_pid != server.pid 17 | begin 18 | sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU 19 | Process.kill(sig, File.read(old_pid).to_i) 20 | rescue Errno::ENOENT, Errno::ESRCH 21 | end 22 | end 23 | sleep 1 24 | end 25 | 26 | after_fork do |server, worker| 27 | defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection 28 | end 29 | 30 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'pathname' 3 | 4 | # path to your application root. 5 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) 6 | 7 | Dir.chdir APP_ROOT do 8 | # This script is a starting point to setup your application. 9 | # Add necessary setup steps to this file: 10 | 11 | puts "== Installing dependencies ==" 12 | system "gem install bundler --conservative" 13 | system "bundle check || bundle install" 14 | 15 | # puts "\n== Copying sample files ==" 16 | # unless File.exist?("config/database.yml") 17 | # system "cp config/database.yml.sample config/database.yml" 18 | # end 19 | 20 | puts "\n== Preparing database ==" 21 | system "bin/rake db:setup" 22 | 23 | puts "\n== Removing old logs and tempfiles ==" 24 | system "rm -f log/*" 25 | system "rm -rf tmp/cache" 26 | 27 | puts "\n== Restarting application server ==" 28 | system "touch tmp/restart.txt" 29 | end 30 | -------------------------------------------------------------------------------- /config/application.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../boot', __FILE__) 2 | 3 | require 'rails/all' 4 | 5 | if defined?(Bundler) 6 | Bundler.require(*Rails.groups(assets: %w(development test))) 7 | end 8 | 9 | module DockerRailsExample 10 | class Application < Rails::Application 11 | config.paths.add File.join('app', 'jobs'), glob: File.join('**', '*.rb') 12 | config.autoload_paths += Dir[Rails.root.join('app', 'jobs', '*')] 13 | config.active_record.raise_in_transactional_callbacks = true 14 | config.active_job.queue_adapter = :sidekiq 15 | config.generators do|g| 16 | g.fixture = true 17 | g.fixture_replacement :factory_girl 18 | g.helper false 19 | g.integration_tool = false 20 | g.javascripts false 21 | g.stylesheets false 22 | g.template_engine :slim 23 | g.test_framework :rspec, view_specs: false, helper_specs: false, fixture: true 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /config/secrets.yml: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Your secret key is used for verifying the integrity of signed cookies. 4 | # If you change this key, all old signed cookies will become invalid! 5 | 6 | # Make sure the secret is at least 30 characters and all random, 7 | # no regular words or you'll be exposed to dictionary attacks. 8 | # You can use `rake secret` to generate a secure secret key. 9 | 10 | # Make sure the secrets in this file are kept private 11 | # if you're sharing your code publicly. 12 | 13 | development: 14 | secret_key_base: af484d71ee8caa6dfe1357afbe59152421633f5bd0a4c1d7585f908ca89b9c975b283ef5ab900e9ca1ee4372f544c1b6f9436b1318c060af3786bc3aff5ed038 15 | 16 | test: 17 | secret_key_base: 9f23a76d478a7c5b25a275e15e7a60217008f65f635b2d7e676a7170e238c0f96716bccc7a1a4c78291174282e0a08eb431ba8403a136768c9a257ee7d4cbd34 18 | 19 | # Do not keep production secrets in the repository, 20 | # instead read values from the environment. 21 | production: 22 | secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> 23 | -------------------------------------------------------------------------------- /script/run-server-spec.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -eu 3 | 4 | HASH=$(openssl rand -hex 4) 5 | DATABASE_URL=mysql2://root:dev@dev-mysql/docker-rails-example 6 | REDIS_URL=redis://dev-redis:6379/dev 7 | 8 | docker run \ 9 | -e DATABASE_URL="${DATABASE_URL}" \ 10 | -e REDIS_URL="${REDIS_URL}" \ 11 | --link dev-mysql:mysql \ 12 | --link dev-redis:redis \ 13 | --name "dbmigrate-${HASH}" \ 14 | -w /var/www/app -t $TARGET \ 15 | sh -c './bin/rake db:create; ./bin/rake db:migrate:reset' 16 | 17 | docker run \ 18 | -e DATABASE_URL="${DATABASE_URL}" \ 19 | -e REDIS_URL="${REDIS_URL}" \ 20 | -v "$(pwd)/docker/serverspec"\:/mnt/serverspec \ 21 | --name "serverspec-${HASH}" \ 22 | --link dev-mysql:mysql \ 23 | --link dev-redis:redis \ 24 | -w /mnt/serverspec -t $TARGET \ 25 | sh -c 'echo "DATABASE_URL=${DATABASE_URL}" >> /var/www/app/.env && echo "REDIS_URL=${REDIS_URL}" >> /var/www/app/.env && service supervisor start && bundle install --path=vendor/bundle && sleep 10 && bundle exec rake spec' 26 | 27 | set +eu 28 | [ $CI ] || docker rm "dbmigrate-${HASH}" 29 | [ $CI ] || docker rm "serverspec-${HASH}" 30 | -------------------------------------------------------------------------------- /docker/serverspec/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | diff-lcs (1.2.5) 5 | multi_json (1.11.2) 6 | net-scp (1.2.1) 7 | net-ssh (>= 2.6.5) 8 | net-ssh (2.9.2) 9 | net-telnet (0.1.1) 10 | rspec (3.3.0) 11 | rspec-core (~> 3.3.0) 12 | rspec-expectations (~> 3.3.0) 13 | rspec-mocks (~> 3.3.0) 14 | rspec-core (3.3.2) 15 | rspec-support (~> 3.3.0) 16 | rspec-expectations (3.3.1) 17 | diff-lcs (>= 1.2.0, < 2.0) 18 | rspec-support (~> 3.3.0) 19 | rspec-its (1.2.0) 20 | rspec-core (>= 3.0.0) 21 | rspec-expectations (>= 3.0.0) 22 | rspec-mocks (3.3.2) 23 | diff-lcs (>= 1.2.0, < 2.0) 24 | rspec-support (~> 3.3.0) 25 | rspec-support (3.3.0) 26 | serverspec (2.23.1) 27 | multi_json 28 | rspec (~> 3.0) 29 | rspec-its 30 | specinfra (~> 2.43) 31 | sfl (2.2) 32 | specinfra (2.43.1) 33 | net-scp 34 | net-ssh (~> 2.7) 35 | net-telnet 36 | sfl 37 | 38 | PLATFORMS 39 | ruby 40 | 41 | DEPENDENCIES 42 | serverspec 43 | 44 | BUNDLED WITH 45 | 1.10.6 46 | -------------------------------------------------------------------------------- /db/schema.rb: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | # This file is auto-generated from the current state of the database. Instead 3 | # of editing this file, please use the migrations feature of Active Record to 4 | # incrementally modify your database, and then regenerate this schema definition. 5 | # 6 | # Note that this schema.rb definition is the authoritative source for your 7 | # database schema. If you need to create the application database on another 8 | # system, you should be using db:schema:load, not running all the migrations 9 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations 10 | # you'll amass, the slower it'll run and the greater likelihood for issues). 11 | # 12 | # It's strongly recommended that you check this file into your version control system. 13 | 14 | ActiveRecord::Schema.define(version: 20150911082140) do 15 | 16 | create_table "books", force: :cascade do |t| 17 | t.string "title", limit: 255 18 | t.string "author", limit: 255 19 | t.datetime "created_at", null: false 20 | t.datetime "updated_at", null: false 21 | end 22 | 23 | end 24 | -------------------------------------------------------------------------------- /spec/routing/books_routing_spec.rb: -------------------------------------------------------------------------------- 1 | require "rails_helper" 2 | 3 | RSpec.describe BooksController, type: :routing do 4 | describe "routing" do 5 | 6 | it "routes to #index" do 7 | expect(:get => "/books").to route_to("books#index") 8 | end 9 | 10 | it "routes to #new" do 11 | expect(:get => "/books/new").to route_to("books#new") 12 | end 13 | 14 | it "routes to #show" do 15 | expect(:get => "/books/1").to route_to("books#show", :id => "1") 16 | end 17 | 18 | it "routes to #edit" do 19 | expect(:get => "/books/1/edit").to route_to("books#edit", :id => "1") 20 | end 21 | 22 | it "routes to #create" do 23 | expect(:post => "/books").to route_to("books#create") 24 | end 25 | 26 | it "routes to #update via PUT" do 27 | expect(:put => "/books/1").to route_to("books#update", :id => "1") 28 | end 29 | 30 | it "routes to #update via PATCH" do 31 | expect(:patch => "/books/1").to route_to("books#update", :id => "1") 32 | end 33 | 34 | it "routes to #destroy" do 35 | expect(:delete => "/books/1").to route_to("books#destroy", :id => "1") 36 | end 37 | 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /script/ecs-deploy-services.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -eu 3 | 4 | CLUSTER=default 5 | UPPER_ENV_NAME=$(echo $ENV_NAME | awk '{print toupper($0)}') 6 | DATABASE_URL=$(eval "echo \$DATABASE_URL_${UPPER_ENV_NAME}") 7 | REDIS_URL=$(eval "echo \$REDIS_URL_${UPPER_ENV_NAME}") 8 | APP_NAME='ngs-docker-rails-example-' 9 | TASK_FAMILY="${APP_NAME}${ENV_NAME}" 10 | SERVICE_NAME="${APP_NAME}service-${ENV_NAME}" 11 | 12 | REDIS_URL=$REDIS_URL DATABASE_URL=$DATABASE_URL \ 13 | erb ecs-task-definitions/service.json.erb > .ecs-task-definition.json 14 | TASK_DEFINITION_JSON=$(aws ecs register-task-definition --family $TASK_FAMILY --cli-input-json "file://$(pwd)/.ecs-task-definition.json") 15 | TASK_REVISION=$(echo $TASK_DEFINITION_JSON | jq .taskDefinition.revision) 16 | DESIRED_COUNT=$(aws ecs describe-services --services $SERVICE_NAME | jq '.services[0].desiredCount') 17 | 18 | if [ ${DESIRED_COUNT} = "0" ]; then 19 | DESIRED_COUNT="1" 20 | fi 21 | 22 | SERVICE_JSON=$(aws ecs update-service --cluster ${CLUSTER} --service ${SERVICE_NAME} --task-definition ${TASK_FAMILY}:${TASK_REVISION} --desired-count ${DESIRED_COUNT}) 23 | echo $SERVICE_JSON | jq . 24 | 25 | TASK_ARN=$(aws ecs list-tasks --cluster ${CLUSTER} --service ${SERVICE_NAME} | jq -r '.taskArns[0]') 26 | TASK_JSON=$(aws ecs stop-task --task ${TASK_ARN}) 27 | echo $TASK_JSON | jq . 28 | -------------------------------------------------------------------------------- /docker/files/etc/nginx/nginx.conf: -------------------------------------------------------------------------------- 1 | daemon off; 2 | user www-data; 3 | worker_processes 4; 4 | pid /run/nginx.pid; 5 | 6 | events { 7 | worker_connections 8000; 8 | } 9 | 10 | http { 11 | sendfile on; 12 | tcp_nopush on; 13 | keepalive_timeout 20; 14 | types_hash_max_size 2048; 15 | server_tokens off; 16 | include /etc/nginx/mime.types; 17 | default_type application/octet-stream; 18 | 19 | access_log /var/log/nginx/access.log; 20 | error_log /var/log/nginx/error.log; 21 | 22 | ## 23 | # Gzip Settings 24 | ## 25 | 26 | gzip on; 27 | gzip_disable "msie6"; 28 | gzip_comp_level 5; 29 | gzip_min_length 256; 30 | gzip_proxied any; 31 | gzip_vary on; 32 | gzip_buffers 16 8k; 33 | gzip_http_version 1.1; 34 | gzip_types text/plain text/css application/json application/javascript text/javascript; 35 | 36 | upstream unicorn { 37 | server unix:/var/run/unicorn.sock; 38 | } 39 | 40 | server { 41 | listen 80; 42 | root /var/www/app/public; 43 | client_max_body_size 50M; 44 | error_page 500 502 503 504 /50x.html; 45 | 46 | location = /50x.html { 47 | root html; 48 | } 49 | 50 | try_files $uri/index.html $uri @unicorn; 51 | 52 | location @unicorn { 53 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 54 | proxy_set_header Host $http_host; 55 | proxy_redirect off; 56 | proxy_pass http://unicorn; 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /ecs-task-definitions/service.json.erb: -------------------------------------------------------------------------------- 1 | { 2 | "family": "ngs-docker-rails-example-<%= ENV['ENV_NAME'] %>", 3 | "containerDefinitions": [ 4 | { 5 | "image": "<%= ENV['DOCKER_REPO'] %>:web-b<%= ENV['CIRCLE_BUILD_NUM'] %>", 6 | "name": "docker-rails-example-web", 7 | "cpu": 1, 8 | "memory": 128, 9 | "essential": true, 10 | "portMappings": [{ "hostPort": 80, "containerPort": 80, "protocol": "tcp" }], 11 | "mountPoints": [{ "containerPath": "/var/www/app/log", "sourceVolume": "log", "readOnly": false }], 12 | "environment": [ 13 | { "name": "DATABASE_URL", "value": "<%= ENV['DATABASE_URL'] %>" }, 14 | { "name": "REDIS_URL", "value": "<%= ENV['REDIS_URL'] %>" } 15 | ], 16 | "essential": true 17 | }, 18 | { 19 | "image": "<%= ENV['DOCKER_REPO'] %>:job-b<%= ENV['CIRCLE_BUILD_NUM'] %>", 20 | "name": "docker-rails-example-job", 21 | "cpu": 1, 22 | "memory": 128, 23 | "essential": true, 24 | "mountPoints": [{ "containerPath": "/var/www/app/log", "sourceVolume": "log", "readOnly": false }], 25 | "environment": [ 26 | { "name": "DATABASE_URL", "value": "<%= ENV['DATABASE_URL'] %>" }, 27 | { "name": "REDIS_URL", "value": "<%= ENV['REDIS_URL'] %>" } 28 | ], 29 | "essential": true 30 | } 31 | ], 32 | "volumes": [ 33 | { 34 | "name": "log", 35 | "host": { "sourcePath": "/var/log/rails" } 36 | } 37 | ] 38 | } 39 | -------------------------------------------------------------------------------- /docker/files/etc/init.d/sidekiq: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | TIMEOUT=${TIMEOUT-60} 6 | APP_ROOT=/var/www/app 7 | PID=/var/run/sidekiq.pid 8 | RAILS_ENV=production 9 | CMD="bin/sidekiq -C $APP_ROOT/config/sidekiq.yml -e $RAILS_ENV" 10 | action="$1" 11 | set -u 12 | 13 | old_pid="$PID.oldbin" 14 | 15 | cd $APP_ROOT || exit 1 16 | 17 | sig () { 18 | test -s "$PID" && kill -$1 `cat $PID` 19 | } 20 | 21 | oldsig () { 22 | test -s $old_pid && kill -$1 `cat $old_pid` 23 | } 24 | 25 | case $action in 26 | start) 27 | sig 0 && echo >&2 "Already running" && exit 0 28 | $CMD 29 | ;; 30 | stop) 31 | sig QUIT && rm -f ${PID} && exit 0 32 | echo >&2 "Not running" 33 | ;; 34 | force-stop) 35 | sig TERM && exit 0 36 | echo >&2 "Not running" 37 | ;; 38 | restart|reload) 39 | sig HUP && echo reloaded OK && exit 0 40 | echo >&2 "Couldn't reload, starting '$CMD' instead" 41 | $CMD 42 | ;; 43 | upgrade) 44 | if sig USR2 && sleep 2 && sig 0 && oldsig QUIT 45 | then 46 | n=$TIMEOUT 47 | while test -s $old_pid && test $n -ge 0 48 | do 49 | printf '.' && sleep 1 && n=$(( $n - 1 )) 50 | done 51 | echo 52 | 53 | if test $n -lt 0 && test -s $old_pid 54 | then 55 | echo >&2 "$old_pid still exists after $TIMEOUT seconds" 56 | exit 1 57 | fi 58 | exit 0 59 | fi 60 | echo >&2 "Couldn't upgrade, starting '$CMD' instead" 61 | $CMD 62 | ;; 63 | reopen-logs) 64 | sig USR1 65 | ;; 66 | *) 67 | echo >&2 "Usage: $0 " 68 | exit 1 69 | ;; 70 | esac 71 | -------------------------------------------------------------------------------- /docker/files/etc/init.d/unicorn: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | TIMEOUT=${TIMEOUT-60} 6 | APP_ROOT=/var/www/app 7 | PID=/var/run/unicorn.pid 8 | RAILS_ENV=production 9 | CMD="bin/unicorn_rails -c $APP_ROOT/config/unicorn.rb -E $RAILS_ENV" 10 | action="$1" 11 | set -u 12 | 13 | old_pid="$PID.oldbin" 14 | 15 | cd $APP_ROOT || exit 1 16 | 17 | sig () { 18 | test -s "$PID" && kill -$1 `cat $PID` 19 | } 20 | 21 | oldsig () { 22 | test -s $old_pid && kill -$1 `cat $old_pid` 23 | } 24 | 25 | case $action in 26 | start) 27 | sig 0 && echo >&2 "Already running" && exit 0 28 | $CMD 29 | ;; 30 | stop) 31 | sig QUIT && rm -f ${PID} && exit 0 32 | echo >&2 "Not running" 33 | ;; 34 | force-stop) 35 | sig TERM && exit 0 36 | echo >&2 "Not running" 37 | ;; 38 | restart|reload) 39 | sig HUP && echo reloaded OK && exit 0 40 | echo >&2 "Couldn't reload, starting '$CMD' instead" 41 | $CMD 42 | ;; 43 | upgrade) 44 | if sig USR2 && sleep 2 && sig 0 && oldsig QUIT 45 | then 46 | n=$TIMEOUT 47 | while test -s $old_pid && test $n -ge 0 48 | do 49 | printf '.' && sleep 1 && n=$(( $n - 1 )) 50 | done 51 | echo 52 | 53 | if test $n -lt 0 && test -s $old_pid 54 | then 55 | echo >&2 "$old_pid still exists after $TIMEOUT seconds" 56 | exit 1 57 | fi 58 | exit 0 59 | fi 60 | echo >&2 "Couldn't upgrade, starting '$CMD' instead" 61 | $CMD 62 | ;; 63 | reopen-logs) 64 | sig USR1 65 | ;; 66 | *) 67 | echo >&2 "Usage: $0 " 68 | exit 1 69 | ;; 70 | esac 71 | -------------------------------------------------------------------------------- /public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | We're sorry, but something went wrong (500) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

We're sorry, but something went wrong.

62 |
63 |

If you are the application owner check the logs for more information.

64 |
65 | 66 | 67 | -------------------------------------------------------------------------------- /config/environments/development.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # In the development environment your application's code is reloaded on 5 | # every request. This slows down response time but is perfect for development 6 | # since you don't have to restart the web server when you make code changes. 7 | config.cache_classes = false 8 | 9 | # Do not eager load code on boot. 10 | config.eager_load = false 11 | 12 | # Show full error reports and disable caching. 13 | config.consider_all_requests_local = true 14 | config.action_controller.perform_caching = false 15 | 16 | # Don't care if the mailer can't send. 17 | config.action_mailer.raise_delivery_errors = false 18 | 19 | # Print deprecation notices to the Rails logger. 20 | config.active_support.deprecation = :log 21 | 22 | # Raise an error on page load if there are pending migrations. 23 | config.active_record.migration_error = :page_load 24 | 25 | # Debug mode disables concatenation and preprocessing of assets. 26 | # This option may cause significant delays in view rendering with a large 27 | # number of complex assets. 28 | config.assets.debug = true 29 | 30 | # Asset digests allow you to set far-future HTTP expiration dates on all assets, 31 | # yet still be able to expire them through the digest params. 32 | config.assets.digest = true 33 | 34 | # Adds additional error checking when serving assets at runtime. 35 | # Checks for improperly declared sprockets dependencies. 36 | # Raises helpful error messages. 37 | config.assets.raise_runtime_errors = true 38 | 39 | # Raises error for missing translations 40 | # config.action_view.raise_on_missing_translations = true 41 | end 42 | -------------------------------------------------------------------------------- /public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The change you wanted was rejected (422) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The change you wanted was rejected.

62 |

Maybe you tried to change something you didn't have access to.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The page you were looking for doesn't exist (404) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The page you were looking for doesn't exist.

62 |

You may have mistyped the address or the page may have moved.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /docker/serverspec/spec/localhost/sidekiq_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'sidekiq', if: ENV['ROLE'] == 'job' do 4 | describe service('sidekiq') do 5 | it { is_expected.not_to be_enabled } 6 | it { is_expected.to be_running } 7 | it { is_expected.to be_running.under('supervisor') } 8 | end 9 | 10 | # TODO: run on web server 11 | # describe command(%q{curl -XPOST -H 'Content-Type: application/json' -d '{"book":{"title":"Hoge", "author":"ngs"}}' http://localhost/books/create_delayed}) do 12 | # its(:stdout) { is_expected.to contain 'HTTP/1.1 201 Created' } 13 | # its(:stdout) { is_expected.to match /{"arguments":\[{"title":"Hoge","author":"ngs"}\],"job_id":"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}","queue_name":"default"}/ } 14 | # end 15 | 16 | describe command(%q{cd $RAILS_ROOT && ./bin/rails runner -e production "p BooksJob.perform_later(author: 'ngs', title: 'Hoge')" 2>&1}) do 17 | after(:all) { sleep 5 } 18 | its(:exit_status) { is_expected.to eq 0 } 19 | its(:stdout) { is_expected.to match /#&1}) do 35 | its(:exit_status) { is_expected.to eq 0 } 36 | its(:stdout) { is_expected.to eq %Q{[["Hoge", "ngs"]]\n} } 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /config/database.yml: -------------------------------------------------------------------------------- 1 | # MySQL. Versions 5.0+ are recommended. 2 | # 3 | # Install the MYSQL driver 4 | # gem install mysql2 5 | # 6 | # Ensure the MySQL gem is defined in your Gemfile 7 | # gem 'mysql2' 8 | # 9 | # And be sure to use new-style password hashing: 10 | # http://dev.mysql.com/doc/refman/5.0/en/old-client.html 11 | # 12 | default: &default 13 | adapter: mysql2 14 | encoding: utf8 15 | pool: 5 16 | username: root 17 | password: 18 | socket: /tmp/mysql.sock 19 | 20 | development: 21 | <<: *default 22 | database: docker-rails-example_development 23 | 24 | # Warning: The database defined as "test" will be erased and 25 | # re-generated from your development database when you run "rake". 26 | # Do not set this db to the same as development or production. 27 | test: 28 | <<: *default 29 | database: docker-rails-example_test 30 | 31 | # As with config/secrets.yml, you never want to store sensitive information, 32 | # like your database password, in your source code. If your source code is 33 | # ever seen by anyone, they now have access to your database. 34 | # 35 | # Instead, provide the password as a unix environment variable when you boot 36 | # the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database 37 | # for a full rundown on how to provide these environment variables in a 38 | # production deployment. 39 | # 40 | # On Heroku and other platform providers, you may have a full connection URL 41 | # available as an environment variable. For example: 42 | # 43 | # DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase" 44 | # 45 | # You can use this database configuration with: 46 | # 47 | # production: 48 | # url: <%= ENV['DATABASE_URL'] %> 49 | # 50 | production: 51 | <<: *default 52 | database: docker-rails-example_production 53 | username: docker-rails-example 54 | password: <%= ENV['DOCKER-RAILS-EXAMPLE_DATABASE_PASSWORD'] %> 55 | -------------------------------------------------------------------------------- /config/environments/test.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # The test environment is used exclusively to run your application's 5 | # test suite. You never need to work with it otherwise. Remember that 6 | # your test database is "scratch space" for the test suite and is wiped 7 | # and recreated between test runs. Don't rely on the data there! 8 | config.cache_classes = true 9 | 10 | # Do not eager load code on boot. This avoids loading your whole application 11 | # just for the purpose of running a single test. If you are using a tool that 12 | # preloads Rails for running tests, you may have to set it to true. 13 | config.eager_load = false 14 | 15 | # Configure static file server for tests with Cache-Control for performance. 16 | config.serve_static_files = true 17 | config.static_cache_control = 'public, max-age=3600' 18 | 19 | # Show full error reports and disable caching. 20 | config.consider_all_requests_local = true 21 | config.action_controller.perform_caching = false 22 | 23 | # Raise exceptions instead of rendering exception templates. 24 | config.action_dispatch.show_exceptions = false 25 | 26 | # Disable request forgery protection in test environment. 27 | config.action_controller.allow_forgery_protection = false 28 | 29 | # Tell Action Mailer not to deliver emails to the real world. 30 | # The :test delivery method accumulates sent emails in the 31 | # ActionMailer::Base.deliveries array. 32 | config.action_mailer.delivery_method = :test 33 | 34 | # Randomize the order test cases are executed. 35 | config.active_support.test_order = :random 36 | 37 | # Print deprecation notices to the stderr. 38 | config.active_support.deprecation = :stderr 39 | 40 | # Raises error for missing translations 41 | # config.action_view.raise_on_missing_translations = true 42 | end 43 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails.application.routes.draw do 2 | resources :books do 3 | collection do 4 | post :create_delayed 5 | end 6 | end 7 | # The priority is based upon order of creation: first created -> highest priority. 8 | # See how all your routes lay out with "rake routes". 9 | 10 | # You can have the root of your site routed with "root" 11 | root 'welcome#index' 12 | 13 | # Example of regular route: 14 | # get 'products/:id' => 'catalog#view' 15 | 16 | # Example of named route that can be invoked with purchase_url(id: product.id) 17 | # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase 18 | 19 | # Example resource route (maps HTTP verbs to controller actions automatically): 20 | # resources :products 21 | 22 | # Example resource route with options: 23 | # resources :products do 24 | # member do 25 | # get 'short' 26 | # post 'toggle' 27 | # end 28 | # 29 | # collection do 30 | # get 'sold' 31 | # end 32 | # end 33 | 34 | # Example resource route with sub-resources: 35 | # resources :products do 36 | # resources :comments, :sales 37 | # resource :seller 38 | # end 39 | 40 | # Example resource route with more complex sub-resources: 41 | # resources :products do 42 | # resources :comments 43 | # resources :sales do 44 | # get 'recent', on: :collection 45 | # end 46 | # end 47 | 48 | # Example resource route with concerns: 49 | # concern :toggleable do 50 | # post 'toggle' 51 | # end 52 | # resources :posts, concerns: :toggleable 53 | # resources :photos, concerns: :toggleable 54 | 55 | # Example resource route within a namespace: 56 | # namespace :admin do 57 | # # Directs /admin/products/* to Admin::ProductsController 58 | # # (app/controllers/admin/products_controller.rb) 59 | # resources :products 60 | # end 61 | end 62 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'dotenv-rails' 4 | gem 'slim-rails' 5 | 6 | # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 7 | gem 'rails', '4.2.4' 8 | # Use mysql as the database for Active Record 9 | gem 'mysql2' 10 | # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 11 | gem 'jbuilder', '~> 2.0' 12 | # bundle exec rake doc:rails generates the API under doc/api. 13 | gem 'sdoc', '~> 0.4.0', group: :doc 14 | 15 | # Use ActiveModel has_secure_password 16 | # gem 'bcrypt', '~> 3.1.7' 17 | 18 | # Use Unicorn as the app server 19 | gem 'unicorn' 20 | gem 'sidekiq' 21 | 22 | # Use Capistrano for deployment 23 | # gem 'capistrano-rails', group: :development 24 | 25 | group :assets do 26 | # Use SCSS for stylesheets 27 | gem 'sass-rails', '~> 5.0' 28 | # Use Uglifier as compressor for JavaScript assets 29 | gem 'uglifier', '>= 1.3.0' 30 | # Use CoffeeScript for .coffee assets and views 31 | gem 'coffee-rails', '~> 4.1.0' 32 | # See https://github.com/rails/execjs#readme for more supported runtimes 33 | gem 'therubyracer', platforms: :ruby 34 | 35 | # Use jquery as the JavaScript library 36 | gem 'jquery-rails' 37 | # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks 38 | gem 'turbolinks' 39 | end 40 | 41 | group :development, :test do 42 | # Call 'byebug' anywhere in the code to stop execution and get a debugger console 43 | gem 'byebug' 44 | end 45 | 46 | group :test do 47 | # Circle CI parallelism & report 48 | gem 'rspec_junit_formatter', git: 'https://github.com/circleci/rspec_junit_formatter.git' 49 | gem 'spring-commands-rspec' 50 | gem 'rspec-rails' 51 | gem 'rspec-its' 52 | gem 'rspec-collection_matchers' 53 | gem 'guard-rspec' 54 | gem 'guard-shell' 55 | gem 'rb-fsevent', group: :darwin 56 | gem 'simplecov', require: false 57 | gem 'database_rewinder' 58 | gem 'timecop' 59 | end 60 | 61 | group :development do 62 | # Access an IRB console on exception pages or by using <%= console %> in views 63 | gem 'web-console', '~> 2.0' 64 | 65 | # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 66 | gem 'spring' 67 | end 68 | -------------------------------------------------------------------------------- /app/controllers/books_controller.rb: -------------------------------------------------------------------------------- 1 | class BooksController < ApplicationController 2 | before_action :set_book, only: [:show, :edit, :update, :destroy] 3 | protect_from_forgery :except => [:create_delayed] 4 | 5 | # GET /books 6 | # GET /books.json 7 | def index 8 | @books = Book.all 9 | end 10 | 11 | # GET /books/1 12 | # GET /books/1.json 13 | def show 14 | end 15 | 16 | # GET /books/new 17 | def new 18 | @book = Book.new 19 | end 20 | 21 | # GET /books/1/edit 22 | def edit 23 | end 24 | 25 | # POST /books 26 | # POST /books.json 27 | def create 28 | @book = Book.new(book_params) 29 | 30 | respond_to do |format| 31 | if @book.save 32 | format.html { redirect_to @book, notice: 'Book was successfully created.' } 33 | format.json { render :show, status: :created, location: @book } 34 | else 35 | format.html { render :new } 36 | format.json { render json: @book.errors, status: :unprocessable_entity } 37 | end 38 | end 39 | end 40 | 41 | def create_delayed 42 | @job = BooksJob.perform_later(book_params) 43 | render json: @job, status: :created 44 | end 45 | 46 | # PATCH/PUT /books/1 47 | # PATCH/PUT /books/1.json 48 | def update 49 | respond_to do |format| 50 | if @book.update(book_params) 51 | format.html { redirect_to @book, notice: 'Book was successfully updated.' } 52 | format.json { render :show, status: :ok, location: @book } 53 | else 54 | format.html { render :edit } 55 | format.json { render json: @book.errors, status: :unprocessable_entity } 56 | end 57 | end 58 | end 59 | 60 | # DELETE /books/1 61 | # DELETE /books/1.json 62 | def destroy 63 | @book.destroy 64 | respond_to do |format| 65 | format.html { redirect_to books_url, notice: 'Book was successfully destroyed.' } 66 | format.json { head :no_content } 67 | end 68 | end 69 | 70 | private 71 | # Use callbacks to share common setup or constraints between actions. 72 | def set_book 73 | @book = Book.find(params[:id]) 74 | end 75 | 76 | # Never trust parameters from the scary internet, only allow the white list through. 77 | def book_params 78 | params.require(:book).permit(:title, :author) 79 | end 80 | end 81 | -------------------------------------------------------------------------------- /circle.yml: -------------------------------------------------------------------------------- 1 | machine: 2 | timezone: UTC 3 | services: 4 | - docker 5 | ruby: 6 | version: 2.2.2 7 | environment: 8 | SPEC_OPTS: "--format documentation --color --format RspecJunitFormatter --out $CIRCLE_TEST_REPORTS/rspec/rspec.xml" 9 | DOCKER_REPO: quay.io/atsnngs/docker-rails-example 10 | pre: 11 | - "echo 'Host *' >> $HOME/.ssh/config" 12 | - "echo 'ForwardAgent yes' >> $HOME/.ssh/config" 13 | - "git config --global user.name 'Circle CI'" 14 | - "git config --global user.email 'circleci@ngs.io'" 15 | general: 16 | artifacts: 17 | - log 18 | dependencies: 19 | cache_directories: 20 | - ~/docker 21 | - docker/serverspec/vendor/bundle 22 | override: 23 | - sudo pip install awscli 24 | - sudo apt-get update && sudo apt-get install jq 25 | - bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3 26 | - docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS $DOCKER_REPO_HOST 27 | - docker info 28 | - docker pull ubuntu:14.04 29 | - docker pull redis 30 | - docker pull mysql 31 | - docker pull "${DOCKER_REPO}:web" 32 | - docker pull "${DOCKER_REPO}:job" 33 | - docker run --name dev-redis -d redis 34 | - docker run --name dev-mysql -e 'MYSQL_ROOT_PASSWORD=dev' -d mysql 35 | - docker ps 36 | - bin/rake assets:precompile 37 | - ROLE=web ./script/build-docker.sh 38 | - ROLE=job ./script/build-docker.sh 39 | - | 40 | docker run --name serverspec-bundle-install \ 41 | -v "$(pwd)/docker/serverspec"\:/mnt/serverspec \ 42 | -w /mnt/serverspec \ 43 | -t "${DOCKER_REPO}:job" \ 44 | bundle install --path=vendor/bundle 45 | test: 46 | override: 47 | - bin/rake spec 48 | - TARGET="${DOCKER_REPO}:web" script/run-server-spec.sh 49 | - TARGET="${DOCKER_REPO}:job" script/run-server-spec.sh 50 | post: 51 | - docker tag "${DOCKER_REPO}:web" "${DOCKER_REPO}:web-b${CIRCLE_BUILD_NUM}" 52 | - docker tag "${DOCKER_REPO}:job" "${DOCKER_REPO}:job-b${CIRCLE_BUILD_NUM}" 53 | - docker push "${DOCKER_REPO}:web-b${CIRCLE_BUILD_NUM}" 54 | - docker push "${DOCKER_REPO}:job-b${CIRCLE_BUILD_NUM}" 55 | deployment: 56 | master: 57 | branch: master 58 | commands: 59 | - docker push "${DOCKER_REPO}:web" 60 | - docker push "${DOCKER_REPO}:job" 61 | stages: 62 | branch: /deployment\/.*/ 63 | commands: 64 | - | 65 | export ENV_NAME=`echo $CIRCLE_BRANCH | sed 's/deployment\///'` && \ 66 | /bin/sh script/ecs-deploy-db-migrate.sh && \ 67 | sleep 5 && \ 68 | /bin/sh script/ecs-deploy-services.sh 69 | -------------------------------------------------------------------------------- /spec/rails_helper.rb: -------------------------------------------------------------------------------- 1 | # This file is copied to spec/ when you run 'rails generate rspec:install' 2 | ENV['RAILS_ENV'] ||= 'test' 3 | require File.expand_path('../../config/environment', __FILE__) 4 | # Prevent database truncation if the environment is production 5 | abort("The Rails environment is running in production mode!") if Rails.env.production? 6 | require 'spec_helper' 7 | require 'rspec/rails' 8 | # Add additional requires below this line. Rails is not loaded until this point! 9 | 10 | # Requires supporting ruby files with custom matchers and macros, etc, in 11 | # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are 12 | # run as spec files by default. This means that files in spec/support that end 13 | # in _spec.rb will both be required and run as specs, causing the specs to be 14 | # run twice. It is recommended that you do not name files matching this glob to 15 | # end with _spec.rb. You can configure this pattern with the --pattern 16 | # option on the command line or in ~/.rspec, .rspec or `.rspec-local`. 17 | # 18 | # The following line is provided for convenience purposes. It has the downside 19 | # of increasing the boot-up time by auto-requiring all files in the support 20 | # directory. Alternatively, in the individual `*_spec.rb` files, manually 21 | # require only the support files necessary. 22 | # 23 | # Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } 24 | 25 | # Checks for pending migrations before tests are run. 26 | # If you are not using ActiveRecord, you can remove this line. 27 | ActiveRecord::Migration.maintain_test_schema! 28 | 29 | RSpec.configure do |config| 30 | # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures 31 | config.fixture_path = "#{::Rails.root}/spec/fixtures" 32 | 33 | # If you're not using ActiveRecord, or you'd prefer not to run each of your 34 | # examples within a transaction, remove the following line or assign false 35 | # instead of true. 36 | config.use_transactional_fixtures = true 37 | 38 | # RSpec Rails can automatically mix in different behaviours to your tests 39 | # based on their file location, for example enabling you to call `get` and 40 | # `post` in specs under `spec/controllers`. 41 | # 42 | # You can disable this behaviour by removing the line below, and instead 43 | # explicitly tag your specs with their type, e.g.: 44 | # 45 | # RSpec.describe UsersController, :type => :controller do 46 | # # ... 47 | # end 48 | # 49 | # The different available types are documented in the features, such as in 50 | # https://relishapp.com/rspec/rspec-rails/docs 51 | config.infer_spec_type_from_file_location! 52 | end 53 | -------------------------------------------------------------------------------- /Dockerfile.erb: -------------------------------------------------------------------------------- 1 | FROM ubuntu:14.04 2 | MAINTAINER Atsushi Nagase 3 | 4 | RUN apt-get update -y && apt-get install -y software-properties-common 5 | RUN apt-add-repository -y ppa:nginx/stable 6 | RUN apt-add-repository -y ppa:brightbox/ruby-ng 7 | RUN apt-get update -y && apt-get install -y \ 8 | locales \ 9 | language-pack-en \ 10 | language-pack-en-base \ 11 | openssh-server \ 12 | curl \ 13 | supervisor \ 14 | build-essential \ 15 | git-core \ 16 | g++ \ 17 | libcurl4-openssl-dev \ 18 | libffi-dev \ 19 | libmysqlclient-dev \ 20 | libreadline-dev \ 21 | libsqlite3-dev \ 22 | libssl-dev \ 23 | libxml2 \ 24 | libxml2-dev \ 25 | libxslt1-dev \ 26 | libyaml-dev \ 27 | python-software-properties \ 28 | zlib1g-dev \ 29 | ruby2.2-dev \ 30 | ruby2.2 31 | 32 | ENV \ 33 | BUNDLE_PATH=/var/www/shared/vendor/bundle \ 34 | RAILS_ENV=production \ 35 | RAILS_ROOT=/var/www/app 36 | 37 | RUN gem install bundler --no-rdoc --no-ri 38 | RUN mkdir -p $RAILS_ROOT 39 | WORKDIR ${RAILS_ROOT} 40 | 41 | RUN (echo <%= `cat Gemfile`.inspect %> > "${RAILS_ROOT}/Gemfile") && (echo <%= `cat Gemfile.lock`.inspect %> > "${RAILS_ROOT}/Gemfile.lock") 42 | RUN mkdir -p $BUNDLE_PATH && \ 43 | mkdir -p vendor && \ 44 | rm -rf vendor/bundle && \ 45 | ln -s $BUNDLE_PATH vendor/bundle && \ 46 | (bundle check || bundle install --without test development darwin assets --jobs 4 --retry 3 --deployment) 47 | 48 | ## Locales 49 | RUN [ -f /var/lib/locales/supported.d/local ] || touch /var/lib/locales/supported.d/local 50 | RUN echo 'LANG="en_US.UTF-8"' > /etc/default/locale 51 | RUN dpkg-reconfigure --frontend noninteractive locales 52 | 53 | RUN echo <%= `cat docker/files/etc/supervisor/supervisord.conf`.inspect %> > /etc/supervisor/supervisord.conf 54 | 55 | <% if ENV['ROLE'] == 'web' %> 56 | RUN apt-get update -y && apt-get install -y nginx 57 | <% end %> 58 | 59 | COPY . $RAILS_ROOT 60 | WORKDIR ${RAILS_ROOT} 61 | 62 | RUN mkdir -p $BUNDLE_PATH && \ 63 | mkdir -p vendor && \ 64 | rm -rf vendor/bundle && \ 65 | ln -s $BUNDLE_PATH vendor/bundle && \ 66 | (bundle check || bundle install --without test development darwin assets --jobs 4 --retry 3 --deployment) && \ 67 | (echo "SECRET_KEY_BASE=$(./bin/rake secret)" > .env) 68 | 69 | ENV ROLE=<%= ENV['ROLE'] %> 70 | 71 | <% if ENV['ROLE'] == 'web' %> 72 | EXPOSE 80 73 | ADD docker/files/etc/supervisor/conf.d/nginx.conf /etc/supervisor/conf.d/nginx.conf 74 | ADD docker/files/etc/supervisor/conf.d/unicorn.conf /etc/supervisor/conf.d/unicorn.conf 75 | ADD docker/files/etc/nginx/nginx.conf /etc/nginx/nginx.conf 76 | ADD docker/files/etc/init.d/unicorn /etc/init.d/unicorn 77 | RUN chmod +x /etc/init.d/unicorn 78 | <% elsif ENV['ROLE'] == 'job' %> 79 | ADD docker/files/etc/supervisor/conf.d/sidekiq.conf /etc/supervisor/conf.d/sidekiq.conf 80 | ADD docker/files/etc/init.d/sidekiq /etc/init.d/sidekiq 81 | RUN chmod +x /etc/init.d/sidekiq 82 | <% end %> 83 | 84 | CMD ["/bin/sh", "/var/www/app/script/run-supervisord.sh"] 85 | -------------------------------------------------------------------------------- /config/environments/production.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # Code is not reloaded between requests. 5 | config.cache_classes = true 6 | 7 | # Eager load code on boot. This eager loads most of Rails and 8 | # your application in memory, allowing both threaded web servers 9 | # and those relying on copy on write to perform better. 10 | # Rake tasks automatically ignore this option for performance. 11 | config.eager_load = true 12 | 13 | # Full error reports are disabled and caching is turned on. 14 | config.consider_all_requests_local = false 15 | config.action_controller.perform_caching = true 16 | 17 | # Enable Rack::Cache to put a simple HTTP cache in front of your application 18 | # Add `rack-cache` to your Gemfile before enabling this. 19 | # For large-scale production use, consider using a caching reverse proxy like 20 | # NGINX, varnish or squid. 21 | # config.action_dispatch.rack_cache = true 22 | 23 | # Disable serving static files from the `/public` folder by default since 24 | # Apache or NGINX already handles this. 25 | config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? 26 | 27 | # Compress JavaScripts and CSS. 28 | config.assets.js_compressor = :uglifier 29 | # config.assets.css_compressor = :sass 30 | 31 | # Do not fallback to assets pipeline if a precompiled asset is missed. 32 | config.assets.compile = false 33 | 34 | # Asset digests allow you to set far-future HTTP expiration dates on all assets, 35 | # yet still be able to expire them through the digest params. 36 | config.assets.digest = true 37 | 38 | # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb 39 | 40 | # Specifies the header that your server uses for sending files. 41 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache 42 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX 43 | 44 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 45 | # config.force_ssl = true 46 | 47 | # Use the lowest log level to ensure availability of diagnostic information 48 | # when problems arise. 49 | config.log_level = :debug 50 | 51 | # Prepend all log lines with the following tags. 52 | # config.log_tags = [ :subdomain, :uuid ] 53 | 54 | # Use a different logger for distributed setups. 55 | # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) 56 | 57 | # Use a different cache store in production. 58 | # config.cache_store = :mem_cache_store 59 | 60 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 61 | # config.action_controller.asset_host = 'http://assets.example.com' 62 | 63 | # Ignore bad email addresses and do not raise email delivery errors. 64 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. 65 | # config.action_mailer.raise_delivery_errors = false 66 | 67 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 68 | # the I18n.default_locale when a translation cannot be found). 69 | config.i18n.fallbacks = true 70 | 71 | # Send deprecation notices to registered listeners. 72 | config.active_support.deprecation = :notify 73 | 74 | # Use default logging formatter so that PID and timestamp are not suppressed. 75 | config.log_formatter = ::Logger::Formatter.new 76 | 77 | # Do not dump schema after migrations. 78 | config.active_record.dump_schema_after_migration = false 79 | end 80 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # This file was generated by the `rails generate rspec:install` command. Conventionally, all 2 | # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. 3 | # The generated `.rspec` file contains `--require spec_helper` which will cause 4 | # this file to always be loaded, without a need to explicitly require it in any 5 | # files. 6 | # 7 | # Given that it is always loaded, you are encouraged to keep this file as 8 | # light-weight as possible. Requiring heavyweight dependencies from this file 9 | # will add to the boot time of your test suite on EVERY test run, even for an 10 | # individual file that may not need all of that loaded. Instead, consider making 11 | # a separate helper file that requires the additional dependencies and performs 12 | # the additional setup, and require it from the spec files that actually need 13 | # it. 14 | # 15 | # The `.rspec` file also contains a few flags that are not defaults but that 16 | # users commonly want. 17 | # 18 | # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration 19 | RSpec.configure do |config| 20 | # rspec-expectations config goes here. You can use an alternate 21 | # assertion/expectation library such as wrong or the stdlib/minitest 22 | # assertions if you prefer. 23 | config.expect_with :rspec do |expectations| 24 | # This option will default to `true` in RSpec 4. It makes the `description` 25 | # and `failure_message` of custom matchers include text for helper methods 26 | # defined using `chain`, e.g.: 27 | # be_bigger_than(2).and_smaller_than(4).description 28 | # # => "be bigger than 2 and smaller than 4" 29 | # ...rather than: 30 | # # => "be bigger than 2" 31 | expectations.include_chain_clauses_in_custom_matcher_descriptions = true 32 | end 33 | 34 | # rspec-mocks config goes here. You can use an alternate test double 35 | # library (such as bogus or mocha) by changing the `mock_with` option here. 36 | config.mock_with :rspec do |mocks| 37 | # Prevents you from mocking or stubbing a method that does not exist on 38 | # a real object. This is generally recommended, and will default to 39 | # `true` in RSpec 4. 40 | mocks.verify_partial_doubles = true 41 | end 42 | 43 | # The settings below are suggested to provide a good initial experience 44 | # with RSpec, but feel free to customize to your heart's content. 45 | =begin 46 | # These two settings work together to allow you to limit a spec run 47 | # to individual examples or groups you care about by tagging them with 48 | # `:focus` metadata. When nothing is tagged with `:focus`, all examples 49 | # get run. 50 | config.filter_run :focus 51 | config.run_all_when_everything_filtered = true 52 | 53 | # Allows RSpec to persist some state between runs in order to support 54 | # the `--only-failures` and `--next-failure` CLI options. We recommend 55 | # you configure your source control system to ignore this file. 56 | config.example_status_persistence_file_path = "spec/examples.txt" 57 | 58 | # Limits the available syntax to the non-monkey patched syntax that is 59 | # recommended. For more details, see: 60 | # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax 61 | # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ 62 | # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching 63 | config.disable_monkey_patching! 64 | 65 | # Many RSpec users commonly either run the entire suite or an individual 66 | # file, and it's useful to allow more verbose output when running an 67 | # individual spec file. 68 | if config.files_to_run.one? 69 | # Use the documentation formatter for detailed output, 70 | # unless a formatter has already been configured 71 | # (e.g. via a command-line flag). 72 | config.default_formatter = 'doc' 73 | end 74 | 75 | # Print the 10 slowest examples and example groups at the 76 | # end of the spec run, to help surface which specs are running 77 | # particularly slow. 78 | config.profile_examples = 10 79 | 80 | # Run specs in random order to surface order dependencies. If you find an 81 | # order dependency and want to debug it, you can fix the order by providing 82 | # the seed, which is printed after each run. 83 | # --seed 1234 84 | config.order = :random 85 | 86 | # Seed global randomization in this process using the `--seed` CLI option. 87 | # Setting this allows you to use `--seed` to deterministically reproduce 88 | # test failures related to randomization by passing the same `--seed` value 89 | # as the one that triggered the failure. 90 | Kernel.srand config.seed 91 | =end 92 | end 93 | -------------------------------------------------------------------------------- /spec/controllers/books_controller_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | # This spec was generated by rspec-rails when you ran the scaffold generator. 4 | # It demonstrates how one might use RSpec to specify the controller code that 5 | # was generated by Rails when you ran the scaffold generator. 6 | # 7 | # It assumes that the implementation code is generated by the rails scaffold 8 | # generator. If you are using any extension libraries to generate different 9 | # controller code, this generated spec may or may not pass. 10 | # 11 | # It only uses APIs available in rails and/or rspec-rails. There are a number 12 | # of tools you can use to make these specs even more expressive, but we're 13 | # sticking to rails and rspec-rails APIs to keep things simple and stable. 14 | # 15 | # Compared to earlier versions of this generator, there is very limited use of 16 | # stubs and message expectations in this spec. Stubs are only used when there 17 | # is no simpler way to get a handle on the object needed for the example. 18 | # Message expectations are only used when there is no simpler way to specify 19 | # that an instance is receiving a specific message. 20 | 21 | RSpec.describe BooksController, type: :controller do 22 | 23 | # This should return the minimal set of attributes required to create a valid 24 | # Book. As you add validations to Book, be sure to 25 | # adjust the attributes here as well. 26 | let(:valid_attributes) { 27 | skip("Add a hash of attributes valid for your model") 28 | } 29 | 30 | let(:invalid_attributes) { 31 | skip("Add a hash of attributes invalid for your model") 32 | } 33 | 34 | # This should return the minimal set of values that should be in the session 35 | # in order to pass any filters (e.g. authentication) defined in 36 | # BooksController. Be sure to keep this updated too. 37 | let(:valid_session) { {} } 38 | 39 | describe "GET #index" do 40 | it "assigns all books as @books" do 41 | book = Book.create! valid_attributes 42 | get :index, {}, valid_session 43 | expect(assigns(:books)).to eq([book]) 44 | end 45 | end 46 | 47 | describe "GET #show" do 48 | it "assigns the requested book as @book" do 49 | book = Book.create! valid_attributes 50 | get :show, {:id => book.to_param}, valid_session 51 | expect(assigns(:book)).to eq(book) 52 | end 53 | end 54 | 55 | describe "GET #new" do 56 | it "assigns a new book as @book" do 57 | get :new, {}, valid_session 58 | expect(assigns(:book)).to be_a_new(Book) 59 | end 60 | end 61 | 62 | describe "GET #edit" do 63 | it "assigns the requested book as @book" do 64 | book = Book.create! valid_attributes 65 | get :edit, {:id => book.to_param}, valid_session 66 | expect(assigns(:book)).to eq(book) 67 | end 68 | end 69 | 70 | describe "POST #create" do 71 | context "with valid params" do 72 | it "creates a new Book" do 73 | expect { 74 | post :create, {:book => valid_attributes}, valid_session 75 | }.to change(Book, :count).by(1) 76 | end 77 | 78 | it "assigns a newly created book as @book" do 79 | post :create, {:book => valid_attributes}, valid_session 80 | expect(assigns(:book)).to be_a(Book) 81 | expect(assigns(:book)).to be_persisted 82 | end 83 | 84 | it "redirects to the created book" do 85 | post :create, {:book => valid_attributes}, valid_session 86 | expect(response).to redirect_to(Book.last) 87 | end 88 | end 89 | 90 | context "with invalid params" do 91 | it "assigns a newly created but unsaved book as @book" do 92 | post :create, {:book => invalid_attributes}, valid_session 93 | expect(assigns(:book)).to be_a_new(Book) 94 | end 95 | 96 | it "re-renders the 'new' template" do 97 | post :create, {:book => invalid_attributes}, valid_session 98 | expect(response).to render_template("new") 99 | end 100 | end 101 | end 102 | 103 | describe "PUT #update" do 104 | context "with valid params" do 105 | let(:new_attributes) { 106 | skip("Add a hash of attributes valid for your model") 107 | } 108 | 109 | it "updates the requested book" do 110 | book = Book.create! valid_attributes 111 | put :update, {:id => book.to_param, :book => new_attributes}, valid_session 112 | book.reload 113 | skip("Add assertions for updated state") 114 | end 115 | 116 | it "assigns the requested book as @book" do 117 | book = Book.create! valid_attributes 118 | put :update, {:id => book.to_param, :book => valid_attributes}, valid_session 119 | expect(assigns(:book)).to eq(book) 120 | end 121 | 122 | it "redirects to the book" do 123 | book = Book.create! valid_attributes 124 | put :update, {:id => book.to_param, :book => valid_attributes}, valid_session 125 | expect(response).to redirect_to(book) 126 | end 127 | end 128 | 129 | context "with invalid params" do 130 | it "assigns the book as @book" do 131 | book = Book.create! valid_attributes 132 | put :update, {:id => book.to_param, :book => invalid_attributes}, valid_session 133 | expect(assigns(:book)).to eq(book) 134 | end 135 | 136 | it "re-renders the 'edit' template" do 137 | book = Book.create! valid_attributes 138 | put :update, {:id => book.to_param, :book => invalid_attributes}, valid_session 139 | expect(response).to render_template("edit") 140 | end 141 | end 142 | end 143 | 144 | describe "DELETE #destroy" do 145 | it "destroys the requested book" do 146 | book = Book.create! valid_attributes 147 | expect { 148 | delete :destroy, {:id => book.to_param}, valid_session 149 | }.to change(Book, :count).by(-1) 150 | end 151 | 152 | it "redirects to the books list" do 153 | book = Book.create! valid_attributes 154 | delete :destroy, {:id => book.to_param}, valid_session 155 | expect(response).to redirect_to(books_url) 156 | end 157 | end 158 | 159 | end 160 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GIT 2 | remote: https://github.com/circleci/rspec_junit_formatter.git 3 | revision: 6885218137afbadf560c922114767866953f8cbf 4 | specs: 5 | rspec_junit_formatter (0.2.0) 6 | builder (< 4) 7 | rspec (>= 2, < 4) 8 | rspec-core (!= 2.12.0) 9 | 10 | GEM 11 | remote: https://rubygems.org/ 12 | specs: 13 | actionmailer (4.2.4) 14 | actionpack (= 4.2.4) 15 | actionview (= 4.2.4) 16 | activejob (= 4.2.4) 17 | mail (~> 2.5, >= 2.5.4) 18 | rails-dom-testing (~> 1.0, >= 1.0.5) 19 | actionpack (4.2.4) 20 | actionview (= 4.2.4) 21 | activesupport (= 4.2.4) 22 | rack (~> 1.6) 23 | rack-test (~> 0.6.2) 24 | rails-dom-testing (~> 1.0, >= 1.0.5) 25 | rails-html-sanitizer (~> 1.0, >= 1.0.2) 26 | actionview (4.2.4) 27 | activesupport (= 4.2.4) 28 | builder (~> 3.1) 29 | erubis (~> 2.7.0) 30 | rails-dom-testing (~> 1.0, >= 1.0.5) 31 | rails-html-sanitizer (~> 1.0, >= 1.0.2) 32 | activejob (4.2.4) 33 | activesupport (= 4.2.4) 34 | globalid (>= 0.3.0) 35 | activemodel (4.2.4) 36 | activesupport (= 4.2.4) 37 | builder (~> 3.1) 38 | activerecord (4.2.4) 39 | activemodel (= 4.2.4) 40 | activesupport (= 4.2.4) 41 | arel (~> 6.0) 42 | activesupport (4.2.4) 43 | i18n (~> 0.7) 44 | json (~> 1.7, >= 1.7.7) 45 | minitest (~> 5.1) 46 | thread_safe (~> 0.3, >= 0.3.4) 47 | tzinfo (~> 1.1) 48 | arel (6.0.3) 49 | binding_of_caller (0.7.2) 50 | debug_inspector (>= 0.0.1) 51 | builder (3.2.2) 52 | byebug (6.0.2) 53 | celluloid (0.17.1.2) 54 | bundler 55 | celluloid-essentials 56 | celluloid-extras 57 | celluloid-fsm 58 | celluloid-pool 59 | celluloid-supervision 60 | dotenv 61 | nenv 62 | rspec-logsplit (>= 0.1.2) 63 | timers (>= 4.1.1) 64 | celluloid-essentials (0.20.2.1) 65 | bundler 66 | dotenv 67 | nenv 68 | rspec-logsplit (>= 0.1.2) 69 | timers (>= 4.1.1) 70 | celluloid-extras (0.20.1) 71 | bundler 72 | dotenv 73 | nenv 74 | rspec-logsplit (>= 0.1.2) 75 | timers (>= 4.1.1) 76 | celluloid-fsm (0.20.1) 77 | bundler 78 | dotenv 79 | nenv 80 | rspec-logsplit (>= 0.1.2) 81 | timers (>= 4.1.1) 82 | celluloid-pool (0.20.1) 83 | bundler 84 | dotenv 85 | nenv 86 | rspec-logsplit (>= 0.1.2) 87 | timers (>= 4.1.1) 88 | celluloid-supervision (0.20.1.1) 89 | bundler 90 | dotenv 91 | nenv 92 | rspec-logsplit (>= 0.1.2) 93 | timers (>= 4.1.1) 94 | coderay (1.1.0) 95 | coffee-rails (4.1.0) 96 | coffee-script (>= 2.2.0) 97 | railties (>= 4.0.0, < 5.0) 98 | coffee-script (2.4.1) 99 | coffee-script-source 100 | execjs 101 | coffee-script-source (1.9.1.1) 102 | connection_pool (2.2.0) 103 | database_rewinder (0.5.3) 104 | debug_inspector (0.0.2) 105 | diff-lcs (1.2.5) 106 | docile (1.1.5) 107 | dotenv (2.0.2) 108 | dotenv-rails (2.0.2) 109 | dotenv (= 2.0.2) 110 | railties (~> 4.0) 111 | erubis (2.7.0) 112 | execjs (2.6.0) 113 | ffi (1.9.10) 114 | formatador (0.2.5) 115 | globalid (0.3.6) 116 | activesupport (>= 4.1.0) 117 | guard (2.13.0) 118 | formatador (>= 0.2.4) 119 | listen (>= 2.7, <= 4.0) 120 | lumberjack (~> 1.0) 121 | nenv (~> 0.1) 122 | notiffany (~> 0.0) 123 | pry (>= 0.9.12) 124 | shellany (~> 0.0) 125 | thor (>= 0.18.1) 126 | guard-compat (1.2.1) 127 | guard-rspec (4.6.4) 128 | guard (~> 2.1) 129 | guard-compat (~> 1.1) 130 | rspec (>= 2.99.0, < 4.0) 131 | guard-shell (0.7.1) 132 | guard (>= 2.0.0) 133 | guard-compat (~> 1.0) 134 | hitimes (1.2.2) 135 | i18n (0.7.0) 136 | jbuilder (2.3.1) 137 | activesupport (>= 3.0.0, < 5) 138 | multi_json (~> 1.2) 139 | jquery-rails (4.0.5) 140 | rails-dom-testing (~> 1.0) 141 | railties (>= 4.2.0) 142 | thor (>= 0.14, < 2.0) 143 | json (1.8.3) 144 | kgio (2.9.3) 145 | libv8 (3.16.14.11) 146 | listen (3.0.3) 147 | rb-fsevent (>= 0.9.3) 148 | rb-inotify (>= 0.9) 149 | loofah (2.0.3) 150 | nokogiri (>= 1.5.9) 151 | lumberjack (1.0.9) 152 | mail (2.6.3) 153 | mime-types (>= 1.16, < 3) 154 | method_source (0.8.2) 155 | mime-types (2.6.1) 156 | mini_portile (0.6.2) 157 | minitest (5.8.0) 158 | multi_json (1.11.2) 159 | mysql2 (0.3.20) 160 | nenv (0.2.0) 161 | nokogiri (1.6.6.2) 162 | mini_portile (~> 0.6.0) 163 | notiffany (0.0.7) 164 | nenv (~> 0.1) 165 | shellany (~> 0.0) 166 | pry (0.10.1) 167 | coderay (~> 1.1.0) 168 | method_source (~> 0.8.1) 169 | slop (~> 3.4) 170 | rack (1.6.4) 171 | rack-test (0.6.3) 172 | rack (>= 1.0) 173 | rails (4.2.4) 174 | actionmailer (= 4.2.4) 175 | actionpack (= 4.2.4) 176 | actionview (= 4.2.4) 177 | activejob (= 4.2.4) 178 | activemodel (= 4.2.4) 179 | activerecord (= 4.2.4) 180 | activesupport (= 4.2.4) 181 | bundler (>= 1.3.0, < 2.0) 182 | railties (= 4.2.4) 183 | sprockets-rails 184 | rails-deprecated_sanitizer (1.0.3) 185 | activesupport (>= 4.2.0.alpha) 186 | rails-dom-testing (1.0.7) 187 | activesupport (>= 4.2.0.beta, < 5.0) 188 | nokogiri (~> 1.6.0) 189 | rails-deprecated_sanitizer (>= 1.0.1) 190 | rails-html-sanitizer (1.0.2) 191 | loofah (~> 2.0) 192 | railties (4.2.4) 193 | actionpack (= 4.2.4) 194 | activesupport (= 4.2.4) 195 | rake (>= 0.8.7) 196 | thor (>= 0.18.1, < 2.0) 197 | raindrops (0.13.0) 198 | rake (10.4.2) 199 | rb-fsevent (0.9.6) 200 | rb-inotify (0.9.5) 201 | ffi (>= 0.5.0) 202 | rdoc (4.2.0) 203 | redis (3.2.1) 204 | redis-namespace (1.5.2) 205 | redis (~> 3.0, >= 3.0.4) 206 | ref (2.0.0) 207 | rspec (3.3.0) 208 | rspec-core (~> 3.3.0) 209 | rspec-expectations (~> 3.3.0) 210 | rspec-mocks (~> 3.3.0) 211 | rspec-collection_matchers (1.1.2) 212 | rspec-expectations (>= 2.99.0.beta1) 213 | rspec-core (3.3.2) 214 | rspec-support (~> 3.3.0) 215 | rspec-expectations (3.3.1) 216 | diff-lcs (>= 1.2.0, < 2.0) 217 | rspec-support (~> 3.3.0) 218 | rspec-its (1.2.0) 219 | rspec-core (>= 3.0.0) 220 | rspec-expectations (>= 3.0.0) 221 | rspec-logsplit (0.1.3) 222 | rspec-mocks (3.3.2) 223 | diff-lcs (>= 1.2.0, < 2.0) 224 | rspec-support (~> 3.3.0) 225 | rspec-rails (3.3.3) 226 | actionpack (>= 3.0, < 4.3) 227 | activesupport (>= 3.0, < 4.3) 228 | railties (>= 3.0, < 4.3) 229 | rspec-core (~> 3.3.0) 230 | rspec-expectations (~> 3.3.0) 231 | rspec-mocks (~> 3.3.0) 232 | rspec-support (~> 3.3.0) 233 | rspec-support (3.3.0) 234 | sass (3.4.18) 235 | sass-rails (5.0.4) 236 | railties (>= 4.0.0, < 5.0) 237 | sass (~> 3.1) 238 | sprockets (>= 2.8, < 4.0) 239 | sprockets-rails (>= 2.0, < 4.0) 240 | tilt (>= 1.1, < 3) 241 | sdoc (0.4.1) 242 | json (~> 1.7, >= 1.7.7) 243 | rdoc (~> 4.0) 244 | shellany (0.0.1) 245 | sidekiq (3.5.0) 246 | celluloid (~> 0.17.0) 247 | connection_pool (~> 2.2, >= 2.2.0) 248 | json (~> 1.0) 249 | redis (~> 3.2, >= 3.2.1) 250 | redis-namespace (~> 1.5, >= 1.5.2) 251 | simplecov (0.10.0) 252 | docile (~> 1.1.0) 253 | json (~> 1.8) 254 | simplecov-html (~> 0.10.0) 255 | simplecov-html (0.10.0) 256 | slim (3.0.6) 257 | temple (~> 0.7.3) 258 | tilt (>= 1.3.3, < 2.1) 259 | slim-rails (3.0.1) 260 | actionmailer (>= 3.1, < 5.0) 261 | actionpack (>= 3.1, < 5.0) 262 | activesupport (>= 3.1, < 5.0) 263 | railties (>= 3.1, < 5.0) 264 | slim (~> 3.0) 265 | slop (3.6.0) 266 | spring (1.3.6) 267 | spring-commands-rspec (1.0.4) 268 | spring (>= 0.9.1) 269 | sprockets (3.3.4) 270 | rack (~> 1.0) 271 | sprockets-rails (2.3.2) 272 | actionpack (>= 3.0) 273 | activesupport (>= 3.0) 274 | sprockets (>= 2.8, < 4.0) 275 | temple (0.7.6) 276 | therubyracer (0.12.2) 277 | libv8 (~> 3.16.14.0) 278 | ref 279 | thor (0.19.1) 280 | thread_safe (0.3.5) 281 | tilt (2.0.1) 282 | timecop (0.8.0) 283 | timers (4.1.1) 284 | hitimes 285 | turbolinks (2.5.3) 286 | coffee-rails 287 | tzinfo (1.2.2) 288 | thread_safe (~> 0.1) 289 | uglifier (2.7.2) 290 | execjs (>= 0.3.0) 291 | json (>= 1.8.0) 292 | unicorn (4.9.0) 293 | kgio (~> 2.6) 294 | rack 295 | raindrops (~> 0.7) 296 | web-console (2.2.1) 297 | activemodel (>= 4.0) 298 | binding_of_caller (>= 0.7.2) 299 | railties (>= 4.0) 300 | sprockets-rails (>= 2.0, < 4.0) 301 | 302 | PLATFORMS 303 | ruby 304 | 305 | DEPENDENCIES 306 | byebug 307 | coffee-rails (~> 4.1.0) 308 | database_rewinder 309 | dotenv-rails 310 | guard-rspec 311 | guard-shell 312 | jbuilder (~> 2.0) 313 | jquery-rails 314 | mysql2 315 | rails (= 4.2.4) 316 | rb-fsevent 317 | rspec-collection_matchers 318 | rspec-its 319 | rspec-rails 320 | rspec_junit_formatter! 321 | sass-rails (~> 5.0) 322 | sdoc (~> 0.4.0) 323 | sidekiq 324 | simplecov 325 | slim-rails 326 | spring 327 | spring-commands-rspec 328 | therubyracer 329 | timecop 330 | turbolinks 331 | uglifier (>= 1.3.0) 332 | unicorn 333 | web-console (~> 2.0) 334 | 335 | BUNDLED WITH 336 | 1.10.6 337 | --------------------------------------------------------------------------------