Module: Deploy::Commands

Includes:
Utility
Included in:
Runner
Defined in:
lib/deploy/commands.rb

Instance Method Summary collapse

Methods included from Utility

#command?

Instance Method Details

#build_image(repo, tag) ⇒ Object



7
8
9
10
11
# File 'lib/deploy/commands.rb', line 7

def build_image(repo, tag)
  shout "Building Docker Image: #{repo}:#{tag}"
  command = "docker build -t #{repo}:#{tag} ."
  exit(1) unless system(command)
end

#create_deploy_zip_fileObject



13
14
15
16
17
18
19
20
21
# File 'lib/deploy/commands.rb', line 13

def create_deploy_zip_file
  # to create the archive correctly we must set up a fake git user
  shout "Creating fake local git user"
  system "git config user.name 'deploy'; git config user.email 'deploy'"

  shout "Creating deploy.zip"
  command = "uploadStash=`git stash create`; git archive -o deploy.zip ${uploadStash:-HEAD}"
  exit(1) unless system(command)
end

#pull_image(repo, tag) ⇒ Object



35
36
37
38
39
# File 'lib/deploy/commands.rb', line 35

def pull_image(repo, tag)
  shout "Pulling Docker Image: #{repo}:#{tag}"
  command = "docker pull #{repo}:#{tag}"
  exit(1) unless system(command)
end

#push_image(repo, tag) ⇒ Object



29
30
31
32
33
# File 'lib/deploy/commands.rb', line 29

def push_image(repo, tag)
  shout "Pushing Docker Image: #{repo}:#{tag}"
  command = "docker push #{repo}:#{tag}"
  exit(1) unless system(command)
end

#run_deploy(version, environment) ⇒ Object



41
42
43
44
45
# File 'lib/deploy/commands.rb', line 41

def run_deploy(version, environment)
  command = "eb deploy #{environment} --label #{version}"
  shout "deploying #{version} to elastic beanstalk with command: #{command}"
  exit(1) unless system(command)
end

#run_rollback(version, environment) ⇒ Object



47
48
49
50
51
# File 'lib/deploy/commands.rb', line 47

def run_rollback(version, environment)
  command = "eb deploy #{environment} --version #{version}"
  shout "deploying #{version} to elastic beanstalk with command: #{command}"
  exit(1) unless system(command)
end

#use_tag_in_dockerrun(repo, tag) ⇒ Object



23
24
25
26
27
# File 'lib/deploy/commands.rb', line 23

def use_tag_in_dockerrun(repo, tag)
  shout "Changing Dockerrun.aws.json to contain latest tag"
  command = "sed 's/<TAG>/#{tag}/' < Dockerrun.aws.json.template > Dockerrun.aws.json"
  exit(1) unless system(command)
end