Skip to content

Commit 64ebaf0

Browse files
author
Administrator
committed
Containerizing
1 parent 97df60c commit 64ebaf0

File tree

5 files changed

+71
-0
lines changed

5 files changed

+71
-0
lines changed

Dockerfile

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM stackbrew/ubuntu:saucy
2+
MAINTAINER Richard Kent Jordan <[email protected]>
3+
4+
RUN echo "deb http://archive.ubuntu.com/ubuntu saucy main universe" > /etc/apt/sources.list
5+
RUN apt-get update
6+
RUN apt-get upgrade -y
7+
8+
RUN apt-get install -y build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config libpq5 libpq-dev libcurl4-gnutls-dev python-software-properties libffi-dev libgdbm-dev nodejs ruby2.0 ruby2.0-dev
9+
RUN gem update --system
10+
RUN gem install bundler
11+
12+
ADD . /app
13+
14+
ENV RAILS_ENV production
15+
WORKDIR /app
16+
RUN bundle install --without development test
17+
RUN rake tmp:create
18+
RUN rake assets:precompile
19+
20+
#Rails (Must set production.rb to serve static assets)
21+
EXPOSE 3000
22+
CMD foreman start
23+

Gemfile

+2
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,5 @@ end
5858

5959
#gem 'spine-rails'
6060
gem 'smt_rails'
61+
gem 'unicorn-rails'
62+
gem 'foreman'

Gemfile.lock

+15
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ GEM
6363
rails (~> 3.0)
6464
daemons (1.1.9)
6565
diff-lcs (1.2.4)
66+
dotenv (0.9.0)
6667
erubis (2.7.0)
6768
eventmachine (1.0.3)
6869
execjs (1.4.0)
@@ -75,6 +76,9 @@ GEM
7576
faye-websocket (0.4.7)
7677
eventmachine (>= 0.12.0)
7778
ffi (1.8.1)
79+
foreman (0.63.0)
80+
dotenv (>= 0.7)
81+
thor (>= 0.13.6)
7882
formatador (0.2.4)
7983
gherkin (2.12.0)
8084
multi_json (~> 1.3)
@@ -112,6 +116,7 @@ GEM
112116
railties (>= 3.0, < 5.0)
113117
thor (>= 0.14, < 2.0)
114118
json (1.8.0)
119+
kgio (2.8.1)
115120
libv8 (3.11.8.17)
116121
listen (1.1.2)
117122
rb-fsevent (>= 0.9.3)
@@ -169,6 +174,7 @@ GEM
169174
rake (>= 0.8.7)
170175
rdoc (~> 3.4)
171176
thor (>= 0.14.6, < 2.0)
177+
raindrops (0.12.0)
172178
rake (10.0.4)
173179
rb-fsevent (0.9.3)
174180
rb-inotify (0.9.0)
@@ -230,6 +236,13 @@ GEM
230236
uglifier (2.1.1)
231237
execjs (>= 0.3.0)
232238
multi_json (~> 1.0, >= 1.0.2)
239+
unicorn (4.7.0)
240+
kgio (~> 2.6)
241+
rack
242+
raindrops (~> 0.7)
243+
unicorn-rails (1.1.0)
244+
rack
245+
unicorn
233246
wirble (0.1.3)
234247
xpath (2.0.0)
235248
nokogiri (~> 1.3)
@@ -244,6 +257,7 @@ DEPENDENCIES
244257
coffee-rails (~> 3.2.1)
245258
cucumber-rails
246259
factory_girl_rails
260+
foreman
247261
guard-jasmine
248262
guard-rspec
249263
guard-spork
@@ -264,4 +278,5 @@ DEPENDENCIES
264278
thin
265279
turn
266280
uglifier (>= 1.0.3)
281+
unicorn-rails
267282
wirble

Procfile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: bundle exec unicorn -c config/unicorn.rb

config/unicorn.rb

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# config/unicorn.rb
2+
rails_env = ENV['RAILS_ENV'] || 'production'
3+
rails_root = `pwd`.gsub("\n", "")
4+
5+
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3)
6+
timeout 15
7+
preload_app true
8+
listen 3000
9+
pid "#{rails_root}/tmp/pids/unicorn.pid"
10+
#stderr_path "#{rails_root}/log/unicorn.log"
11+
#stdout_path "#{rails_root}/log/unicorn.log"
12+
13+
before_fork do |server, worker|
14+
Signal.trap 'TERM' do
15+
puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
16+
Process.kill 'QUIT', Process.pid
17+
end
18+
19+
defined?(ActiveRecord::Base) and
20+
ActiveRecord::Base.connection.disconnect!
21+
end
22+
23+
after_fork do |server, worker|
24+
Signal.trap 'TERM' do
25+
puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT'
26+
end
27+
28+
defined?(ActiveRecord::Base) and
29+
ActiveRecord::Base.establish_connection
30+
end

0 commit comments

Comments
 (0)