Skip to content

Instantly share code, notes, and snippets.

@rds13
Last active January 2, 2016 22:39
Show Gist options
  • Save rds13/8370995 to your computer and use it in GitHub Desktop.
Save rds13/8370995 to your computer and use it in GitHub Desktop.
Docker Sinatra Unicorn playground
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
require "rubygems"
require "sinatra"
require File.join( File.dirname(__FILE__), 'app.rb')
run App
#
#
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"]
source 'https://rubygems.org'
#ruby '2.0.0'
gem 'sinatra'
gem 'unicorn'
# 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