Class: Init

Inherits:
Thor::Group
  • Object
show all
Includes:
DockerMgr::Util, Thor::Actions
Defined in:
lib/commands/init.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DockerMgr::Util

#add_line_to_routine, #add_packages, #add_trust, #admin_dir, #apps_dir, #attic_dir, #backup_dir, #base_images_dir, #cert_dir, #config, #data_services, #exec_hook, #extract_date, #extract_email, #extract_git_variable, #extract_name, #generate_ca_installer, #install_dir, #package_tar, #proxy_dir, #remove_line_from_routine, #root_dir, #root_dir_condition, #routine_dir, #runner_dir, #service_hooks_for, #services, #vhost_dir, #volumes

Class Method Details

.source_rootObject



9
10
11
# File 'lib/commands/init.rb', line 9

def self.source_root
  File.expand_path('../templates',__dir__)
end

Instance Method Details

#create_base_imageObject



40
41
42
43
44
45
46
47
48
# File 'lib/commands/init.rb', line 40

def create_base_image
  @user_email,@user_name = config.values_at(:email,:name)
  image_name = 'base'
  image_path = "#{base_images_dir}/#{image_name}/v1.0"
  @image_name = image_name
  @version = "1.0"
  @base = "ubuntu:14.04"
  create_image(image_path,'curl','git')
end

#create_base_runnerObject



50
51
52
53
54
55
56
# File 'lib/commands/init.rb', line 50

def create_base_runner
  @image_name = 'runner_base'
  image_path = "#{base_images_dir}/#{@image_name}/v1.0"
  @version = "1.0"
  @base = "ayufan/gitlab-ci-multi-runner:latest"
  create_image(image_path,'java','node','ruby','ruby_buildtools','node_buildtools')
end

#create_caObject



25
26
27
28
29
30
31
32
33
34
# File 'lib/commands/init.rb', line 25

def create_ca
  FileUtils.cd 'docker/admin/ca' do 
    puts `openssl req -x509 -newkey rsa:4096 -keyout rootCA.key -out rootCA.crt -days 7800 -sha256`
  end
  chmod 'docker/admin/ca/rootCA.key',0600
  chmod 'docker/admin/ca/sign.sh',0755
  FileUtils.cd 'docker' do 
    generate_ca_installer
  end
end

#init_gitObject



36
37
38
# File 'lib/commands/init.rb', line 36

def init_git
  puts `git init docker`
end

#project_structureObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/commands/init.rb', line 13

def project_structure
  empty_directory "docker/apps"
  empty_directory "docker/attic"
  empty_directory "docker/backup"
  empty_directory "docker/base_images"
  directory "admin","docker/admin"
  empty_directory "docker/ci_runner"
  empty_directory "docker/proxy/certs"
  empty_directory "docker/proxy/vhosts.d"
  copy_file "gitignore","docker/.gitignore"
end