dapp 0.5.13 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/bin/dapp +3 -0
  3. data/config/en/common.yml +35 -6
  4. data/config/en/net_status.yml +20 -6
  5. data/lib/dapp.rb +53 -27
  6. data/lib/dapp/application.rb +48 -27
  7. data/lib/dapp/application/git_artifact.rb +1 -1
  8. data/lib/dapp/application/path.rb +2 -18
  9. data/lib/dapp/application/tags.rb +5 -5
  10. data/lib/dapp/build/stage/artifact.rb +8 -3
  11. data/lib/dapp/build/stage/base.rb +43 -30
  12. data/lib/dapp/build/stage/{infra_install.rb → before_install.rb} +6 -6
  13. data/lib/dapp/build/stage/before_setup.rb +27 -0
  14. data/lib/dapp/build/stage/docker_instructions.rb +12 -1
  15. data/lib/dapp/build/stage/from.rb +4 -3
  16. data/lib/dapp/build/stage/{source_1_archive.rb → ga_archive.rb} +7 -7
  17. data/lib/dapp/build/stage/{source_1_archive_dependencies.rb → ga_archive_dependencies.rb} +4 -4
  18. data/lib/dapp/build/stage/{source_base.rb → ga_base.rb} +31 -7
  19. data/lib/dapp/build/stage/{source_dependencies_base.rb → ga_dependencies_base.rb} +5 -6
  20. data/lib/dapp/build/stage/{source_5.rb → ga_latest_patch.rb} +6 -6
  21. data/lib/dapp/build/stage/install/ga_post_install_patch.rb +21 -0
  22. data/lib/dapp/build/stage/install/ga_post_install_patch_dependencies.rb +21 -0
  23. data/lib/dapp/build/stage/install/ga_pre_install_patch.rb +21 -0
  24. data/lib/dapp/build/stage/install/ga_pre_install_patch_dependencies.rb +31 -0
  25. data/lib/dapp/build/stage/install/install.rb +31 -0
  26. data/lib/dapp/build/stage/mod/artifact.rb +9 -19
  27. data/lib/dapp/build/stage/mod/group.rb +42 -0
  28. data/lib/dapp/build/stage/mod/logging.rb +62 -26
  29. data/lib/dapp/build/stage/setup/chef_cookbooks.rb +37 -0
  30. data/lib/dapp/build/stage/setup/ga_post_setup_patch.rb +25 -0
  31. data/lib/dapp/build/stage/setup/ga_post_setup_patch_dependencies.rb +31 -0
  32. data/lib/dapp/build/stage/setup/ga_pre_setup_patch.rb +25 -0
  33. data/lib/dapp/build/stage/setup/ga_pre_setup_patch_dependencies.rb +27 -0
  34. data/lib/dapp/build/stage/setup/setup.rb +31 -0
  35. data/lib/dapp/builder/base.rb +9 -6
  36. data/lib/dapp/builder/chef.rb +128 -107
  37. data/lib/dapp/builder/chef/berksfile.rb +3 -0
  38. data/lib/dapp/builder/shell.rb +4 -3
  39. data/lib/dapp/cli.rb +8 -6
  40. data/lib/dapp/cli/base.rb +6 -1
  41. data/lib/dapp/cli/bp.rb +41 -0
  42. data/lib/dapp/cli/build.rb +17 -4
  43. data/lib/dapp/cli/cleanup.rb +24 -0
  44. data/lib/dapp/cli/list.rb +2 -2
  45. data/lib/dapp/cli/push.rb +8 -9
  46. data/lib/dapp/cli/run.rb +3 -4
  47. data/lib/dapp/cli/spush.rb +20 -0
  48. data/lib/dapp/cli/stages.rb +2 -0
  49. data/lib/dapp/cli/stages/cleanup.rb +7 -3
  50. data/lib/dapp/cli/stages/flush.rb +6 -3
  51. data/lib/dapp/config/application.rb +17 -11
  52. data/lib/dapp/config/chef.rb +4 -0
  53. data/lib/dapp/config/docker.rb +3 -2
  54. data/lib/dapp/config/git_artifact.rb +1 -2
  55. data/lib/dapp/config/main.rb +5 -2
  56. data/lib/dapp/config/shell.rb +20 -16
  57. data/lib/dapp/docker_registry.rb +32 -0
  58. data/lib/dapp/docker_registry/base.rb +47 -0
  59. data/lib/dapp/docker_registry/default.rb +18 -0
  60. data/lib/dapp/docker_registry/mod/authorization.rb +62 -0
  61. data/lib/dapp/docker_registry/mod/request.rb +44 -0
  62. data/lib/dapp/error/image.rb +6 -0
  63. data/lib/dapp/error/project.rb +6 -0
  64. data/lib/dapp/error/registry.rb +6 -0
  65. data/lib/dapp/exception/registry.rb +6 -0
  66. data/lib/dapp/git_artifact.rb +6 -7
  67. data/lib/dapp/git_repo/base.rb +1 -1
  68. data/lib/dapp/git_repo/remote.rb +6 -38
  69. data/lib/dapp/helper/sha256.rb +3 -3
  70. data/lib/dapp/helper/shellout.rb +25 -7
  71. data/lib/dapp/helper/streaming.rb +1 -3
  72. data/lib/dapp/image/argument.rb +31 -18
  73. data/lib/dapp/image/docker.rb +15 -8
  74. data/lib/dapp/image/stage.rb +10 -12
  75. data/lib/dapp/lock/base.rb +44 -0
  76. data/lib/dapp/lock/error.rb +14 -0
  77. data/lib/dapp/lock/file.rb +33 -0
  78. data/lib/dapp/prctl.rb +22 -0
  79. data/lib/dapp/project.rb +75 -0
  80. data/lib/dapp/project/command/bp.rb +24 -0
  81. data/lib/dapp/project/command/build.rb +21 -0
  82. data/lib/dapp/project/command/cleanup.rb +24 -0
  83. data/lib/dapp/project/command/common.rb +51 -0
  84. data/lib/dapp/project/command/list.rb +14 -0
  85. data/lib/dapp/project/command/push.rb +21 -0
  86. data/lib/dapp/project/command/run.rb +15 -0
  87. data/lib/dapp/project/command/spush.rb +17 -0
  88. data/lib/dapp/project/command/stages_cleanup.rb +70 -0
  89. data/lib/dapp/project/command/stages_flush.rb +18 -0
  90. data/lib/dapp/project/dappfile.rb +70 -0
  91. data/lib/dapp/project/lock.rb +27 -0
  92. data/lib/dapp/project/logging/base.rb +107 -0
  93. data/lib/dapp/project/logging/process.rb +104 -0
  94. data/lib/dapp/project/paint.rb +16 -0
  95. data/lib/dapp/project/ssh_agent.rb +77 -0
  96. data/lib/dapp/version.rb +1 -1
  97. metadata +74 -27
  98. data/lib/dapp/application/deps/gitartifact.rb +0 -39
  99. data/lib/dapp/application/logging.rb +0 -120
  100. data/lib/dapp/application/system_shellout.rb +0 -63
  101. data/lib/dapp/build/stage/chef_cookbooks.rb +0 -33
  102. data/lib/dapp/build/stage/infra_setup.rb +0 -27
  103. data/lib/dapp/build/stage/install.rb +0 -27
  104. data/lib/dapp/build/stage/setup.rb +0 -27
  105. data/lib/dapp/build/stage/source_1.rb +0 -21
  106. data/lib/dapp/build/stage/source_1_dependencies.rb +0 -27
  107. data/lib/dapp/build/stage/source_2.rb +0 -17
  108. data/lib/dapp/build/stage/source_2_dependencies.rb +0 -17
  109. data/lib/dapp/build/stage/source_3.rb +0 -17
  110. data/lib/dapp/build/stage/source_3_dependencies.rb +0 -23
  111. data/lib/dapp/build/stage/source_4.rb +0 -21
  112. data/lib/dapp/build/stage/source_4_dependencies.rb +0 -27
  113. data/lib/dapp/cli/smartpush.rb +0 -19
  114. data/lib/dapp/controller.rb +0 -119
  115. data/lib/dapp/error/controller.rb +0 -6
  116. data/lib/dapp/helper/log.rb +0 -73
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 01676cf63c920ea0e92fe63a31a56b6675bc6292
4
- data.tar.gz: 3301444d6c80446d4c1e692e941627db4ed3b60f
3
+ metadata.gz: 01ccef0d1d810b43eca5b590a2b2509eb66ef5f0
4
+ data.tar.gz: 6b78e52904754a66a6789d73e9db2a3ecd4e1fe9
5
5
  SHA512:
6
- metadata.gz: dc8a5ab0d2441d9382e7cd4a1f2f6f1d5cec834c040e31130ce47f76cbfbc2e632d4f557066655bb40e6f0201edf5a4ad54eb701c7c10e99c913d30ee24e8ef0
7
- data.tar.gz: cc7078af0e3daa91ab5062538d64ad72cff9b4e87eeee7a0668ed33c19442c4cee2f1a44025265d7d44ff4656c1d176d519cbb80f91a99924d6fe03f52bcf4d4
6
+ metadata.gz: 4a013f7409fc4a7a543d5cfc12d978dcc38d015b076e49f00161ab8e3012f58527c93d4cf22b44ff5d2401761afc4f5225be0812b4271acfc2cddb597c528aa8
7
+ data.tar.gz: c7e382cd7d9010cb78bfb380e4fab60b7392cca4fc53596979ab56749dfb765c8a00f28bd1993faffa6c16a5549892c7712bd6811cea01fd70894cbc8222ba1f
data/bin/dapp CHANGED
@@ -16,4 +16,7 @@ rescue Dapp::Error::Base, NetStatus::Exception => e
16
16
  rescue Interrupt => _e
17
17
  $stderr.puts(Dapp::Helper::Paint.paint_string('Interrupted', :warning))
18
18
  exit 1
19
+ rescue Errno::EACCES => _e
20
+ $stderr.puts(Dapp::Helper::Paint.paint_string('Permission denied!', :warning))
21
+ exit 1
19
22
  end
@@ -3,20 +3,20 @@ en:
3
3
  image:
4
4
  signature: "signature: %{signature}"
5
5
  info:
6
- date: "date: %{value}"
6
+ created_at: "date: %{value}"
7
7
  size: "size: %{value} MB"
8
8
  difference: "difference: %{value} MB"
9
9
  commands: "commands:"
10
+ instructions: "instructions:"
10
11
  process:
11
12
  artifact_copy: "copying artifact '%{name}'"
12
13
  artifact_building: "building artifact '%{name}'"
14
+ git_artifact_loading: 'loading git_artifact'
13
15
  git_artifact_clone: "cloning remote git_artifact '%{name}'"
14
16
  git_artifact_fetch: "fetching remote git_artifact '%{name}'"
15
- berks_vendor: 'vendoring cookbooks'
16
- chef_cookbooks_stage_berks_vendor: 'vendoring cookbooks for chef cookbooks stage'
17
- gitartifact_container_loading: 'loading dappdeps/gitartifact container'
18
- chefdk_container_loading: 'loading dappdeps/chefdk container'
19
- system_shellout_container_loading: 'loading system shellout container'
17
+ chefdk_loading: 'loading chefdk'
18
+ berks_vendor: 'berks vendor'
19
+ waiting_resouce_lock: "waiting for locked resource '%{name}'"
20
20
  status:
21
21
  process:
22
22
  pushing: '[PUSHING]'
@@ -32,3 +32,32 @@ en:
32
32
  build: '[BUILD]'
33
33
  empty: '[EMPTY]'
34
34
  push: '[PUSH]'
35
+ warning:
36
+ excess_builder_instruction: "WARNING: Excessive use of the 'builder' instruction. Builder type will be automatically determined by the first use of any builder."
37
+ excess_name_instruction: "WARNING: Excessive use of the 'name' instruction. Given name corresponds to default name."
38
+ another_image_already_tagged: 'WARNING: image with other id already exist.'
39
+ group:
40
+ install_group: 'Install group'
41
+ setup_group: 'Setup group'
42
+ stage:
43
+ from: 'From'
44
+ before_install: 'Before install'
45
+ g_a_archive_dependencies: 'Git artifacts dependencies'
46
+ g_a_archive: 'Git artifacts: create archive'
47
+ install_group:
48
+ g_a_pre_install_patch_dependencies: 'Git artifacts dependencies'
49
+ g_a_pre_install_patch: 'Git artifacts: apply patches (before install)'
50
+ install: 'Install'
51
+ g_a_post_install_patch_dependencies: 'Git artifacts dependencies'
52
+ g_a_post_install_patch: 'Git artifacts: apply patches (after install)'
53
+ artifact: 'Artifact'
54
+ before_setup: 'Before setup'
55
+ setup_group:
56
+ g_a_pre_setup_patch_dependencies: 'Git artifacts dependencies'
57
+ g_a_pre_setup_patch: 'Git artifacts: apply patches (before setup)'
58
+ setup: 'Setup'
59
+ chef_cookbooks: 'Сhef сookbooks'
60
+ g_a_post_setup_patch_dependencies: 'Git artifacts dependencies'
61
+ g_a_post_setup_patch: 'Git artifacts: apply patches (after setup)'
62
+ g_a_latest_patch: 'Git artifacts: latest patch'
63
+ docker_instructions: 'Docker instructions'
@@ -8,25 +8,39 @@ en:
8
8
  application_not_run: "Application run failed!"
9
9
  git_branch_without_name: "Application has specific revision that isn't associated with a branch name!"
10
10
  ci_environment_required: 'CI environment required (Travis or GitLab CI)!'
11
+ cookbooks_stage_checksum_not_caclculated: "Cookbooks checksum not calculated for stage '%{stage}', run build first"
11
12
  dappfile:
12
13
  incorrect: "Dappfile with '%{error}':\n%{message}"
13
14
  build:
14
15
  from_image_required: 'Missing from_image!'
15
16
  image_already_untagged: "Image `%{name}` already untagged!"
16
17
  image_not_exist: "Image `%{name}` not exist!"
17
- another_image_already_tagged: 'Image with other id already tagged!'
18
18
  built_id_not_defined: '`from.built_id` not defined!'
19
- controller:
20
- push_command_unexpected_apps_number: "Push command can process only one application!"
21
- run_command_unexpected_apps_number: "Run command can process only one application!"
22
- no_such_app: "No such app: '%{patterns}'!"
19
+ from_image_not_found: 'Image `%{name}` not found!'
20
+ project:
21
+ spush_command_unexpected_apps_number: "Command 'spush' can process only one application!"
22
+ run_command_unexpected_apps_number: "Command 'run' can process only one application!"
23
+ no_such_app: "No such app: '%{apps_patterns}'!"
23
24
  dappfile_not_found: "Dappfile not found!"
25
+ cannot_run_ssh_agent: "Cannot run ssh-agent"
26
+ ssh_key_not_found: "Ssh key '%{path}' not exist!"
24
27
  config:
25
28
  builder_type_conflict: 'Conflict between builder types!'
26
29
  builder_type_unsupported: "Defined unsupported builder type `%{type}`!"
27
- docker_from_not_defined: "Docker `from` not defined!"
30
+ docker_from_not_defined: "`docker.from` not defined!"
28
31
  artifact_unexpected_attribute: "Artifact doesn't has attribute '%{attr}'!"
29
32
  git_artifact_unexpected_attribute: "'%{type}' git artifact doesn't has attribute '%{attr}'!"
33
+ docker_from_incorrect: "`docker.from` has incorrect value `%{name}`: expected format `image_name:tag`!"
30
34
  app_name_incorrect: "Application has incorrect name '%{name}': doesn't match regex '%{reg}'!"
31
35
  chef:
32
36
  stage_path_overlap: "Cannot install '%{cookbook}' cookbook's path %{from} into %{to}: already exists"
37
+ registry:
38
+ incorrect_repo: 'Incorrect repository!'
39
+ no_such_app: 'No such app in registry!'
40
+ authenticate_type_not_supported: 'Registry authenticate type not supported!'
41
+ not_found: 'Registry not found!'
42
+ user_not_authorized: 'User not authorized!'
43
+ response_with_error_status: 'Response with error status!'
44
+ berksfile_absolute_path_forbidden: "Absolute paths in Berksfile are not allowed (cookbook '%{cookbook}', path: '%{path}')"
45
+ lock:
46
+ timeout: "Could not obtain lock for '%{name}' within %{timeout} seconds"
@@ -20,28 +20,37 @@ require 'dapp/helper/cli'
20
20
  require 'dapp/helper/trivia'
21
21
  require 'dapp/helper/sha256'
22
22
  require 'dapp/helper/i18n'
23
- require 'dapp/helper/log'
24
23
  require 'dapp/helper/paint'
25
24
  require 'dapp/helper/streaming'
26
25
  require 'dapp/helper/shellout'
27
26
  require 'dapp/helper/net_status'
27
+ require 'dapp/prctl'
28
28
  require 'dapp/error/base'
29
29
  require 'dapp/error/application'
30
30
  require 'dapp/error/dappfile'
31
31
  require 'dapp/error/build'
32
32
  require 'dapp/error/config'
33
- require 'dapp/error/controller'
33
+ require 'dapp/error/project'
34
34
  require 'dapp/error/shellout'
35
+ require 'dapp/error/registry'
36
+ require 'dapp/exception/base'
37
+ require 'dapp/exception/introspect_image'
38
+ require 'dapp/exception/registry'
39
+ require 'dapp/lock/error'
40
+ require 'dapp/lock/base'
41
+ require 'dapp/lock/file'
35
42
  require 'dapp/cli'
36
43
  require 'dapp/cli/base'
37
44
  require 'dapp/cli/build'
38
45
  require 'dapp/cli/push'
39
- require 'dapp/cli/smartpush'
46
+ require 'dapp/cli/spush'
40
47
  require 'dapp/cli/list'
41
48
  require 'dapp/cli/stages'
42
49
  require 'dapp/cli/stages/flush'
43
50
  require 'dapp/cli/stages/cleanup'
44
51
  require 'dapp/cli/run'
52
+ require 'dapp/cli/cleanup'
53
+ require 'dapp/cli/bp'
45
54
  require 'dapp/filelock'
46
55
  require 'dapp/config/application'
47
56
  require 'dapp/config/main'
@@ -58,35 +67,54 @@ require 'dapp/builder/chef/berksfile'
58
67
  require 'dapp/builder/shell'
59
68
  require 'dapp/build/stage/mod/artifact'
60
69
  require 'dapp/build/stage/mod/logging'
70
+ require 'dapp/build/stage/mod/group'
61
71
  require 'dapp/build/stage/base'
62
- require 'dapp/build/stage/source_base'
63
- require 'dapp/build/stage/source_dependencies_base'
72
+ require 'dapp/build/stage/ga_base'
73
+ require 'dapp/build/stage/ga_dependencies_base'
64
74
  require 'dapp/build/stage/from'
65
- require 'dapp/build/stage/infra_install'
66
- require 'dapp/build/stage/infra_setup'
67
- require 'dapp/build/stage/install'
75
+ require 'dapp/build/stage/before_install'
76
+ require 'dapp/build/stage/ga_archive_dependencies'
77
+ require 'dapp/build/stage/ga_archive'
78
+ require 'dapp/build/stage/install/ga_pre_install_patch_dependencies'
79
+ require 'dapp/build/stage/install/ga_pre_install_patch'
80
+ require 'dapp/build/stage/install/install'
81
+ require 'dapp/build/stage/install/ga_post_install_patch_dependencies'
82
+ require 'dapp/build/stage/install/ga_post_install_patch'
68
83
  require 'dapp/build/stage/artifact'
69
- require 'dapp/build/stage/setup'
70
- require 'dapp/build/stage/chef_cookbooks'
71
- require 'dapp/build/stage/source_1_archive'
72
- require 'dapp/build/stage/source_1_archive_dependencies'
73
- require 'dapp/build/stage/source_1'
74
- require 'dapp/build/stage/source_1_dependencies'
75
- require 'dapp/build/stage/source_2'
76
- require 'dapp/build/stage/source_2_dependencies'
77
- require 'dapp/build/stage/source_3'
78
- require 'dapp/build/stage/source_3_dependencies'
79
- require 'dapp/build/stage/source_4'
80
- require 'dapp/build/stage/source_4_dependencies'
81
- require 'dapp/build/stage/source_5'
84
+ require 'dapp/build/stage/before_setup'
85
+ require 'dapp/build/stage/setup/ga_pre_setup_patch_dependencies'
86
+ require 'dapp/build/stage/setup/ga_pre_setup_patch'
87
+ require 'dapp/build/stage/setup/setup'
88
+ require 'dapp/build/stage/setup/chef_cookbooks'
89
+ require 'dapp/build/stage/setup/ga_post_setup_patch_dependencies'
90
+ require 'dapp/build/stage/setup/ga_post_setup_patch'
91
+ require 'dapp/build/stage/ga_latest_patch'
82
92
  require 'dapp/build/stage/docker_instructions'
83
- require 'dapp/controller'
93
+ require 'dapp/project/lock'
94
+ require 'dapp/project/ssh_agent'
95
+ require 'dapp/project/dappfile'
96
+ require 'dapp/project/paint'
97
+ require 'dapp/project/command/build'
98
+ require 'dapp/project/command/bp'
99
+ require 'dapp/project/command/cleanup'
100
+ require 'dapp/project/command/common'
101
+ require 'dapp/project/command/list'
102
+ require 'dapp/project/command/push'
103
+ require 'dapp/project/command/run'
104
+ require 'dapp/project/command/spush'
105
+ require 'dapp/project/command/stages_flush'
106
+ require 'dapp/project/command/stages_cleanup'
107
+ require 'dapp/project/logging/base'
108
+ require 'dapp/project/logging/process'
109
+ require 'dapp/project'
110
+ require 'dapp/docker_registry'
111
+ require 'dapp/docker_registry/mod/request'
112
+ require 'dapp/docker_registry/mod/authorization'
113
+ require 'dapp/docker_registry/base'
114
+ require 'dapp/docker_registry/default'
84
115
  require 'dapp/application/git_artifact'
85
- require 'dapp/application/logging'
86
116
  require 'dapp/application/path'
87
117
  require 'dapp/application/tags'
88
- require 'dapp/application/deps/gitartifact'
89
- require 'dapp/application/system_shellout'
90
118
  require 'dapp/application'
91
119
  require 'dapp/image/argument'
92
120
  require 'dapp/image/docker'
@@ -95,8 +123,6 @@ require 'dapp/git_repo/base'
95
123
  require 'dapp/git_repo/own'
96
124
  require 'dapp/git_repo/remote'
97
125
  require 'dapp/git_artifact'
98
- require 'dapp/exception/base'
99
- require 'dapp/exception/introspect_image'
100
126
 
101
127
  # Dapp
102
128
  module Dapp
@@ -1,54 +1,63 @@
1
1
  module Dapp
2
2
  # Application
3
3
  class Application
4
- include Helper::Log
5
- include Helper::Shellout
6
- include Helper::I18n
7
- include Helper::Sha256
8
- include Logging
9
4
  include GitArtifact
10
5
  include Path
11
6
  include Tags
12
- include Deps::Gitartifact
13
- include SystemShellout
14
- include Dapp::Filelock
7
+
8
+ include Helper::Sha256
15
9
 
16
10
  attr_reader :config
17
- attr_reader :cli_options
18
11
  attr_reader :ignore_git_fetch
12
+ attr_reader :should_be_built
19
13
  attr_reader :is_artifact
14
+ attr_reader :project
20
15
 
21
- def initialize(config:, cli_options:, ignore_git_fetch: false, is_artifact: false)
16
+ def initialize(config:, project:, should_be_built: false, ignore_git_fetch: false, is_artifact: false)
22
17
  @config = config
23
- @cli_options = cli_options
18
+ @project = project
24
19
 
25
- @tmp_path = Dir.mktmpdir(cli_options[:tmp_dir_prefix] || 'dapp-')
26
- @build_path = cli_options[:build_dir] || home_path('.dapps-build')
20
+ @tmp_path = Dir.mktmpdir(project.cli_options[:tmp_dir_prefix] || 'dapp-')
27
21
 
28
22
  @last_stage = Build::Stage::DockerInstructions.new(self)
29
23
  @ignore_git_fetch = ignore_git_fetch
24
+ @should_be_built = should_be_built
30
25
  @is_artifact = is_artifact
31
26
  end
32
27
 
33
28
  def build!
29
+ raise Error::Application, code: :application_not_built if should_be_built && !last_stage.image.tagged?
30
+
34
31
  with_introspection do
35
- last_stage.build!
36
- last_stage.save_in_cache!
32
+ project.lock("#{config._basename}.images", shared: true) do
33
+ last_stage.build_lock! do
34
+ last_stage.build!
35
+ last_stage.save_in_cache!
36
+ end
37
+ end
37
38
  end
38
39
  ensure
39
40
  FileUtils.rm_rf(tmp_path)
40
41
  end
41
42
 
42
- def export!(repo)
43
- raise Error::Application, code: :application_not_built unless last_stage.image.tagged? || dry_run?
43
+ def export!(repo, format:)
44
+ builder.before_application_export
45
+
46
+ raise Error::Application, code: :application_not_built unless last_stage.image.tagged? || project.dry_run?
44
47
 
45
- tags.each do |tag|
46
- image_name = [repo, tag].join(':')
47
- if dry_run?
48
- log_state(image_name, state: t(code: 'state.push'), styles: { status: :success })
49
- else
50
- log_process(image_name, process: t(code: 'status.process.pushing')) do
51
- last_stage.image.export!(image_name, log_verbose: log_verbose?, log_time: log_time?, force: cli_options[:force])
48
+ project.lock("#{config._basename}.images", shared: true) do
49
+ tags.each do |tag|
50
+ image_name = format % { repo: repo, application_name: config._name, tag: tag }
51
+ if project.dry_run?
52
+ project.log_state(image_name, state: project.t(code: 'state.push'), styles: { status: :success })
53
+ else
54
+ project.lock("image.#{image_name.gsub('/', '__')}") do
55
+ Dapp::Image::Stage.cache_reset(image_name)
56
+ project.log_process(image_name, process: project.t(code: 'status.process.pushing')) do
57
+ last_stage.image.export!(image_name, log_verbose: project.log_verbose?,
58
+ log_time: project.log_time?)
59
+ end
60
+ end
52
61
  end
53
62
  end
54
63
  end
@@ -57,8 +66,8 @@ module Dapp
57
66
  def run(docker_options, command)
58
67
  raise Error::Application, code: :application_not_built unless last_stage.image.tagged?
59
68
  cmd = "docker run #{[docker_options, last_stage.image.name, command].flatten.compact.join(' ')}"
60
- if dry_run?
61
- log_info(cmd)
69
+ if project.dry_run?
70
+ project.log_info(cmd)
62
71
  else
63
72
  system(cmd) || raise(Error::Application, code: :application_not_run)
64
73
  end
@@ -68,6 +77,18 @@ module Dapp
68
77
  last_stage.send(:signature)
69
78
  end
70
79
 
80
+ def stage_cache_format
81
+ "#{project.cache_format % { application_name: config._basename }}:%{signature}"
82
+ end
83
+
84
+ def stage_dapp_label
85
+ project.stage_dapp_label_format % { application_name: config._basename }
86
+ end
87
+
88
+ def artifact(config)
89
+ self.class.new(config: config, project: project, ignore_git_fetch: ignore_git_fetch, is_artifact: true, should_be_built: should_be_built)
90
+ end
91
+
71
92
  def builder
72
93
  @builder ||= Builder.const_get(config._builder.capitalize).new(self)
73
94
  end
@@ -80,7 +101,7 @@ module Dapp
80
101
  data = e.net_status[:data]
81
102
  cmd = "docker run -ti --rm --entrypoint /bin/bash #{data[:options]} #{data[:built_id]}"
82
103
  system(cmd).tap do |res|
83
- shellout!("docker rmi #{data[:built_id]}") if data[:rmi]
104
+ project.shellout!("docker rmi #{data[:built_id]}") if data[:rmi]
84
105
  res || raise(Error::Application, code: :application_not_run)
85
106
  end
86
107
  exit 0
@@ -16,7 +16,7 @@ module Dapp
16
16
 
17
17
  def remote_git_artifacts
18
18
  @remote_git_artifact_list ||= Array(config._git_artifact._remote).map do |ga_config|
19
- repo = GitRepo::Remote.new(self, ga_config._name, url: ga_config._url, ssh_key_path: ga_config._ssh_key_path)
19
+ repo = GitRepo::Remote.new(self, ga_config._name, url: ga_config._url)
20
20
  repo.fetch!(ga_config._branch)
21
21
  Dapp::GitArtifact.new(repo, **ga_config._artifact_options)
22
22
  end
@@ -11,18 +11,8 @@ module Dapp
11
11
  make_path(@tmp_path, *path).expand_path.tap { |p| p.parent.mkpath }
12
12
  end
13
13
 
14
- def build_path(*path)
15
- make_path(@build_path, home_path.basename, *path).expand_path.tap { |p| p.parent.mkpath }
16
- end
17
-
18
- def project_path
19
- @project_path ||= begin
20
- if File.basename(expand_path(home_path, 1)) == '.dapps'
21
- expand_path(home_path, 2)
22
- else
23
- home_path
24
- end
25
- end
14
+ def build_path
15
+ project.build_path.join(config._basename)
26
16
  end
27
17
 
28
18
  def container_dapp_path(*path)
@@ -38,12 +28,6 @@ module Dapp
38
28
  def make_path(base, *path)
39
29
  path.compact.map(&:to_s).inject(Pathname.new(base), &:+)
40
30
  end
41
-
42
- def expand_path(path, number = 1)
43
- path = File.expand_path(path)
44
- number.times.each { path = File.dirname(path) }
45
- path
46
- end
47
31
  end # Path
48
32
  end # Application
49
33
  end # Dapp
@@ -16,23 +16,23 @@ module Dapp
16
16
  end
17
17
 
18
18
  def simple_tags
19
- cli_options[:tag]
19
+ project.cli_options[:tag]
20
20
  end
21
21
 
22
22
  def branch_tags
23
- return [] unless cli_options[:tag_branch]
23
+ return [] unless project.cli_options[:tag_branch]
24
24
  raise Error::Application, code: :git_branch_without_name if (branch = git_repo.branch) == 'HEAD'
25
25
  [branch]
26
26
  end
27
27
 
28
28
  def commit_tags
29
- return [] unless cli_options[:tag_commit]
29
+ return [] unless project.cli_options[:tag_commit]
30
30
  commit = git_repo.latest_commit
31
31
  [commit]
32
32
  end
33
33
 
34
34
  def build_tags
35
- return [] unless cli_options[:tag_build_id]
35
+ return [] unless project.cli_options[:tag_build_id]
36
36
 
37
37
  if ENV['GITLAB_CI']
38
38
  build_id = ENV['CI_BUILD_ID']
@@ -46,7 +46,7 @@ module Dapp
46
46
  end
47
47
 
48
48
  def ci_tags
49
- return [] unless cli_options[:tag_ci]
49
+ return [] unless project.cli_options[:tag_ci]
50
50
 
51
51
  if ENV['GITLAB_CI']
52
52
  branch = ENV['CI_BUILD_REF_NAME']