Class: Minfra::Cli::Project

Inherits:
Command show all
Defined in:
lib/minfra/cli/commands/project.rb,
lib/minfra/cli/commands/project/tag.rb,
lib/minfra/cli/commands/project/branch.rb

Defined Under Namespace

Classes: Branch, ProjectInfo, Tag

Instance Method Summary collapse

Methods included from Logging

#debug, #deprecated, #error, #exit_error, #info, #warn

Methods included from Common

#run_cmd

Instance Method Details

#buildObject



61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/minfra/cli/commands/project.rb', line 61

def build
  p = ProjectInfo.load(Pathname.pwd)
  run_pre_repo
  target = options[:target] || p.docker.dev_target

  cmd = %(docker build #{"--target #{target}" if target} -t #{p.repo_name}:latest #{p.app_dir})
  res = Runner.run(cmd)
  exit(1) if res.error?

  return if options[:noload]

  debug("loading image into KIND's registry")
  Runner.run(%(kind load docker-image #{p.repo_name}:latest --name #{minfra_config.name}))
end

#exec(cmd = '/bin/bash') ⇒ Object



77
78
79
80
81
# File 'lib/minfra/cli/commands/project.rb', line 77

def exec(cmd = '/bin/bash')
  p = ProjectInfo.load(Pathname.pwd)
  run_pre_repo
  Kernel.exec(%(docker run -ti --rm  #{p.exec_params} -v #{p.app_dir}:/code #{p.repo_name}:latest #{cmd}))
end

#pushObject



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/minfra/cli/commands/project.rb', line 86

def push
  tag = options[:tag] || `date +%Y%m%d%H%M`
  p = ProjectInfo.load(Pathname.pwd)

  repo_name = if options[:registry]
                "#{options[:registry]}/#{p.repo_name}"
              else
                p.repo_name
              end

  Runner.run(%(docker build -t #{p.repo_name}:latest #{p.app_dir}))
  #        Runner.run(%{docker push #{p.repo_name}})
  Runner.run(%(docker tag #{p.repo_name}:latest #{repo_name}:#{tag}))
  Runner.run(%(docker push #{repo_name}:#{tag}))
end

#testObject



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/minfra/cli/commands/project.rb', line 45

def test
  ARGV.delete('project') # ARGV is passed along to `rspec` call
  ARGV.delete('test')

  if File.exist?('./bin/run_tests')
    project = ProjectInfo.load(Pathname.pwd)
    debug "Using project specific ./bin/run_tests in #{project.name}"
    system('./bin/run_tests', out: $stdout, err: :out)
  else
    require_relative '../../generic/bin/run_tests'
  end
end