Last active
January 2, 2016 22:39
-
-
Save rds13/8370995 to your computer and use it in GitHub Desktop.
Docker Sinatra Unicorn playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'sinatra' | |
class App < Sinatra::Application | |
get %r{/.*} do | |
puts "A request has arrived #{params.inspect}" | |
response = "Hello" | |
puts "Response is #{response}" | |
return response | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rubygems" | |
require "sinatra" | |
require File.join( File.dirname(__FILE__), 'app.rb') | |
run App |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# | |
FROM ubuntu:latest | |
RUN apt-get update | |
RUN apt-get install -y ruby1.9.1 rubygems git | |
RUN apt-get clean | |
RUN gem install bundler | |
RUN locale-gen en_US en_US.UTF-8 | |
EXPOSE 8080 | |
RUN git clone https://gist.github.com/8370995.git /opt/sinatra/ | |
RUN cd /opt/sinatra && bundle install | |
WORKDIR /opt/sinatra | |
CMD ["unicorn","-d","-c", "unicorn.conf"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
#ruby '2.0.0' | |
gem 'sinatra' | |
gem 'unicorn' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# set path to app that will be used to configure unicorn, | |
# note the trailing slash in this example | |
@dir = File.join(File.dirname(__FILE__),"") | |
@tmp = File.join(@dir,"tmp") | |
Dir.exists?(@tmp) || Dir.mkdir(@tmp) | |
worker_processes 2 | |
working_directory @dir | |
timeout 30 | |
# Specify path to socket unicorn listens to | |
listen "0.0.0.0:8080", :backlog => 64 | |
# Set process id path | |
pid File.join(@tmp, "unicorn.pid") | |
# Set log file paths | |
stderr_path File.join(@tmp, "unicorn.stderr.log") | |
stdout_path File.join(@tmp, "unicorn.stdout.log") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment