Class: Contained::Task::Deploy

Inherits:
Base
  • Object
show all
Defined in:
lib/contained/task/deploy.rb

Overview

Examples:

Contained::Task::Deploy.execute(environment: "production", config: {})

Instance Method Summary collapse

Methods inherited from Base

execute!, #initialize

Constructor Details

This class inherits a constructor from Contained::Task::Base

Instance Method Details

#execute!Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/contained/task/deploy.rb', line 10

def execute!
  stack = @config.fetch("stack")
  username = ENV["DOCKER_LOGIN"]
  password = ENV["DOCKER_PASSWORD"]

  @stdout.puts("[deploy] stack=#{stack} environment=#{@environment}")

  on hosts, in: :sequence do
    execute(:docker, :login, "-u", username, "-p", password) if username && password

    execute(<<~BASH)
      source ./.contained/#{stack}/.env
      docker stack deploy -c ./.contained/#{stack}/compose.yml #{stack} --with-registry-auth
    BASH
  end
end