Last active
August 29, 2015 13:55
-
-
Save lmars/8708967 to your computer and use it in GitHub Desktop.
Docker Deployer
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
class Deployer | |
attr_accessor :current_id | |
attr_reader :image | |
def initalize(image) | |
@image = image | |
end | |
def start | |
self.current_id = run "docker run #{image}" | |
end | |
def stop | |
run "docker stop #{current_id}" | |
end | |
def pull | |
run "docker pull #{image}" | |
end | |
def deploy | |
pull | |
stop | |
start | |
end | |
end | |
deployer = Deployer.new("lmars/app") | |
deployer.start | |
trap("USR2") { deployer.deploy } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment