avm-tools 0.100.0 → 0.101.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avm/docker/image.rb +7 -23
  3. data/lib/avm/docker/runner.rb +32 -6
  4. data/lib/avm/eac_rails_base1/runner/bundle.rb +1 -2
  5. data/lib/avm/eac_redmine_base0/docker_image.rb +52 -0
  6. data/lib/avm/eac_redmine_base0/instance.rb +2 -2
  7. data/lib/avm/instances/base/dockerizable.rb +1 -0
  8. data/lib/avm/instances/base/entry_keys.rb +6 -1
  9. data/lib/avm/instances/docker_image.rb +15 -0
  10. data/lib/avm/instances/entries.rb +0 -1
  11. data/lib/avm/instances/entry.rb +3 -2
  12. data/lib/avm/instances/entry_keys.rb +1 -0
  13. data/lib/avm/self.rb +9 -0
  14. data/lib/avm/tools/runner.rb +4 -0
  15. data/lib/avm/tools/runner/config/load_path.rb +4 -3
  16. data/lib/avm/tools/runner/eac_redmine_base0/dev_docker.rb +17 -0
  17. data/lib/avm/tools/runner/eac_redmine_base0/docker.rb +3 -0
  18. data/lib/avm/tools/runner/git/deploy.rb +2 -1
  19. data/lib/avm/tools/version.rb +1 -1
  20. data/template/avm/eac_redmine_base0/docker_image/Dockerfile.template +47 -0
  21. data/template/avm/eac_redmine_base0/docker_image/apache_http_virtualhost.conf.template +10 -0
  22. data/template/avm/eac_redmine_base0/docker_image/apache_https_virtualhost.conf.template +16 -0
  23. data/template/avm/eac_redmine_base0/docker_image/install_settings.sh.template +29 -0
  24. data/template/avm/eac_redmine_base0/docker_image/start.sh.template +25 -0
  25. data/template/avm/eac_ubuntu_base0/docker_image/Dockerfile +1 -1
  26. data/vendor/avm-apps/lib/avm/apps/config.rb +15 -0
  27. data/vendor/avm-apps/lib/avm/apps/jobs/base.rb +1 -1
  28. data/vendor/avm-apps/lib/avm/apps/version.rb +1 -1
  29. data/vendor/eac_cli/lib/eac_cli/config/entry.rb +2 -0
  30. data/vendor/eac_cli/lib/eac_cli/definition/positional_argument.rb +6 -1
  31. data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder/alternative.rb +3 -1
  32. data/vendor/eac_cli/lib/eac_cli/runner_with/help.rb +6 -2
  33. data/vendor/eac_cli/lib/eac_cli/runner_with/subcommands.rb +5 -1
  34. data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
  35. data/vendor/eac_git/lib/eac_git/executables.rb +4 -0
  36. data/vendor/eac_git/lib/eac_git/local/commit/archive.rb +19 -0
  37. data/vendor/eac_git/lib/eac_git/version.rb +1 -1
  38. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/context.rb +31 -0
  39. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/contextualizable.rb +21 -0
  40. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/context.rb +11 -0
  41. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  42. metadata +15 -3
  43. data/lib/avm/configs.rb +0 -26
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: acd09c13ca7d0637196f933aadf90bb07ab9946f71a075f14a4f4fcf421f2377
4
- data.tar.gz: db77e011115f9fcb1eb8bcc8003f1ea4b4055efa3a1996e73fce1b0cf569bf03
3
+ metadata.gz: 5243b812d2aa6e9e61cff80a964aa4b035abd9dd85051f5798fbfc6b1c00486a
4
+ data.tar.gz: 8c79b0a42a1d863349129e5a2ab8d091f8765abea99815d4f706e64126f843bc
5
5
  SHA512:
6
- metadata.gz: 3d7954e5f0708686a8096a759fc51ac2f3eff7b539e07d5b35c425dede0f4d9b03fa4f1130f0f01b39e619ceff4c1ff43cf8b6d47d5f31c9e6363007de92ecf9
7
- data.tar.gz: 2ca9bfaf366021f71954e27c4da9b8bcf6d05270e5120b04a58d30e42d57b142c2b2fec25eabb967638d7d1a6d0e8068f2a639bd916c3152ff50eed3018d9a6b
6
+ metadata.gz: f1c66dd955e5367563ccad9d9ae5e44946c109b9abf519b3bddb04cd5bda6dcb4b74a6bc4745f1ba7fd400111ab5ce41e5172cd3d28765ea44106531ba8d8644
7
+ data.tar.gz: 2b7c051160d2c1b549a25b6a620a9458c151b85887c1bcffd859ac4099fd72e57a6d2af17309b293883a1da0b431a64b54e8491446e191efed274f18a2f93dfe
@@ -3,10 +3,11 @@
3
3
  require 'eac_ruby_utils/core_ext'
4
4
  require 'avm/executables'
5
5
  require 'avm/patches/object/template'
6
+ require 'eac_docker/images/templatized'
6
7
 
7
8
  module Avm
8
9
  module Docker
9
- class Image
10
+ class Image < ::EacDocker::Images::Templatized
10
11
  attr_reader :registry
11
12
  attr_accessor :snapshot
12
13
  attr_accessor :version
@@ -18,10 +19,9 @@ module Avm
18
19
  end
19
20
 
20
21
  def build(extra_args = [])
21
- on_build_dir do
22
- template.apply(self, build_dir)
23
- run_docker_build(extra_args)
24
- end
22
+ nyi "Extra args: #{extra_args}" if extra_args.any?
23
+
24
+ provide
25
25
  end
26
26
 
27
27
  def generator_version
@@ -32,9 +32,10 @@ module Avm
32
32
  ::Avm::Executables.docker.command.append(['push', tag]).system!
33
33
  end
34
34
 
35
- def read_entry(path, _options = {})
35
+ def read_entry(path, options = {})
36
36
  method = path.gsub('.', '_')
37
37
  return send(method) if respond_to?(path, true)
38
+ return instance.read_entry(path, options) if respond_to?(:instance)
38
39
 
39
40
  raise "Method \"#{method}\" not found for entry \"#{path}\""
40
41
  end
@@ -66,23 +67,6 @@ module Avm
66
67
  r += '-snapshot' if snapshot
67
68
  r
68
69
  end
69
-
70
- private
71
-
72
- attr_reader :build_dir
73
-
74
- def run_docker_build(extra_args)
75
- ::Avm::Executables.docker.command.append(
76
- ['build', '-t', tag] + extra_args + [build_dir]
77
- ).system!
78
- end
79
-
80
- def on_build_dir
81
- @build_dir = ::Dir.mktmpdir
82
- yield
83
- ensure
84
- ::FileUtils.rm_rf(@build_dir)
85
- end
86
70
  end
87
71
  end
88
72
  end
@@ -43,42 +43,68 @@ module Avm
43
43
  infov 'Registry name', registry
44
44
  infov 'Version?', version?
45
45
  infov 'Snapshot?', snapshot?
46
- infov 'Image name', instance.docker_image.tag
46
+ infov 'Image name', docker_image.tag
47
47
  infov 'Build arguments', build_args
48
48
  infov 'Entrypoint arguments', entrypoint_args
49
49
  end
50
50
 
51
51
  def build
52
- instance.docker_image.build(build_args)
52
+ docker_image.build(build_args)
53
+ success 'Docker image builded'
53
54
  end
54
55
 
55
56
  def build_args
56
57
  parsed.build_arg
57
58
  end
58
59
 
60
+ def docker_container
61
+ instance.docker_container
62
+ end
63
+
64
+ def docker_image
65
+ instance.docker_image
66
+ end
67
+
59
68
  def entrypoint_args
60
69
  parsed.entrypoint_arg
61
70
  end
62
71
 
63
72
  def push
64
- instance.docker_image.push if parsed.push?
73
+ docker_image.push if parsed.push?
65
74
  end
66
75
 
67
76
  def container_run
68
77
  return unless parsed.run?
69
78
 
70
- instance.docker_container.run(
79
+ docker_container.run(
71
80
  entrypoint_args: entrypoint_args,
72
81
  clear: parsed.clear?
73
82
  )
74
83
  end
75
84
 
76
85
  def registry_uncached
77
- parsed.registry_name.if_present(::Avm::Docker::Registry.default) do |v|
78
- ::Avm::Docker::Registry.new(v)
86
+ registry_from_option || registry_from_instance || registry_from_default ||
87
+ fatal_error('No registry defined')
88
+ end
89
+
90
+ def registry_from_option
91
+ parsed.registry_name.if_present { |v| ::Avm::Docker::Registry.new(v) }
92
+ end
93
+
94
+ def registry_from_instance
95
+ if if_respond(:use_default_registry?, true)
96
+ instance.docker_registry_optional.if_present { |v| ::Avm::Docker::Registry.new(v) }
97
+ else
98
+ ::Avm::Docker::Registry.new(instance.docker_registry)
79
99
  end
80
100
  end
81
101
 
102
+ def registry_from_default
103
+ return nil unless if_respond(:use_default_registry?, true)
104
+
105
+ ::Avm::Docker::Registry.default
106
+ end
107
+
82
108
  def snapshot?
83
109
  !parsed.no_snapshot?
84
110
  end
@@ -8,8 +8,7 @@ module Avm
8
8
  module EacRailsBase1
9
9
  class Runner < ::Avm::EacWebappBase0::Runner
10
10
  class Bundle
11
- runner_with ::Avm::EacRailsBase1::RunnerWith::Bundle
12
- runner_definition do
11
+ runner_with ::Avm::EacRailsBase1::RunnerWith::Bundle, :help do
13
12
  desc 'Runs "bundle ...".'
14
13
  pos_arg :'bundle-args', repeat: true, optional: true
15
14
  end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/core_ext'
4
+ require 'avm/instances/docker_image'
5
+
6
+ module Avm
7
+ module EacRedmineBase0
8
+ class DockerImage < ::Avm::Instances::DockerImage
9
+ enable_simple_cache
10
+
11
+ REDMINE_SOURCE_HOST_SUBPATH = 'redmine_source'
12
+
13
+ def avm_fs_cache_object_id
14
+ instance.id
15
+ end
16
+
17
+ def redmine_user
18
+ 'redmine'
19
+ end
20
+
21
+ def redmine_user_home
22
+ "/home/#{redmine_user}"
23
+ end
24
+
25
+ def redmine_path
26
+ "#{redmine_user_home}/redmine_app"
27
+ end
28
+
29
+ def start_path
30
+ '/start.sh'
31
+ end
32
+
33
+ private
34
+
35
+ def git_repo_uncached
36
+ ::EacGit::Local.new(instance.source_instance.fs_path)
37
+ end
38
+
39
+ def redmine_source_git_id
40
+ git_repo.rev_parse('HEAD')
41
+ end
42
+
43
+ def redmine_source_path_uncached
44
+ r = provide_dir.join(REDMINE_SOURCE_HOST_SUBPATH)
45
+ ::FileUtils.rm_rf(r.to_path)
46
+ r.mkpath
47
+ git_repo.commit(redmine_source_git_id).archive_to_dir(r).system!
48
+ REDMINE_SOURCE_HOST_SUBPATH
49
+ end
50
+ end
51
+ end
52
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/eac_redmine_base0/data_unit'
4
- require 'avm/eac_ubuntu_base0/docker_image'
4
+ require 'avm/eac_redmine_base0/docker_image'
5
5
  require 'avm/eac_webapp_base0/instance'
6
6
  require 'avm/eac_rails_base1/instance'
7
7
 
@@ -11,7 +11,7 @@ module Avm
11
11
  FILES_UNITS = { files: 'files' }.freeze
12
12
 
13
13
  def docker_image_class
14
- ::Avm::EacUbuntuBase0::DockerImage
14
+ ::Avm::EacRedmineBase0::DockerImage
15
15
  end
16
16
 
17
17
  def docker_run_arguments
@@ -33,6 +33,7 @@ module Avm
33
33
 
34
34
  def docker_image_uncached
35
35
  r = docker_image_class.new(docker_image_options.fetch(:registry))
36
+ r.instance = self if r.respond_to?(:instance)
36
37
  r.version = docker_image_options[:version] if docker_image_options.key?(:version)
37
38
  r.snapshot = docker_image_options[:snapshot] if docker_image_options.key?(:snapshot)
38
39
  r
@@ -7,9 +7,14 @@ module Avm
7
7
  class Base
8
8
  module EntryKeys
9
9
  ::Avm::Instances::EntryKeys.all.each do |key|
10
- define_method key.to_s.variableize do
10
+ method_name = key.to_s.variableize
11
+ define_method method_name do
11
12
  read_entry(key)
12
13
  end
14
+
15
+ define_method "#{method_name}_optional" do
16
+ read_entry(key, required: false)
17
+ end
13
18
  end
14
19
  end
15
20
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/docker/image'
4
+
5
+ module Avm
6
+ module Instances
7
+ class DockerImage < ::Avm::Docker::Image
8
+ attr_accessor :instance
9
+
10
+ def stereotype_tag
11
+ instance.id
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'eac_ruby_utils/core_ext'
4
- require 'avm/configs'
5
4
  require 'avm/instances/entry'
6
5
 
7
6
  module Avm
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avm/apps/config'
3
4
  require 'eac_ruby_utils/core_ext'
4
5
 
5
6
  module Avm
@@ -30,7 +31,7 @@ module Avm
30
31
  end
31
32
 
32
33
  def read(extra_options = {})
33
- ::Avm.configs.read_entry(full_path, options.merge(extra_options))
34
+ ::Avm::Apps::Config.current.entry(full_path, options.merge(extra_options)).value
34
35
  end
35
36
 
36
37
  def suffix_as_array
@@ -46,7 +47,7 @@ module Avm
46
47
  end
47
48
 
48
49
  def write(value)
49
- ::Avm.configs.sub.entry(full_path).value = value
50
+ ::Avm::Apps::Config.current.entry(full_path).value = value
50
51
  end
51
52
  end
52
53
  end
@@ -44,6 +44,7 @@ module Avm
44
44
  {
45
45
  '' => %w[fs_path host_id source_instance_id],
46
46
  database: %w[id hostname limit name password port system timeout username],
47
+ docker: %w[registry],
47
48
  mailer: {
48
49
  '' => %w[id from reply_to],
49
50
  smtp: %w[address port domain username password authentication starttls_auto]
data/lib/avm/self.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'eac_cli/old_configs_bridge'
3
4
  require 'eac_ruby_base0/application'
4
5
  require 'eac_ruby_utils/require_sub'
5
6
  require 'avm/instances/base'
@@ -13,6 +14,14 @@ module Avm
13
14
  @application ||= ::EacRubyBase0::Application.new(root.to_path)
14
15
  end
15
16
 
17
+ # @return [EacCli::OldConfigsBridge]
18
+ def build_config(path = nil)
19
+ ::EacCli::OldConfigsBridge.new(
20
+ application.name,
21
+ path.if_present({}) { |v| { storage_path: v } }
22
+ )
23
+ end
24
+
16
25
  def instance
17
26
  @instance ||= ::Avm::Self::Instance.by_id('avm-tools_self')
18
27
  end
@@ -17,6 +17,10 @@ module Avm
17
17
  def application
18
18
  ::Avm::Self.application
19
19
  end
20
+
21
+ def run
22
+ ::Avm::Apps::Config.context.on(::Avm::Self.build_config) { super }
23
+ end
20
24
  end
21
25
  end
22
26
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avm/apps/config'
3
4
  require 'avm/self'
4
5
  require 'avm/core_ext'
5
6
 
@@ -20,9 +21,9 @@ module Avm
20
21
 
21
22
  private
22
23
 
23
- # @return [[EacCli::OldConfigsBridge]]
24
+ # @return [[EacCli::Config]]
24
25
  def config_node
25
- ::Avm.configs.sub
26
+ ::Avm::Apps::Config.current
26
27
  end
27
28
 
28
29
  def run_add
@@ -34,7 +35,7 @@ module Avm
34
35
  end
35
36
 
36
37
  def run_show
37
- infov 'Configuration path', config_node.path
38
+ infov 'Configuration path', config_node.url
38
39
  infov 'Paths included', config_node.self_loaded_nodes.count
39
40
  config_node.self_loaded_nodes.each do |loaded_node|
40
41
  infov ' * ', loaded_node.url
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/docker/runner'
4
+
5
+ module Avm
6
+ module Tools
7
+ class Runner
8
+ class EacRedmineBase0 < ::Avm::EacRailsBase1::Runner
9
+ class DevDocker < ::Avm::Docker::Runner
10
+ def docker_image
11
+ ::Avm::EacUbuntuBase0::DockerImage
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -7,6 +7,9 @@ module Avm
7
7
  class Runner
8
8
  class EacRedmineBase0 < ::Avm::EacRailsBase1::Runner
9
9
  class Docker < ::Avm::Docker::Runner
10
+ def use_default_registry?
11
+ false
12
+ end
10
13
  end
11
14
  end
12
15
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avm/apps/config'
3
4
  require 'avm/launcher/git/base'
4
5
  require 'avm/git/commit'
5
6
 
@@ -90,7 +91,7 @@ module Avm
90
91
  end
91
92
 
92
93
  def variables_source
93
- instance || ::Avm.configs
94
+ instance || ::Avm::Apps::Config.current
94
95
  end
95
96
 
96
97
  def instance_uncached
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.100.0'
5
+ VERSION = '0.101.0'
6
6
  end
7
7
  end
@@ -0,0 +1,47 @@
1
+ FROM ubuntu:20.04
2
+ RUN apt-get update -y
3
+ RUN DEBIAN_FRONTEND=noninteractive apt-get install -y sudo tzdata git apt-utils
4
+ RUN ln -fs /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime
5
+ RUN dpkg-reconfigure --frontend noninteractive tzdata
6
+
7
+ # Usuário "%%redmine_user%%"
8
+ RUN /usr/sbin/useradd --shell /bin/bash --home-dir '%%redmine_user_home%%' --create-home '%%redmine_user%%'
9
+ RUN /bin/echo '%%redmine_user%%:%%redmine_user%%' | /usr/sbin/chpasswd
10
+ RUN /bin/chown '%%redmine_user%%:%%redmine_user%%' %%redmine_user_home%% -R
11
+ RUN /bin/echo "%%redmine_user%% ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/%%redmine_user%%_all_nopasswd && chmod 0440 /etc/sudoers.d/%%redmine_user%%_all_nopasswd
12
+
13
+ # Redmine / Código-fonte
14
+ RUN echo '%%redmine_source_git_id%%' '%%redmine_user_home%%/redmine_source_git_id'
15
+ ADD '%%redmine_source_path%%' '%%redmine_path%%/'
16
+ RUN chown -R '%%redmine_user%%:%%redmine_user%%' '%%redmine_user_home%%'
17
+
18
+ # Redmine / Configuração de instalação
19
+ USER '%%redmine_user%%'
20
+ WORKDIR '%%redmine_user_home%%'
21
+ COPY install_settings.sh "%%redmine_path%%/config/install.sh"
22
+
23
+ # Redmine / Instalação
24
+ USER '%%redmine_user%%'
25
+ WORKDIR '%%redmine_user_home%%'
26
+ RUN '%%redmine_path%%/plugins/redmine_installer/installer/run.sh' redmine_as_apache_base
27
+
28
+ # Apache / Configuração do virtualhost
29
+ COPY apache_http_virtualhost.conf /etc/apache2/sites-available/redmine.conf
30
+ COPY apache_https_virtualhost.conf /etc/apache2/sites-available/redmine_ssl.conf
31
+ USER root
32
+ RUN a2ensite redmine
33
+ RUN a2ensite redmine_ssl
34
+ RUN a2dissite 000-default
35
+ RUN a2enmod ssl
36
+ RUN service apache2 restart
37
+
38
+ # Portas
39
+ EXPOSE 80/tcp 443/tcp 22/tcp
40
+
41
+ # Execução
42
+ COPY start.sh '%%start_path%%'
43
+ RUN /bin/chmod +x '%%start_path%%'
44
+ RUN /bin/chown '%%redmine_user%%:%%redmine_user%%' '%%start_path%%'
45
+ USER '%%redmine_user%%'
46
+ WORKDIR '%%redmine_user_home%%'
47
+ ENTRYPOINT '%%start_path%%'
@@ -0,0 +1,10 @@
1
+ <VirtualHost _default_:80>
2
+ DocumentRoot "%%redmine_path%%/public"
3
+ PassengerEnabled On
4
+
5
+ <Directory "%%redmine_path%%/public" >
6
+ Allow from all
7
+ Options -MultiViews
8
+ Require all granted
9
+ </Directory>
10
+ </VirtualHost>
@@ -0,0 +1,16 @@
1
+ <IfModule mod_ssl.c>
2
+ <VirtualHost _default_:443>
3
+ SSLEngine on
4
+ SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
5
+ SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
6
+
7
+ DocumentRoot "%%redmine_path%%/public"
8
+ PassengerEnabled On
9
+
10
+ <Directory "%%redmine_path%%/public" >
11
+ Allow from all
12
+ Options -MultiViews
13
+ Require all granted
14
+ </Directory>
15
+ </VirtualHost>
16
+ </IfModule>
@@ -0,0 +1,29 @@
1
+ # Database (PostgreSQL)
2
+ export postgresql_database=redmine
3
+ export postgresql_database_test=redmine_test
4
+ export postgresql_user=redmine
5
+ export postgresql_password=redmine
6
+
7
+ # Git hosting
8
+ export gitolite_user=git
9
+ export gitolite_user_home="/var/lib/$gitolite_user"
10
+ export redmine_git_hosting_ssh_key_name=redmine_git_hosting_id
11
+ export git_repositories_hierarchical_organisation=false
12
+
13
+ # Address
14
+ export address_https=false
15
+ export address_host="%%web.hostname%%"
16
+ export address_port=
17
+ export address_path=
18
+
19
+ # Mail
20
+ export smtp_server='mail.trf1.jus.br'
21
+ export smtp_port='25'
22
+ export smtp_domain='trf1.jus.br'
23
+ export smtp_tls='false'
24
+ export smtp_enable_starttls_auto=''
25
+ export smtp_openssl_verify_mode=''
26
+ export smtp_authentication='none'
27
+ export smtp_username=''
28
+ export smtp_password=''
29
+ export mail_from='"redmine-trf1_0" <redmine@trf1.jus.br>'
@@ -0,0 +1,25 @@
1
+ #!/bin/bash
2
+
3
+ set -u
4
+ set -e
5
+
6
+ function title() {
7
+ printf ">>>> %s <<<<\n" "$1"
8
+ }
9
+
10
+ title 'Restarting Apache HTTPD service...'
11
+ sudo service apache2 restart
12
+
13
+ title 'Restarting SSH service...'
14
+ sudo service ssh restart
15
+
16
+ title 'Restarting PostgresSQL service...'
17
+ sudo service postgresql restart
18
+
19
+ title 'Requesting web interface...'
20
+ wget 'http://localhost' &> /dev/null
21
+
22
+ title 'Reading production log...'
23
+ LOG_FILE='%%redmine_path%%/log/production.log'
24
+ printf " * tail -f \"$LOG_FILE\":\n"
25
+ sudo tail -f "$LOG_FILE"
@@ -1,4 +1,4 @@
1
- FROM ubuntu:bionic
1
+ FROM ubuntu:20.04
2
2
  RUN apt-get update -y
3
3
  RUN apt-get install -y sudo tzdata
4
4
  RUN /usr/sbin/useradd --shell /bin/bash --home-dir /home/myuser --create-home myuser
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Apps
7
+ class Config
8
+ enable_context
9
+
10
+ class << self
11
+ delegate :current, to: :context
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/apps/jobs/variables_source'
4
- require 'eac_ruby_utils/core_ext'
4
+ require 'eac_cli/core_ext'
5
5
 
6
6
  module Avm
7
7
  module Apps
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Apps
5
- VERSION = '0.2.1'
5
+ VERSION = '0.3.0'
6
6
  end
7
7
  end
@@ -26,6 +26,8 @@ module EacCli
26
26
  input_value
27
27
  end
28
28
 
29
+ delegate :value=, to: :sub_entry
30
+
29
31
  private
30
32
 
31
33
  def sub_value_to_return
@@ -6,9 +6,10 @@ module EacCli
6
6
  class Definition
7
7
  class PositionalArgument
8
8
  DEFAULT_REQUIRED = true
9
+ DEFAULT_VISIBLE = true
9
10
 
10
11
  enable_listable
11
- lists.add_symbol :option, :optional, :repeat, :required, :subcommand
12
+ lists.add_symbol :option, :optional, :repeat, :required, :subcommand, :visible
12
13
  common_constructor :name, :options, default: [{}] do
13
14
  options.assert_valid_keys(self.class.lists.option.values)
14
15
  end
@@ -51,6 +52,10 @@ module EacCli
51
52
  def to_s
52
53
  "#{self.class.name.demodulize}[#{identifier}]"
53
54
  end
55
+
56
+ def visible?
57
+ options.key?(OPTION_VISIBLE) ? options.fetch(OPTION_VISIBLE) : DEFAULT_VISIBLE
58
+ end
54
59
  end
55
60
  end
56
61
  end
@@ -31,10 +31,12 @@ module EacCli
31
31
  end
32
32
 
33
33
  def positionals
34
- alternative.positional.map { |p| positional(p) }
34
+ alternative.positional.map { |p| positional(p) }.reject(&:blank?)
35
35
  end
36
36
 
37
37
  def positional(positional)
38
+ return unless positional.visible?
39
+
38
40
  if positional.subcommand?
39
41
  ::EacCli::DocoptRunner::SUBCOMMANDS_MACRO
40
42
  else
@@ -10,8 +10,8 @@ module EacCli
10
10
  include ::EacCli::Runner
11
11
 
12
12
  runner_definition.alt do
13
- options_argument false
14
13
  bool_opt '-h', '--help', 'Show help.', usage: true
14
+ pos_arg :any_arg_with_help, repeat: true, optional: true, visible: false
15
15
  end
16
16
 
17
17
  set_callback :run, :before do
@@ -20,7 +20,7 @@ module EacCli
20
20
  end
21
21
 
22
22
  def help_run
23
- return unless parsed.help?
23
+ return unless show_help?
24
24
 
25
25
  puts help_text
26
26
  raise ::EacCli::Runner::Exit
@@ -31,6 +31,10 @@ module EacCli
31
31
  r += help_extra_text if respond_to?(:help_extra_text)
32
32
  r
33
33
  end
34
+
35
+ def show_help?
36
+ parsed.help? && !if_respond(:run_subcommand?, false)
37
+ end
34
38
  end
35
39
  end
36
40
  end
@@ -60,7 +60,7 @@ module EacCli
60
60
  end
61
61
 
62
62
  def run_with_subcommand
63
- if subcommand_name
63
+ if run_subcommand?
64
64
  if subcommand_runner.respond_to?(:run_run)
65
65
  subcommand_runner.run_run
66
66
  else
@@ -79,6 +79,10 @@ module EacCli
79
79
  "Method #{__method__} should be overrided in #{self.class.name}"
80
80
  end
81
81
 
82
+ def run_subcommand?
83
+ subcommand_name.present?
84
+ end
85
+
82
86
  def subcommands?
83
87
  self.class.runner_definition.subcommands?
84
88
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacCli
4
- VERSION = '0.18.0'
4
+ VERSION = '0.19.0'
5
5
  end
@@ -20,6 +20,10 @@ module EacGit
20
20
  r
21
21
  end
22
22
 
23
+ def tar_uncached
24
+ env.executable('tar', '--version')
25
+ end
26
+
23
27
  module GitCommandExtensions
24
28
  def command(*args)
25
29
  super(*args).envvar('PATH', path_with_git_subrepo)
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacGit
6
+ class Local
7
+ class Commit
8
+ module Archive
9
+ # @return [EacRubyUtils::Envs::Command]
10
+ def archive_to_dir(path)
11
+ path = path.to_pathname
12
+ repo.command('archive', '--format=tar', hash).pipe(
13
+ ::EacGit::Executables.tar.command('-xC', path)
14
+ )
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacGit
4
- VERSION = '0.4.2'
4
+ VERSION = '0.5.0'
5
5
  end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRubyUtils
4
+ class Context
5
+ def current
6
+ optional_current || raise('No elements in context')
7
+ end
8
+
9
+ def optional_current
10
+ stack.last
11
+ end
12
+
13
+ delegate :pop, to: :stack
14
+ delegate :push, to: :stack
15
+
16
+ def on(obj)
17
+ push(obj)
18
+ begin
19
+ yield
20
+ ensure
21
+ pop
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ def stack
28
+ @stack ||= []
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/context'
4
+
5
+ module EacRubyUtils
6
+ module Contextualizable
7
+ common_concern
8
+
9
+ module ClassMethods
10
+ def context
11
+ @context ||= ::EacRubyUtils::Context.new
12
+ end
13
+ end
14
+
15
+ module InstanceMethods
16
+ def context
17
+ self.class.context
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/patch'
4
+ require 'eac_ruby_utils/contextualizable'
5
+
6
+ class Module
7
+ # Patches module with [EacRubyUtils::Contextualizable].
8
+ def enable_context
9
+ ::EacRubyUtils.patch(self, ::EacRubyUtils::Contextualizable)
10
+ end
11
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.65.0'
4
+ VERSION = '0.66.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avm-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.100.0
4
+ version: 0.101.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-01 00:00:00.000000000 Z
11
+ date: 2021-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -324,7 +324,6 @@ files:
324
324
  - lib/avm.rb
325
325
  - lib/avm/app_src.rb
326
326
  - lib/avm/cached_download.rb
327
- - lib/avm/configs.rb
328
327
  - lib/avm/core_ext.rb
329
328
  - lib/avm/data.rb
330
329
  - lib/avm/data/instance.rb
@@ -365,6 +364,7 @@ files:
365
364
  - lib/avm/eac_redmine_base0/core_update.rb
366
365
  - lib/avm/eac_redmine_base0/data_unit.rb
367
366
  - lib/avm/eac_redmine_base0/deploy.rb
367
+ - lib/avm/eac_redmine_base0/docker_image.rb
368
368
  - lib/avm/eac_redmine_base0/instance.rb
369
369
  - lib/avm/eac_ubuntu_base0.rb
370
370
  - lib/avm/eac_ubuntu_base0/apache.rb
@@ -487,6 +487,7 @@ files:
487
487
  - lib/avm/instances/base/auto_values/web.rb
488
488
  - lib/avm/instances/base/dockerizable.rb
489
489
  - lib/avm/instances/base/entry_keys.rb
490
+ - lib/avm/instances/docker_image.rb
490
491
  - lib/avm/instances/entries.rb
491
492
  - lib/avm/instances/entry.rb
492
493
  - lib/avm/instances/entry_keys.rb
@@ -618,6 +619,7 @@ files:
618
619
  - lib/avm/tools/runner/eac_rails_base0.rb
619
620
  - lib/avm/tools/runner/eac_redmine_base0.rb
620
621
  - lib/avm/tools/runner/eac_redmine_base0/core_update.rb
622
+ - lib/avm/tools/runner/eac_redmine_base0/dev_docker.rb
621
623
  - lib/avm/tools/runner/eac_redmine_base0/docker.rb
622
624
  - lib/avm/tools/runner/eac_redmine_base0/project_rename.rb
623
625
  - lib/avm/tools/runner/eac_webapp_base0.rb
@@ -657,6 +659,11 @@ files:
657
659
  - template/avm/eac_rails_base0/deploy/config/envvars.d/email.yml.template
658
660
  - template/avm/eac_redmine_base0/deploy/config/install.sh.template
659
661
  - template/avm/eac_redmine_base0/deploy/config/secrets.yml
662
+ - template/avm/eac_redmine_base0/docker_image/Dockerfile.template
663
+ - template/avm/eac_redmine_base0/docker_image/apache_http_virtualhost.conf.template
664
+ - template/avm/eac_redmine_base0/docker_image/apache_https_virtualhost.conf.template
665
+ - template/avm/eac_redmine_base0/docker_image/install_settings.sh.template
666
+ - template/avm/eac_redmine_base0/docker_image/start.sh.template
660
667
  - template/avm/eac_ubuntu_base0/docker_image/Dockerfile
661
668
  - template/avm/eac_webapp_base0/apache_host/no_ssl.conf
662
669
  - template/avm/eac_webapp_base0/apache_path/default.conf
@@ -681,6 +688,7 @@ files:
681
688
  - vendor/avm-apps/Gemfile
682
689
  - vendor/avm-apps/avm-apps.gemspec
683
690
  - vendor/avm-apps/lib/avm/apps.rb
691
+ - vendor/avm-apps/lib/avm/apps/config.rb
684
692
  - vendor/avm-apps/lib/avm/apps/jobs.rb
685
693
  - vendor/avm-apps/lib/avm/apps/jobs/base.rb
686
694
  - vendor/avm-apps/lib/avm/apps/jobs/variables_source.rb
@@ -840,6 +848,7 @@ files:
840
848
  - vendor/eac_git/lib/eac_git/executables.rb
841
849
  - vendor/eac_git/lib/eac_git/local.rb
842
850
  - vendor/eac_git/lib/eac_git/local/commit.rb
851
+ - vendor/eac_git/lib/eac_git/local/commit/archive.rb
843
852
  - vendor/eac_git/lib/eac_git/local/commit/changed_file.rb
844
853
  - vendor/eac_git/lib/eac_git/local/commit/diff_tree_line.rb
845
854
  - vendor/eac_git/lib/eac_git/local/dirty_files.rb
@@ -1118,6 +1127,8 @@ files:
1118
1127
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/class_initialize.rb
1119
1128
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/instance_initialize.rb
1120
1129
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/super_args.rb
1130
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/context.rb
1131
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/contextualizable.rb
1121
1132
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/core_ext.rb
1122
1133
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/custom_format.rb
1123
1134
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/envs.rb
@@ -1186,6 +1197,7 @@ files:
1186
1197
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module.rb
1187
1198
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/abstract_methods.rb
1188
1199
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/common_concern.rb
1200
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/context.rb
1189
1201
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/immutable.rb
1190
1202
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/listable.rb
1191
1203
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/patch.rb
data/lib/avm/configs.rb DELETED
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_cli/old_configs_bridge'
4
-
5
- module Avm
6
- class << self
7
- attr_reader :configs_storage_path
8
-
9
- def configs
10
- @configs ||= ::EacCli::OldConfigsBridge.new('avm-tools', configs_options)
11
- end
12
-
13
- def configs_file_path
14
- configs_storage_path || default_configs_file_path
15
- end
16
-
17
- def configs_options
18
- configs_storage_path.if_present({}) { |v| { storage_path: v } }
19
- end
20
-
21
- def configs_storage_path=(path)
22
- @configs_storage_path = path
23
- @configs = nil
24
- end
25
- end
26
- end