-
-
Save dylan/11d45cb1767629962c5f to your computer and use it in GitHub Desktop.
Sinatra Demo
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 | |
RUN apt-get install -y ruby rubygems git | |
RUN git clone https://gist.github.com/11d45cb1767629962c5f.git /opt/sinatra/ | |
RUN gem install bundler | |
EXPOSE :5000 | |
RUN cd /opt/sinatra && bundle install | |
CMD ["/usr/local/bin/foreman","start","-d","/opt/sinatra"] |
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' | |
gem 'sinatra' | |
gem 'foreman' |
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
web: bundle exec ruby server.rb |
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 'sinatra' | |
#Bound to this address so that external hosts can access it, VERY IMPORTANT! | |
set :bind, '0.0.0.0' | |
set :logging, true | |
get '/' do | |
'hello world' | |
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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
# | |
require 'json' | |
Vagrant::Config.run do |config| | |
config.vm.box = "raring" | |
config.vm.box_url = "http://cloud-images.ubuntu.com/raring/current/raring-server-cloudimg-vagrant-amd64-disk1.box" | |
config.vm.forward_port 5000, 5000 | |
config.vm.customize [ | |
"modifyvm", :id, | |
"--memory", 512 | |
] | |
# Check if a vm has been provisioned yet | |
if File.exists?".vagrant" | |
vagrant_file = JSON.load(IO.read('.vagrant')) | |
end | |
if vagrant_file.nil? or !vagrant_file['active'].has_key?('default') | |
# I broke out each command here so we can see exactly what occurs | |
# We're gonna use this a few times | |
apt_update = "apt-get update;" | |
# Shortcut in case we need it | |
restart = "shutdown -r +1;" | |
# Install aufs | |
aufs_supp = "apt-get install linux-image-extra-`uname -r` dkms -y;" | |
# Add the repo key so we can grab 0.6 | |
add_docker_repo_key = "sudo sh -c \"curl http://get.docker.io/gpg | apt-key add -\";" | |
# Add the repo for the Docker packages | |
add_docker_repo = "sudo sh -c \"echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list\";" | |
# Install Docker | |
install_docker = "apt-get install -q -y --force-yes lxc-docker;" | |
# Put it all together, | |
icmd = "#{apt_update} "\ | |
"#{aufs_supp} "\ | |
"#{add_docker_repo} "\ | |
"#{add_docker_repo_key}"\ | |
"#{apt_update} "\ | |
"#{install_docker}" | |
# And run it. | |
config.vm.provision :shell, :inline => icmd | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment