├── .gitignore ├── Dockerfile ├── Gemfile ├── Gemfile.lock ├── LICENSE ├── README.md ├── config.ru └── public ├── apple-touch-icon.png └── favicon.ico /.gitignore: -------------------------------------------------------------------------------- 1 | log/ 2 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ruby:2.3.1 2 | MAINTAINER Brian Morton "bmorton@yammer-inc.com" 3 | 4 | # Install dependencies for gems 5 | RUN apt-get update -y && apt-get -y install libpq-dev 6 | 7 | # Add and install gem dependencies 8 | ADD Gemfile /app/Gemfile 9 | ADD Gemfile.lock /app/Gemfile.lock 10 | RUN bash -l -c "cd /app && bundle install -j4" 11 | 12 | ADD . /app 13 | 14 | WORKDIR /app 15 | EXPOSE 8080 16 | 17 | CMD bundle exec puma -t ${PUMA_MIN_THREADS:-8}:${PUMA_MAX_THREADS:-12} -w ${PUMA_WORKERS:-1} -p 8080 -e ${RACK_ENV:-production} --preload 18 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gem "pg" 4 | gem "pghero" 5 | gem "puma", "~> 3.0" 6 | gem "rails", "~> 4.2" 7 | gem "rails_12factor", "~> 0.0.3" 8 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | actionmailer (4.2.7.1) 5 | actionpack (= 4.2.7.1) 6 | actionview (= 4.2.7.1) 7 | activejob (= 4.2.7.1) 8 | mail (~> 2.5, >= 2.5.4) 9 | rails-dom-testing (~> 1.0, >= 1.0.5) 10 | actionpack (4.2.7.1) 11 | actionview (= 4.2.7.1) 12 | activesupport (= 4.2.7.1) 13 | rack (~> 1.6) 14 | rack-test (~> 0.6.2) 15 | rails-dom-testing (~> 1.0, >= 1.0.5) 16 | rails-html-sanitizer (~> 1.0, >= 1.0.2) 17 | actionview (4.2.7.1) 18 | activesupport (= 4.2.7.1) 19 | builder (~> 3.1) 20 | erubis (~> 2.7.0) 21 | rails-dom-testing (~> 1.0, >= 1.0.5) 22 | rails-html-sanitizer (~> 1.0, >= 1.0.2) 23 | activejob (4.2.7.1) 24 | activesupport (= 4.2.7.1) 25 | globalid (>= 0.3.0) 26 | activemodel (4.2.7.1) 27 | activesupport (= 4.2.7.1) 28 | builder (~> 3.1) 29 | activerecord (4.2.7.1) 30 | activemodel (= 4.2.7.1) 31 | activesupport (= 4.2.7.1) 32 | arel (~> 6.0) 33 | activesupport (4.2.7.1) 34 | i18n (~> 0.7) 35 | json (~> 1.7, >= 1.7.7) 36 | minitest (~> 5.1) 37 | thread_safe (~> 0.3, >= 0.3.4) 38 | tzinfo (~> 1.1) 39 | arel (6.0.3) 40 | builder (3.2.2) 41 | concurrent-ruby (1.0.2) 42 | erubis (2.7.0) 43 | globalid (0.3.7) 44 | activesupport (>= 4.1.0) 45 | i18n (0.7.0) 46 | json (1.8.3) 47 | loofah (2.0.3) 48 | nokogiri (>= 1.5.9) 49 | mail (2.6.4) 50 | mime-types (>= 1.16, < 4) 51 | mime-types (3.1) 52 | mime-types-data (~> 3.2015) 53 | mime-types-data (3.2016.0521) 54 | mini_portile2 (2.1.0) 55 | minitest (5.9.1) 56 | nokogiri (1.6.8.1) 57 | mini_portile2 (~> 2.1.0) 58 | pg (0.19.0) 59 | pghero (1.6.2) 60 | activerecord 61 | puma (3.6.0) 62 | rack (1.6.5) 63 | rack-test (0.6.3) 64 | rack (>= 1.0) 65 | rails (4.2.7.1) 66 | actionmailer (= 4.2.7.1) 67 | actionpack (= 4.2.7.1) 68 | actionview (= 4.2.7.1) 69 | activejob (= 4.2.7.1) 70 | activemodel (= 4.2.7.1) 71 | activerecord (= 4.2.7.1) 72 | activesupport (= 4.2.7.1) 73 | bundler (>= 1.3.0, < 2.0) 74 | railties (= 4.2.7.1) 75 | sprockets-rails 76 | rails-deprecated_sanitizer (1.0.3) 77 | activesupport (>= 4.2.0.alpha) 78 | rails-dom-testing (1.0.7) 79 | activesupport (>= 4.2.0.beta, < 5.0) 80 | nokogiri (~> 1.6.0) 81 | rails-deprecated_sanitizer (>= 1.0.1) 82 | rails-html-sanitizer (1.0.3) 83 | loofah (~> 2.0) 84 | rails_12factor (0.0.3) 85 | rails_serve_static_assets 86 | rails_stdout_logging 87 | rails_serve_static_assets (0.0.5) 88 | rails_stdout_logging (0.0.5) 89 | railties (4.2.7.1) 90 | actionpack (= 4.2.7.1) 91 | activesupport (= 4.2.7.1) 92 | rake (>= 0.8.7) 93 | thor (>= 0.18.1, < 2.0) 94 | rake (11.3.0) 95 | sprockets (3.7.0) 96 | concurrent-ruby (~> 1.0) 97 | rack (> 1, < 3) 98 | sprockets-rails (3.2.0) 99 | actionpack (>= 4.0) 100 | activesupport (>= 4.0) 101 | sprockets (>= 3.0.0) 102 | thor (0.19.1) 103 | thread_safe (0.3.5) 104 | tzinfo (1.2.2) 105 | thread_safe (~> 0.1) 106 | 107 | PLATFORMS 108 | ruby 109 | 110 | DEPENDENCIES 111 | pg 112 | pghero 113 | puma (~> 3.0) 114 | rails (~> 4.2) 115 | rails_12factor (~> 0.0.3) 116 | 117 | BUNDLED WITH 118 | 1.11.2 119 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Brian Morton. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PgHero Solo 2 | 3 | This repository is a containerized, standalone instance of the excellent [PgHero engine](https://github.com/ankane/pghero). It allows you to pass a `DATABASE_URL` environment variable to run PgHero within Docker against your database without having to mount this inside your Rails application. It allows all the benefits of PgHero while allowing you to run a separate application instance safely behind your firewall without fear of accidently exposing it through your production Rails app. 4 | 5 | This strategy is used at [Yammer](https://www.yammer.com) to run PgHero against each of our different shards. 6 | 7 | This repository has an [automated build](https://registry.hub.docker.com/u/bmorton/pghero/) on the public Docker hub. To demo this and run it on OS X with boot2docker installed, you can connect to a Homebrew-installed Postgres instance like this: 8 | 9 | ``` 10 | docker run -ti -e DATABASE_URL=postgres://user@10.0.2.2:5432/myapp_development -p 8080:8080 bmorton/pghero 11 | ``` 12 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | Bundler.require 2 | require "securerandom" 3 | require "pghero/engine" 4 | require "rails_12factor" 5 | require "rails/all" 6 | 7 | class PGHeroSolo < Rails::Application 8 | routes.append do 9 | mount PgHero::Engine, at: ENV['MOUNTPOINT'] || "/" 10 | end 11 | 12 | config.cache_classes = true 13 | config.eager_load = true 14 | config.consider_all_requests_local = true 15 | config.secret_token = ENV['SECRET_KEY_BASE'] || SecureRandom.hex(30) 16 | end 17 | 18 | PGHeroSolo.initialize! 19 | run PGHeroSolo 20 | -------------------------------------------------------------------------------- /public/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmorton/pghero_solo/c383d4e442488245d07e49fedd87de05b32ff614/public/apple-touch-icon.png -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmorton/pghero_solo/c383d4e442488245d07e49fedd87de05b32ff614/public/favicon.ico --------------------------------------------------------------------------------