module Indocker

Constants

VERSION

Public Class Methods

add_artifact(artifact) click to toggle source
# File lib/indocker.rb, line 158
def add_artifact(artifact)
  artifacts.push(artifact)
end
add_build_server(build_server) click to toggle source
# File lib/indocker.rb, line 241
def add_build_server(build_server)
  if !build_server.is_a?(Indocker::BuildServer)
    raise ArgumentError.new("should be an instance of Indocker::BuildServer, got: #{build_server.inspect}")
  end

  existing = build_servers.detect {|s| s == build_server}

  if existing
    raise ArgumentError.new("build server with name #{build_server.name} was already defined")
  end

  build_servers.push(build_server)
end
add_registry(registry) click to toggle source
# File lib/indocker.rb, line 170
def add_registry(registry)
  if !registry.is_a?(Indocker::Registries::Abstract)
    raise ArgumentError.new("should be an instance of Indocker::Registries::Abstract, got: #{registry.inspect}")
  end

  registries.push(registry)
end
add_repository(repository) click to toggle source
# File lib/indocker.rb, line 162
def add_repository(repository)
  if !repository.is_a?(Indocker::Repositories::Abstract)
    raise ArgumentError.new("should be an instance of Indocker::Repositories::Abstract, got: #{repository.inspect}")
  end

  repositories.push(repository)
end
add_server(server) click to toggle source
# File lib/indocker.rb, line 178
def add_server(server)
  if !server.is_a?(Indocker::Server)
    raise ArgumentError.new("should be an instance of Indocker::Server, got: #{server.inspect}")
  end

  existing = servers.detect {|s| s == server}

  if existing
    raise ArgumentError.new("server with name #{server.name} was already defined")
  end

  servers.push(server)
end
artifacts() click to toggle source
# File lib/indocker.rb, line 275
def artifacts
  @artifacts ||= []
end
build_configuration(name) click to toggle source
# File lib/indocker.rb, line 299
def build_configuration(name)
  builder = Indocker::Configurations::ConfigurationBuilder.new(
    name: name,
    repositories: repositories,
    registries: registries,
    servers: servers,
    build_servers: build_servers,
    volumes: volumes,
    networks: networks,
    env_files: env_files,
    containers: containers,
  )

  @configuration = builder.configuration
  builder
end
build_helper(&proc) click to toggle source
# File lib/indocker.rb, line 453
def build_helper(&proc)
  Indocker::BuildContextHelper.class_exec(&proc)
end
build_servers() click to toggle source
# File lib/indocker.rb, line 279
def build_servers
  @build_servers ||= []
end
check(servers: []) click to toggle source
# File lib/indocker.rb, line 373
def check(servers: [])
  Indocker::DeploymentChecker
    .new(Indocker.logger)
    .run(
      configuration: configuration,
      servers: servers,
    )
end
compile(images:, skip_dependent:) click to toggle source
# File lib/indocker.rb, line 393
def compile(images:, skip_dependent:)
  Indocker::Launchers::ImagesCompiler
    .new(Indocker.logger)
    .compile(
      configuration: configuration,
      image_list: images,
      skip_dependent: skip_dependent,
    )
end
configuration() click to toggle source
# File lib/indocker.rb, line 287
def configuration
  @configuration || (raise ArgumentError.new("no configuration provided"))
end
configuration_name() click to toggle source
# File lib/indocker.rb, line 461
def configuration_name
  @configuration_name || (raise ArgumentError.new("configuration was not specified"))
end
container_files() click to toggle source
# File lib/indocker.rb, line 200
def container_files
  @container_files || (raise ArgumentError.new("container files were not found. Set bounded contexts dir"))
end
containers() click to toggle source
# File lib/indocker.rb, line 295
def containers
  @containers ||= []
end
define_container(name) click to toggle source
# File lib/indocker.rb, line 335
def define_container(name)
  builder = Indocker::Containers::ContainerBuilder.new(
    name: name,
    configuration: configuration,
  )

  containers.push(builder.container)
  builder
end
define_env_file(env_file) click to toggle source
# File lib/indocker.rb, line 224
def define_env_file(env_file)
  if env_files.detect {|ef| ef.name == env_file.name}
    Indocker.logger.error("env file :#{env_file.name} was already defined")
    exit 1
  end

  env_files.push(env_file)
end
define_image(name) click to toggle source
# File lib/indocker.rb, line 316
def define_image(name)
  path = caller[0].split(':').first

  if !(path =~ /\/image.rb$/)
    Indocker.logger.error("image :#{name} should be defined in image.rb file")
    exit 1
  end

  builder = Indocker::Images::ImageBuilder.new(
    name: name,
    configuration: configuration,
    dir: path.split('image.rb').first
  )

  images.push(builder.image)

  builder
end
define_network(name) click to toggle source
# File lib/indocker.rb, line 192
def define_network(name)
  if networks.detect {|n| n.name == name}
    raise ArgumentError.new("network :#{name} was already defined")
  end

  networks.push(Indocker::Networks::Network.new(name))
end
define_volume(volume) click to toggle source
# File lib/indocker.rb, line 233
def define_volume(volume)
  if volumes.detect { |v| v.name == volume.name}
    raise ArgumentError.new("volume :#{volume.name} was already defined")
  end

  volumes.push(volume)
end
deploy(containers: [], skip_tags: [], tags: [], skip_dependent: false, skip_containers: [], servers: [], skip_build: false, skip_deploy: false, force_restart: false, skip_force_restart: [], auto_confirm: false, require_confirmation: false) click to toggle source
# File lib/indocker.rb, line 345
def deploy(containers: [], skip_tags: [], tags: [], skip_dependent: false,
  skip_containers: [], servers: [], skip_build: false, skip_deploy: false,
  force_restart: false, skip_force_restart: [], auto_confirm: false,
  require_confirmation: false)

  deployment_policy = Indocker::DeploymentPolicy.new(
    deploy_containers:    containers,
    deploy_tags:          tags,
    servers:              servers,
    skip_dependent:       skip_dependent,
    skip_containers:      skip_containers,
    skip_build:           skip_build,
    skip_deploy:          skip_deploy,
    skip_tags:            skip_tags,
    force_restart:        force_restart,
    skip_force_restart:   skip_force_restart,
    auto_confirm:         auto_confirm,
    require_confirmation: require_confirmation,
  )

  Indocker::Launchers::ConfigurationDeployer
    .new(logger: Indocker.logger, global_logger: Indocker.global_logger)
    .run(
      configuration:     configuration,
      deployment_policy: deployment_policy
    )
end
deploy_dir() click to toggle source
# File lib/indocker.rb, line 142
def deploy_dir
  if @deploy_dir
    @deploy_dir
  else
    raise ArgumentError.new("deploy dir was not specified")
  end
end
dockerignore() click to toggle source
# File lib/indocker.rb, line 449
def dockerignore
  @dockerignore || []
end
env_files() click to toggle source
# File lib/indocker.rb, line 283
def env_files
  @env_files ||= []
end
export_command() click to toggle source
# File lib/indocker.rb, line 122
def export_command
  @export_command
end
global_build_args() click to toggle source
# File lib/indocker.rb, line 413
def global_build_args
  Indocker::ContextArgs.new(nil, configuration.global_build_args, nil)
end
global_logger() click to toggle source

Global logger would output data without dependency on how we deploy the progress Currently it will always output data to stdout

# File lib/indocker.rb, line 437
def global_logger
  @global_logger ||= Indocker::LoggerFactory.create(STDOUT, @log_level)
end
helper() click to toggle source
# File lib/indocker.rb, line 417
def helper
  Indocker::BuildContextHelper.new(Indocker.configuration, nil)
end
image_files() click to toggle source
# File lib/indocker.rb, line 204
def image_files
  @image_files || (raise ArgumentError.new("image files were not found. Set bounded contexts dir"))
end
images() click to toggle source
# File lib/indocker.rb, line 291
def images
  @images ||= []
end
launched?(contaner_name, servers: nil) click to toggle source
# File lib/indocker.rb, line 382
def launched?(contaner_name, servers: nil)
  silent_logger = Logger.new(File.open(File::NULL, "w"))
  Indocker::DeploymentChecker
    .new(silent_logger, silent_logger)
    .launched?(
      contaner_name,
      configuration: configuration,
      servers: servers,
    )
end
logger() click to toggle source

This logger outputs progress of the deployment It will not output anything for deployment without debug option

# File lib/indocker.rb, line 423
def logger
  @logger ||= begin
    logger_stdout = if @log_level == Logger::DEBUG
      STDOUT
    else
      File.open(File::NULL, "w")
    end

    Indocker::LoggerFactory.create(logger_stdout, @log_level)
  end
end
networks() click to toggle source
# File lib/indocker.rb, line 263
def networks
  @networks ||= []
end
redeploy_crontab_path() click to toggle source
# File lib/indocker.rb, line 138
def redeploy_crontab_path
  @redeploy_crontab_path
end
registries() click to toggle source
# File lib/indocker.rb, line 259
def registries
  @registries ||= []
end
repositories() click to toggle source
# File lib/indocker.rb, line 255
def repositories
  @repositories ||= []
end
root_dir() click to toggle source
# File lib/indocker.rb, line 150
def root_dir
  if @root_dir
    File.expand_path(@root_dir)
  else
    raise ArgumentError.new("root dir was not specified")
  end
end
run(container_name, force_restart) click to toggle source
# File lib/indocker.rb, line 403
def run(container_name, force_restart)
  Indocker::Launchers::ContainerRunner
    .new(Indocker.logger)
    .run(
      configuration: configuration,
      container_name: container_name,
      force_restart: force_restart
    )
end
servers() click to toggle source
# File lib/indocker.rb, line 271
def servers
  @servers ||= []
end
set_bounded_contexts_dir(path) click to toggle source
# File lib/indocker.rb, line 208
def set_bounded_contexts_dir(path)
  @container_files = {}

  Dir[File.join(path, '**/container.rb')].map do |path|
    name = path.gsub('/container.rb', '').split('/').last.to_sym
    @container_files[name] = path
  end

  @image_files = {}

  Dir[File.join(path, '**/image.rb')].map do |path|
    name = path.gsub('/image.rb', '').split('/').last.to_sym
    @image_files[name] = path
  end
end
set_configuration_name(name) click to toggle source
# File lib/indocker.rb, line 457
def set_configuration_name(name)
  @configuration_name = name
end
set_deploy_dir(val) click to toggle source
# File lib/indocker.rb, line 126
def set_deploy_dir(val)
  @deploy_dir = val
end
set_dockerignore(ignore_list) click to toggle source
# File lib/indocker.rb, line 445
def set_dockerignore(ignore_list)
  @dockerignore = ignore_list
end
set_export_command(command) click to toggle source
# File lib/indocker.rb, line 118
def set_export_command(command)
  @export_command = command
end
set_log_level(level) click to toggle source
# File lib/indocker.rb, line 441
def set_log_level(level)
  @log_level = level
end
set_redeploy_crontab_path(val) click to toggle source
# File lib/indocker.rb, line 134
def set_redeploy_crontab_path(val)
  @redeploy_crontab_path = val
end
set_root_dir(val) click to toggle source
# File lib/indocker.rb, line 130
def set_root_dir(val)
  @root_dir = val
end
volumes() click to toggle source
# File lib/indocker.rb, line 267
def volumes
  @volumes ||= []
end