smartcloud 0.2.0 → 0.3.0

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: 77ed71de3cc780a8cd8672f942b0f31691309159dc941b88bef8be0fbfc36561
4
- data.tar.gz: db7906edf628c1d762415148c1932bd86feb01dfee647c7ca8b075f095689432
3
+ metadata.gz: 85369e5e6c9d09e3120c224b6032b3498bd4d7f9fa896245b2f65f601f9c6c88
4
+ data.tar.gz: cde8d32810801ed981f0359dcc82b2fb837cdd10c79c9524c9db248f9fe6379e
5
5
  SHA512:
6
- metadata.gz: 07f54bcb600bdeaef2405a741b9a05b7522264d517d7999a5b7dbbec0214d5552deba01567862b458e1c94fea0acd97e1aef2b574ff71d9e5c9b1af0e8490d05
7
- data.tar.gz: a29bcfb7e3c84b5de7038ce9148a1d17772b26535aac05665b0c56b610c2d06c2a663fcbf023150e990fe20c6081d738c74934896c277e61855670118b78f69b
6
+ metadata.gz: f972998785f3eb1931992ae1512e1510f363151fee1c3a328fc422a15a5351bdd1d120f149ee43636dadafcdbdde33f8f906fb1c88db045b6b1c4530bb1c4ed6
7
+ data.tar.gz: d87aa2dec7bb4620bf5ecc9329afe1b53335da305b21e4b0035b81d65fec755243583bde24184cdfeaca560ad7b95ad943aa1fa22f3e1dfbeb2d4296e1f29208
data/README.md CHANGED
@@ -1,4 +1,6 @@
1
1
  # SmartCloud
2
+ Git push should deploy.
3
+
2
4
  Smartcloud is a full-stack deployment framework for Rails optimized for programmer happiness and peaceful administration. It encourages natural simplicity by favoring convention over configuration.
3
5
 
4
6
  Deploy your Rails apps to your own server with - git push production master
@@ -55,16 +55,16 @@ module Smartcloud
55
55
  --volume='#{Smartcloud.config.user_home_path}/.smartcloud/config:#{Smartcloud.config.user_home_path}/.smartcloud/config' \
56
56
  --volume='#{container_path_with_version}:/app' \
57
57
  --volume='#{container_path}/app/vendor/bundle:/app/vendor/bundle' \
58
- --volume='#{container_path}/app/public:/app/public/assets' \
59
- --volume='#{container_path}/app/public:/app/public/packs' \
58
+ --volume='#{container_path}/app/public/assets:/app/public/assets' \
59
+ --volume='#{container_path}/app/public/packs:/app/public/packs' \
60
60
  --volume='#{container_path}/app/node_modules:/app/node_modules' \
61
61
  --restart='always' \
62
62
  --init \
63
63
  --network='nginx-network' \
64
64
  smartcloud/buildpacks/rails", out: File::NULL)
65
65
 
66
- # system("docker network connect solr-network #{new_container}")
67
66
  system("docker network connect mysql-network #{new_container}")
67
+ system("docker network connect elasticsearch-network #{new_container}")
68
68
 
69
69
  if system("docker start --attach #{new_container}")
70
70
  logger.debug "Starting Web Server ..."
@@ -17,6 +17,7 @@ require 'smartcloud/buildpacker'
17
17
 
18
18
  require 'smartcloud/user'
19
19
 
20
+ require 'smartcloud/grids/elasticsearch'
20
21
  require 'smartcloud/grids/mysql'
21
22
  require 'smartcloud/grids/nginx'
22
23
  require 'smartcloud/grids/prereceiver'
@@ -65,6 +65,9 @@ module Smartcloud
65
65
  password: #{SecureRandom.hex(16)}
66
66
  database_name: #{SecureRandom.hex(4)}_production
67
67
 
68
+ elasticsearch:
69
+ port: 9200
70
+
68
71
  redmine:
69
72
  admin_username: admin
70
73
  admin_password: #{SecureRandom.hex(16)}
@@ -17,15 +17,16 @@ module Smartcloud
17
17
 
18
18
  puts "-----> Installing Docker"
19
19
  commands = [
20
- "sudo apt-get update",
21
- "sudo apt-get install apt-transport-https ca-certificates curl software-properties-common",
20
+ "sudo apt-get -y update",
21
+ "sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common",
22
22
  "curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -",
23
23
  "sudo apt-key fingerprint 0EBFCD88",
24
24
  "sudo add-apt-repository \"deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable\"",
25
- "sudo apt-get update",
26
- "sudo apt-get install docker-ce",
25
+ "sudo apt-get -y update",
26
+ "sudo apt-get -y install docker-ce",
27
27
  "sudo usermod -aG docker $USER",
28
- "docker run --rm hello-world"
28
+ "docker run --rm hello-world",
29
+ "docker rmi hello-world"
29
30
  ]
30
31
  ssh.run commands
31
32
 
@@ -0,0 +1,91 @@
1
+ # The main Smartcloud Grids Elasticsearch driver
2
+ module Smartcloud
3
+ module Grids
4
+ class Elasticsearch < Smartcloud::Base
5
+ def initialize
6
+ end
7
+
8
+ def install
9
+ self.uninstall
10
+
11
+ print "-----> Creating settings for elasticsearch ... "
12
+
13
+ vm_max_map_count_filepath = "~/.smartcloud/grids/grid-elasticsearch/vm_max_map_count"
14
+ ssh = Smartcloud::SSH.new
15
+ ssh.run "sudo sysctl -b vm.max_map_count > #{vm_max_map_count_filepath}"
16
+ ssh.run "sudo sysctl -w vm.max_map_count=262144"
17
+
18
+ puts "done"
19
+ end
20
+
21
+ def uninstall
22
+ print "-----> Removing settings for elasticsearch ... "
23
+
24
+ vm_max_map_count_filepath = "~/.smartcloud/grids/grid-elasticsearch/vm_max_map_count"
25
+ ssh = Smartcloud::SSH.new
26
+ ssh.run "test -f #{vm_max_map_count_filepath} && sudo sysctl -w vm.max_map_count=$(cat #{vm_max_map_count_filepath})"
27
+ ssh.run "test -f #{vm_max_map_count_filepath} && rm #{vm_max_map_count_filepath}"
28
+
29
+ puts "done"
30
+ end
31
+
32
+ def self.up(*args)
33
+ args.flatten!
34
+ exposed = args.empty? ? '' : args.shift
35
+
36
+ if Smartcloud::Docker.running?
37
+ # Creating networks
38
+ unless system("docker network inspect elasticsearch-network", [:out, :err] => File::NULL)
39
+ print "-----> Creating network elasticsearch-network ... "
40
+ if system("docker network create elasticsearch-network", out: File::NULL)
41
+ puts "done"
42
+ end
43
+ end
44
+
45
+ # Creating & Starting containers
46
+ print "-----> Creating container elasticsearch ... "
47
+ if system("docker create \
48
+ --name='elasticsearch' \
49
+ --env discovery.type=single-node \
50
+ --env cluster.name=elasticsearch-cluster \
51
+ --env bootstrap.memory_lock=true \
52
+ --env 'ES_JAVA_OPTS=-Xms512m -Xmx512m -Des.enforce.bootstrap.checks=true' \
53
+ --ulimit memlock=-1:-1 \
54
+ --user `id -u`:`id -g` \
55
+ #{"--publish='#{Smartcloud.credentials.elasticsearch[:port]}:#{Smartcloud.credentials.elasticsearch[:port]}'" if exposed == '--exposed'} \
56
+ --volume='#{Smartcloud.config.user_home_path}/.smartcloud/grids/grid-elasticsearch/data:/usr/share/elasticsearch/data' \
57
+ --restart='always' \
58
+ --network='elasticsearch-network' \
59
+ elasticsearch:7.4.1", out: File::NULL)
60
+
61
+ puts "done"
62
+ print "-----> Starting container elasticsearch ... "
63
+ if system("docker start elasticsearch", out: File::NULL)
64
+ puts "done"
65
+ end
66
+ end
67
+ end
68
+ end
69
+
70
+ def self.down
71
+ if Smartcloud::Docker.running?
72
+ # Stopping & Removing containers - in reverse order
73
+ print "-----> Stopping container elasticsearch ... "
74
+ if system("docker stop 'elasticsearch'", out: File::NULL)
75
+ puts "done"
76
+ print "-----> Removing container elasticsearch ... "
77
+ if system("docker rm 'elasticsearch'", out: File::NULL)
78
+ puts "done"
79
+ end
80
+ end
81
+
82
+ # Removing networks
83
+ print "-----> Removing network elasticsearch-network ... "
84
+ if system("docker network rm elasticsearch-network", out: File::NULL)
85
+ puts "done"
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
@@ -122,6 +122,9 @@ module Smartcloud
122
122
  logger.fatal "This version name already exists ... Failed."
123
123
  return
124
124
  end
125
+ else
126
+ # Allow the push to complete for all other branches normally.
127
+ exit 10
125
128
  end
126
129
 
127
130
  logger.formatter = nil
@@ -22,6 +22,7 @@ module Smartcloud
22
22
  --env REDMINE_DB_PASSWORD=#{Smartcloud.credentials.redmine[:database_password]} \
23
23
  --env REDMINE_DB_DATABASE=#{Smartcloud.credentials.redmine[:database_name]} \
24
24
  --env REDMINE_PLUGINS_MIGRATE=#{Smartcloud.credentials.redmine[:plugins_migrate]} \
25
+ --volume='#{Smartcloud.config.user_home_path}/.smartcloud/apps/repositories:/repositories:ro' \
25
26
  --volume='#{Smartcloud.config.user_home_path}/.smartcloud/grids/grid-redmine/files:/usr/src/redmine/files' \
26
27
  --restart='always' \
27
28
  --network='nginx-network' \
@@ -28,9 +28,15 @@ module Smartcloud
28
28
  ssh = Smartcloud::SSH.new
29
29
  ssh.run "smartcloud buildpacker install"
30
30
  ssh.run "smartcloud prereceiver install"
31
+
32
+ elasticsearch = Smartcloud::Grids::Elasticsearch.new
33
+ elasticsearch.install
31
34
  end
32
35
 
33
36
  def stop
37
+ elasticsearch = Smartcloud::Grids::Elasticsearch.new
38
+ elasticsearch.uninstall
39
+
34
40
  ssh = Smartcloud::SSH.new
35
41
  ssh.run "smartcloud prereceiver uninstall"
36
42
  ssh.run "smartcloud buildpacker uninstall"
@@ -175,6 +181,10 @@ module Smartcloud
175
181
 
176
182
  'grids',
177
183
 
184
+ 'grids/grid-elasticsearch',
185
+ 'grids/grid-elasticsearch/vm_max_map_count',
186
+ 'grids/grid-elasticsearch/data/***',
187
+
178
188
  'grids/grid-mysql',
179
189
  'grids/grid-mysql/data/***',
180
190
 
@@ -206,6 +216,10 @@ module Smartcloud
206
216
 
207
217
  'grids',
208
218
 
219
+ 'grids/grid-elasticsearch',
220
+ 'grids/grid-elasticsearch/data',
221
+ 'grids/grid-elasticsearch/data/.keep',
222
+
209
223
  'grids/grid-mysql',
210
224
  'grids/grid-mysql/data',
211
225
  'grids/grid-mysql/data/.keep',
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: false
2
2
 
3
3
  module Smartcloud
4
- VERSION = "0.2.0".freeze
4
+ VERSION = "0.3.0".freeze
5
5
 
6
6
  def self.version
7
7
  @@version ||= VERSION
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smartcloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Timeboard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-25 00:00:00.000000000 Z
11
+ date: 2019-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-ssh
@@ -85,6 +85,8 @@ files:
85
85
  - lib/smartcloud/engine.rb
86
86
  - lib/smartcloud/engine/Dockerfile
87
87
  - lib/smartcloud/engine/buildpacks/rails/Dockerfile
88
+ - lib/smartcloud/grids/elasticsearch.rb
89
+ - lib/smartcloud/grids/grid-elasticsearch/.keep
88
90
  - lib/smartcloud/grids/grid-mysql/docker-entrypoint-initdb.d/.keep
89
91
  - lib/smartcloud/grids/grid-nginx/.keep
90
92
  - lib/smartcloud/grids/grid-prereceiver/Dockerfile
@@ -273,6 +275,7 @@ files:
273
275
  - lib/smartcloud/templates/dotsmartcloud/bin/smartcloud.sh
274
276
  - lib/smartcloud/templates/dotsmartcloud/config/environment.rb
275
277
  - lib/smartcloud/templates/dotsmartcloud/config/users.yml
278
+ - lib/smartcloud/templates/dotsmartcloud/grids/grid-elasticsearch/data/.keep
276
279
  - lib/smartcloud/templates/dotsmartcloud/grids/grid-mysql/data/.keep
277
280
  - lib/smartcloud/templates/dotsmartcloud/grids/grid-nginx/certificates/.keep
278
281
  - lib/smartcloud/templates/dotsmartcloud/grids/grid-nginx/fastcgi.conf