indocker 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b625051ee86d20ec224e8f277b5fc884ce7c02ef671a18533836e9e654c1fcf
4
- data.tar.gz: 1867b3210ab2134bd52366a2ded1abc0e24ef122ecc8337a5213f5f0460526a5
3
+ metadata.gz: b26827edabc3dcae5d27465689bcfa96fc00f7649eecb978af3f766dbf834a78
4
+ data.tar.gz: 30bcfaa047bc22995b77cb695ff58d7624d6a3702b97c99df900bbaddd3e9e18
5
5
  SHA512:
6
- metadata.gz: 8298028d5eea2ac46b1ebf67fb5b19b0846c96a1bc731b6717869412f802d7781d3ee80fa15e7ae75336f5fa878fa9ea90fcfbb5e7a668bcc500d2f5bc4a97d5
7
- data.tar.gz: 9f2a4091d1def4b6f86aef36c240a5f5439ee0c604f516b7f52b215b7285b53cbe41800530e517ee97159bda7b99665bfa9a1cf92371e7011c9671f15ddf20b1
6
+ metadata.gz: 8c518149fae3e281c98d1620abc68cb192c741843dd583121e0e6cc3c7b24802fe33d5ebf8b257677fba77b64ce052a474d73b9a9efdb9045222d64f34d9f266
7
+ data.tar.gz: 1ca41ab244943db566081ac81efdf1ffb0f4a886ce480b39e8d55c595757de249df2c33321ab82a1cee6f0807695ad827cf7218907420802087066b7125b5099
data/Gemfile.lock CHANGED
@@ -1,12 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- indocker (0.1.1)
4
+ indocker (0.1.2)
5
+ net-ssh
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
8
9
  specs:
9
10
  diff-lcs (1.3)
11
+ net-ssh (5.2.0)
10
12
  rake (10.5.0)
11
13
  rspec (3.9.0)
12
14
  rspec-core (~> 3.9.0)
data/README.md CHANGED
@@ -4,29 +4,16 @@ Docker Containers Deployment
4
4
 
5
5
  ## Installation
6
6
 
7
- Add this line to your application's Gemfile:
8
-
9
- ```ruby
10
- gem 'indocker'
7
+ ```
8
+ $ gem install indocker
11
9
  ```
12
10
 
13
- And then execute:
14
-
15
- $ bundle
16
-
17
- Or install it yourself as:
18
-
19
- $ gem install indocker
20
-
21
- ## Usage
22
-
23
- TODO: Write usage instructions here
24
-
25
- ## Development
26
-
27
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
11
+ ## Development: Launch example app
28
12
 
29
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
13
+ ```ruby
14
+ cd example
15
+ bundle exec indocker/bin/deploy -C dev -c ruby -d
16
+ ```
30
17
 
31
18
  ## License
32
19
 
@@ -0,0 +1,120 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require_relative 'utils/configurations'
5
+
6
+ configurations = list_configurations(File.expand_path(File.join(__dir__, '../configurations')))
7
+
8
+ ARGV << '-h' if ARGV.empty?
9
+
10
+ options = {
11
+ skip_build: false,
12
+ force_restart: false,
13
+ skip_tags: [],
14
+ skip_force_restart: [],
15
+ }
16
+
17
+ OptionParser.new do |opts|
18
+ opts.banner = "Usage: indocker/bin/deploy [options]"
19
+
20
+ opts.on("-d", "--debug", "Debug mode") do |val|
21
+ options[:debug] = true
22
+ end
23
+
24
+ opts.on("-C", "--configuration REQUIRED", String, "Configuration name") do |val|
25
+ options[:configuration] = val
26
+ end
27
+
28
+ opts.on("-c", "--container OPTIONAL", String, "Deploy by container name") do |val|
29
+ options[:containers] ||= []
30
+ options[:containers].push(val.to_sym)
31
+ end
32
+
33
+ opts.on("-t", "--tag OPTIONAL", String, "Deploy containers by tag") do |val|
34
+ options[:tags] ||= []
35
+ options[:tags].push(val)
36
+ end
37
+
38
+ opts.on("-s", "--skip OPTIONAL", String, "Skip container during deployment") do |val|
39
+ options[:skip_containers] ||= []
40
+ options[:skip_containers] << val.to_sym
41
+ end
42
+
43
+ opts.on("-S", "--server OPTIONAL", String, "Deploy containers that include specfic server") do |val|
44
+ options[:servers] ||= []
45
+ options[:servers].push(val.to_sym)
46
+ end
47
+
48
+ opts.on("-D", "--skip-dependent", "Do not deploy dependent containers") do |val|
49
+ options[:skip_dependent] = true
50
+ end
51
+
52
+ opts.on("-f", "--force-restart", "Force to restart each container") do |val|
53
+ options[:force_restart] = true
54
+ end
55
+
56
+ opts.on("-F", "--skip-force-restart OPTIONAL", "Skip force restart of specific container for force restart mode") do |val|
57
+ options[:skip_force_restart].push(val.to_sym)
58
+ end
59
+
60
+ opts.on("-B", "--skip-build", "Skip image build") do |val|
61
+ options[:skip_build] = true
62
+ end
63
+
64
+ opts.on("-y", "--auto-confirm", "Automatically confirm deployment") do |val|
65
+ options[:auto_confirm] = true
66
+ end
67
+
68
+ opts.on("-r", "--require-confirmation", "Require deploy confirmation") do |val|
69
+ options[:require_confirmation] = true
70
+ end
71
+
72
+ opts.on("-T", "--skip-tag OPTIONAL", "Skip containers tagged by specific tags") do |val|
73
+ options[:skip_tags].push(val)
74
+ end
75
+
76
+ opts.on_tail("-h", "--help", "Show help") do
77
+ puts opts
78
+ exit
79
+ end
80
+ end.parse!
81
+
82
+ if !options.has_key?(:configuration)
83
+ puts "You should specify configuration using -C or --configuration option.\nAvailable configurations: #{configurations.sort.join(', ')}"
84
+ exit 1
85
+ end
86
+
87
+ if !configurations.include?(options[:configuration])
88
+ puts "Invalid configuration provided: #{options[:configuration]}.\nAvailable configurations: #{configurations.inspect}"
89
+ exit 1
90
+ end
91
+
92
+ begin
93
+ require 'indocker'
94
+ rescue LoadError
95
+ puts "InDocker has been moved into a separate gem. Please install using `gem install indocker`"
96
+ exit
97
+ end
98
+
99
+ if options[:debug]
100
+ Indocker.set_log_level(Logger::DEBUG)
101
+ else
102
+ Indocker.set_log_level(Logger::INFO)
103
+ end
104
+
105
+ Indocker.set_configuration_name(options[:configuration])
106
+ require_relative '../setup'
107
+
108
+ Indocker.deploy(
109
+ containers: options[:containers] || [],
110
+ tags: options[:tags] || [],
111
+ skip_containers: options[:skip_containers] || [],
112
+ skip_dependent: !!options[:skip_dependent],
113
+ servers: options[:servers] || [],
114
+ skip_build: options[:skip_build],
115
+ force_restart: options[:force_restart],
116
+ skip_tags: options[:skip_tags] || [],
117
+ skip_force_restart: options[:skip_force_restart] || [],
118
+ auto_confirm: !!options[:auto_confirm],
119
+ require_confirmation: !!options[:require_confirmation],
120
+ )
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require_relative '../utils/configurations'
5
+
6
+ configurations = list_configurations(File.expand_path(File.join(__dir__, '../../configurations')))
7
+
8
+ ARGV << '-h' if ARGV.empty?
9
+
10
+ options = {}
11
+
12
+ OptionParser.new do |opts|
13
+ opts.banner = "Usage: indocker/bin/remote/compile [options] (only on remote server)"
14
+
15
+ opts.on("-C", "--configuration REQUIRED", String, "Configuration name") do |val|
16
+ options[:configuration] = val
17
+ end
18
+
19
+ opts.on("-d", "--debug", "Debug mode") do |val|
20
+ options[:debug] = true
21
+ end
22
+
23
+ opts.on("-i", "--image REQUIRED", String, "Image to be compiled") do |val|
24
+ options[:images] ||= []
25
+ options[:images].push(val.to_sym)
26
+ end
27
+
28
+ opts.on("-s", "--skip-dependent", String, "Do not compile dependent images") do |val|
29
+ options[:skip_dependent] = true
30
+ end
31
+
32
+ opts.on_tail("-h", "--help", "Show help") do
33
+ puts opts
34
+ exit
35
+ end
36
+ end.parse!
37
+
38
+ if !options.has_key?(:configuration)
39
+ puts "You should specify configuration using -C or --configuration option.\nAvailable configurations: #{configurations.sort.join(', ')}"
40
+ exit 1
41
+ end
42
+
43
+ if !configurations.include?(options[:configuration])
44
+ puts "Invalid configuration provided: #{options[:configuration]}.\nAvailable configurations: #{configurations.inspect}"
45
+ exit 1
46
+ end
47
+
48
+ if !options.has_key?(:images)
49
+ puts "At least one image should be provided"
50
+ end
51
+
52
+ begin
53
+ require 'indocker'
54
+ rescue LoadError
55
+ puts "InDocker has been moved into a separate gem. Please install using `gem install indocker`"
56
+ exit 1
57
+ end
58
+
59
+ if options[:debug]
60
+ Indocker.set_log_level(Logger::DEBUG)
61
+ else
62
+ Indocker.set_log_level(Logger::INFO)
63
+ end
64
+
65
+ Indocker.set_configuration_name(options[:configuration])
66
+ require_relative '../../setup'
67
+
68
+
69
+ Indocker.compile(
70
+ images: options[:images] || [],
71
+ skip_dependent: !!options[:skip_dependent]
72
+ )
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require_relative '../utils/configurations'
5
+
6
+ configurations = list_configurations(File.expand_path(File.join(__dir__, '../../configurations')))
7
+
8
+ ARGV << '-h' if ARGV.empty?
9
+
10
+ options = {
11
+ force_restart: false,
12
+ }
13
+
14
+ OptionParser.new do |opts|
15
+ opts.banner = "Usage: indocker/bin/remote/run [options] (only on remove server)"
16
+
17
+ opts.on("-C", "--configuration REQUIRED", String, "Configuration name") do |val|
18
+ options[:configuration] = val
19
+ end
20
+
21
+ opts.on("-d", "--debug", "Debug mode") do |val|
22
+ options[:debug] = true
23
+ end
24
+
25
+ opts.on("-c", "--container REQUIRED", String, "Container name") do |val|
26
+ options[:container] = val.to_sym
27
+ end
28
+
29
+ opts.on("-f", "--force-restart", "Force to restart each container") do |val|
30
+ options[:force_restart] = true
31
+ end
32
+
33
+ opts.on_tail("-h", "--help", "Show help") do
34
+ puts opts
35
+ exit
36
+ end
37
+ end.parse!
38
+
39
+ if !options.has_key?(:configuration)
40
+ puts "You should specify configuration using -C or --configuration option.\nAvailable configurations: #{configurations.sort.join(', ')}"
41
+ exit 1
42
+ end
43
+
44
+ if !configurations.include?(options[:configuration])
45
+ puts "Invalid configuration provided: #{options[:configuration]}.\nAvailable configurations: #{configurations.inspect}"
46
+ exit 1
47
+ end
48
+
49
+ begin
50
+ require 'indocker'
51
+ rescue LoadError
52
+ puts "InDocker has been moved into a separate gem. Please install using `gem install indocker`"
53
+ exit 1
54
+ end
55
+
56
+ if options[:debug]
57
+ Indocker.set_log_level(Logger::DEBUG)
58
+ else
59
+ Indocker.set_log_level(Logger::INFO)
60
+ end
61
+
62
+ Indocker.set_configuration_name(options[:configuration])
63
+ require_relative '../../setup'
64
+
65
+
66
+ Indocker.run(options[:container], options[:force_restart])
@@ -0,0 +1,3 @@
1
+ def list_configurations(configurations_dir)
2
+ Dir[File.join(configurations_dir, '**/*.rb')].map {|c| c.split('/').last.gsub('.rb', '')}
3
+ end
@@ -0,0 +1,10 @@
1
+ FROM ruby:2.5.0
2
+
3
+ RUN dpkg --add-architecture i386 \
4
+ && apt-get update \
5
+ && apt-get install vim curl -y \
6
+ && apt-get clean \
7
+ && rm -rf /var/lib/apt/lists/*
8
+
9
+ RUN mkdir /app
10
+ WORKDIR /app
@@ -0,0 +1,5 @@
1
+ Indocker
2
+ .define_container(:ruby)
3
+ .tags('ruby', 'console=true')
4
+ .image(:ruby)
5
+ .networks(:app_net)
@@ -0,0 +1,3 @@
1
+ Indocker
2
+ .define_image(:ruby)
3
+ .registry(:default)
@@ -0,0 +1,9 @@
1
+ Indocker
2
+ .build_configuration(:dev)
3
+ .use_registry(:dev, as: :default)
4
+ .use_build_server(:local_bs)
5
+ .enabled_containers(
6
+ ruby: {
7
+ servers: [:localhost],
8
+ }
9
+ )
@@ -0,0 +1,8 @@
1
+ Indocker.add_build_server(
2
+ Indocker::BuildServer.new(
3
+ name: :local_bs,
4
+ host: 'localhost',
5
+ user: `whoami`.strip,
6
+ port: 22
7
+ )
8
+ )
@@ -0,0 +1 @@
1
+ Indocker.define_network(:app_net)
@@ -0,0 +1,3 @@
1
+ Indocker.add_registry(
2
+ Indocker::Registries::Local.new(:dev)
3
+ )
@@ -0,0 +1,8 @@
1
+ Indocker.add_server(
2
+ Indocker::Server.new(
3
+ name: :localhost,
4
+ host: 'localhost',
5
+ user: `whoami`.strip,
6
+ port: 22
7
+ )
8
+ )
@@ -0,0 +1,24 @@
1
+ require 'indocker'
2
+
3
+ root_dir = File.join(__dir__, '..', '..')
4
+
5
+ Indocker.set_root_dir(__dir__)
6
+ Indocker.set_deploy_dir(File.join(root_dir, 'tmp', 'deployment'))
7
+
8
+ Indocker.set_dockerignore [
9
+ 'Dockerfile',
10
+ '.DS_Store',
11
+ '**/.DS_Store',
12
+ '**/*.log',
13
+ '.vscode',
14
+ 'tmp',
15
+ ]
16
+
17
+ require_relative 'infrastructure/registries'
18
+ require_relative 'infrastructure/servers'
19
+ require_relative 'infrastructure/build_servers'
20
+ require_relative 'infrastructure/networks'
21
+
22
+ Indocker.set_bounded_contexts_dir(File.join(__dir__, 'bounded_contexts'))
23
+
24
+ require_relative "configurations/#{Indocker.configuration_name}"
data/indocker.gemspec CHANGED
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
24
  spec.require_paths = ["lib"]
25
25
 
26
+ spec.add_dependency "net-ssh"
26
27
  spec.add_development_dependency "bundler", "~> 1.17"
27
28
  spec.add_development_dependency "rake", "~> 10.0"
28
29
  spec.add_development_dependency "rspec", "~> 3.0"
@@ -60,6 +60,14 @@ class Indocker::DockerRunArgs
60
60
  end
61
61
  end
62
62
 
63
+ sysctl = container.get_start_option(:sysctl)
64
+
65
+ if sysctl
66
+ Array(sysctl).each do |val|
67
+ args.push("--sysctl #{val}")
68
+ end
69
+ end
70
+
63
71
  if container.is_daemonized?
64
72
  args.push("--detach")
65
73
  end
@@ -1,3 +1,3 @@
1
1
  module Indocker
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: indocker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruslan Gatiyatov
@@ -9,8 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2020-01-10 00:00:00.000000000 Z
12
+ date: 2020-04-13 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: net-ssh
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
14
28
  - !ruby/object:Gem::Dependency
15
29
  name: bundler
16
30
  requirement: !ruby/object:Gem::Requirement
@@ -70,6 +84,19 @@ files:
70
84
  - Rakefile
71
85
  - bin/console
72
86
  - bin/setup
87
+ - example/indocker/bin/deploy
88
+ - example/indocker/bin/remote/compile
89
+ - example/indocker/bin/remote/run
90
+ - example/indocker/bin/utils/configurations.rb
91
+ - example/indocker/bounded_contexts/shared/ruby/Dockerfile
92
+ - example/indocker/bounded_contexts/shared/ruby/container.rb
93
+ - example/indocker/bounded_contexts/shared/ruby/image.rb
94
+ - example/indocker/configurations/dev.rb
95
+ - example/indocker/infrastructure/build_servers.rb
96
+ - example/indocker/infrastructure/networks.rb
97
+ - example/indocker/infrastructure/registries.rb
98
+ - example/indocker/infrastructure/servers.rb
99
+ - example/indocker/setup.rb
73
100
  - indocker.gemspec
74
101
  - lib/indocker.rb
75
102
  - lib/indocker/artifacts/git.rb
@@ -147,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
174
  - !ruby/object:Gem::Version
148
175
  version: '0'
149
176
  requirements: []
150
- rubygems_version: 3.0.6
177
+ rubygems_version: 3.0.8
151
178
  signing_key:
152
179
  specification_version: 4
153
180
  summary: Docker Containers Deployment