class Stax::Docker

Public Instance Methods

build() click to toggle source
# File lib/stax/docker.rb, line 52
def build
  docker_build
end
docker_build() click to toggle source

build a docker image locally

# File lib/stax/docker.rb, line 23
def docker_build
  debug("Docker build #{docker_image}")
  system "docker build -t #{docker_image} #{Git.toplevel}"
end
docker_image() click to toggle source

full image name for docker push

# File lib/stax/docker.rb, line 18
def docker_image
  @_docker_image ||= "#{docker_registry}/#{docker_repository}"
end
docker_push() click to toggle source

push docker image from local

# File lib/stax/docker.rb, line 29
def docker_push
  debug("Docker push #{docker_image}")
  system "docker push #{docker_image}"
end
docker_registry() click to toggle source

default to ECR registry for this account

# File lib/stax/docker.rb, line 8
def docker_registry
  @_docker_registry ||= "#{aws_account_id}.dkr.ecr.#{aws_region}.amazonaws.com"
end
docker_repository() click to toggle source

name the docker repo after the git repo

# File lib/stax/docker.rb, line 13
def docker_repository
  @_docker_repository ||= File.basename(Git.toplevel)
end
exists() click to toggle source
# File lib/stax/docker.rb, line 71
def exists
  puts Aws::Ecr.exists?(docker_repository, Git.sha)
end
image() click to toggle source
# File lib/stax/docker.rb, line 46
def image
  puts docker_image
end
login() click to toggle source
# File lib/stax/docker.rb, line 57
def login
  Aws::Ecr.auth.each do |auth|
    debug("Login to ECR registry #{auth.proxy_endpoint}")
    user, pass = Base64.decode64(auth.authorization_token).split(':')
    system "docker login -u #{user} -p #{pass} #{auth.proxy_endpoint}"
  end
end
poll() click to toggle source
# File lib/stax/docker.rb, line 76
def poll
  debug("Waiting for image in ECR #{docker_repository}:#{Git.sha}")
  sleep 10 until Aws::Ecr.exists?(docker_repository, Git.sha)
end
push() click to toggle source
# File lib/stax/docker.rb, line 66
def push
  docker_push
end
registry() click to toggle source
# File lib/stax/docker.rb, line 36
def registry
  puts docker_registry
end
repository() click to toggle source
# File lib/stax/docker.rb, line 41
def repository
  puts docker_repository
end