Class: Fastlane::Actions::DockerComposeAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/docker/actions/docker_compose.rb

Class Method Summary collapse

Class Method Details

.authorsObject



50
51
52
# File 'lib/fastlane/plugin/docker/actions/docker_compose.rb', line 50

def self.authors
  ["hjanuschka"]
end

.available_optionsObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fastlane/plugin/docker/actions/docker_compose.rb', line 24

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :files,
                                 description: "Compose files",
                                 env_name: "DOCKER_BUILD_COMPOSE_FILES",
                                 is_string: false,
                                 optional: true,
                                 type: Array),
    FastlaneCore::ConfigItem.new(key: :command,
                                 description: "Compose command (up, down, pull ....)",
                                 default_value: "log",
                                 optional: false,
                                 env_name: "DOCKER_COMPOSE_COMMAND"),
    FastlaneCore::ConfigItem.new(key: :detach,
                                 description: "Detach on run",
                                 optional: true,
                                 is_string: false,
                                 default_value: true,
                                 env_name: "DOCKER_COMPOSE_DETACH"),
    FastlaneCore::ConfigItem.new(key: :project,
                                 description: "Compose project name",
                                 optional: true,
                                 env_name: "DOCKER_COMPOSE_PROJECT")
  ]
end

.descriptionObject



20
21
22
# File 'lib/fastlane/plugin/docker/actions/docker_compose.rb', line 20

def self.description
  "Define and run multi-container applications with Docker"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/fastlane/plugin/docker/actions/docker_compose.rb', line 54

def self.is_supported?(platform)
  true
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fastlane/plugin/docker/actions/docker_compose.rb', line 4

def self.run(params)
  unless `which docker-compose`.include?("docker-compose")
    UI.error("docker-compose was not found")
    UI.error("please read the following https://docs.docker.com/compose/install/ on how to install it.")
    UI.user_error!("docker-compose not installed")
  end

  command = "docker-compose "
  command << params[:files].map { |item| " -f " + item }.join + " " if params[:files]
  command << "--project-name {params[:project].shellescape} " if params[:project]
  command << params[:command]
  command << " -d " if params[:command] == "up" && params[:detach]

  Actions.sh command, log: true
end