orchestration 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/TODO +7 -0
- data/lib/orchestration/docker_compose/application_service.rb +51 -0
- data/lib/orchestration/docker_compose/services.rb +2 -0
- data/lib/orchestration/docker_compose.rb +2 -0
- data/lib/orchestration/install_generator.rb +3 -3
- data/lib/orchestration/services/application/configuration.rb +21 -0
- data/lib/orchestration/services/application.rb +10 -0
- data/lib/orchestration/services/database/configuration.rb +18 -5
- data/lib/orchestration/services.rb +1 -0
- data/lib/orchestration/templates/Dockerfile.tt +2 -2
- data/lib/orchestration/templates/Makefile.tt +13 -5
- data/lib/orchestration/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8ceff8fc2dd990496a6de51dddca57caa2e7000
|
4
|
+
data.tar.gz: dd0507265efb67c67ea5164cb2a7ff8b22675f0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f254e30b288a9d20aba6b55abd7fc01fd8973690bb31f430904f870a40088a6b0b7b4c5f7677c81c1cf02c6ed99c2fc8552a3a2ead211ed3bf877757dccea80
|
7
|
+
data.tar.gz: fc397b5f3341a7f6b2eda9e3231159c5fa5460a9feb3b5059472c5ea21de94796a3f55a4b7ad18571ef6a99eeb1ba3c3896efa7868024ccc577679777ae621fb
|
data/README.md
CHANGED
data/TODO
CHANGED
@@ -1,2 +1,9 @@
|
|
1
1
|
Be aware of yarn and include build steps in Dockerfile if present. Use dashboard
|
2
2
|
front end as a reference.
|
3
|
+
|
4
|
+
Create a production docker-compose.yml and set:
|
5
|
+
- RAILS_ENV
|
6
|
+
- SECRET_KEY_BASE
|
7
|
+
- DATABASE_URL (from config/database.yml)
|
8
|
+
|
9
|
+
Provide volumes for databases and mount appropriate directories for adapter
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Orchestration
|
4
|
+
module DockerCompose
|
5
|
+
class ApplicationService
|
6
|
+
PORT = 3000
|
7
|
+
|
8
|
+
def initialize(config)
|
9
|
+
@config = config
|
10
|
+
@env = config.environment
|
11
|
+
end
|
12
|
+
|
13
|
+
def definition
|
14
|
+
{
|
15
|
+
'image' => image,
|
16
|
+
'environment' => environment,
|
17
|
+
'ports' => ["#{PORT}:#{PORT}"]
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def image
|
24
|
+
"#{@env.settings.get('docker.username')}/#{@env.application_name}"
|
25
|
+
end
|
26
|
+
|
27
|
+
def environment
|
28
|
+
{
|
29
|
+
# `nil` values will inherit from environment or `.env` file.
|
30
|
+
'RAILS_ENV' => nil,
|
31
|
+
'SECRET_KEY_BASE' => nil,
|
32
|
+
'DATABASE_URL' => database_url,
|
33
|
+
'RAILS_LOG_TO_STDOUT' => '1'
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
def database_url
|
38
|
+
settings = @config.database_settings
|
39
|
+
return nil if settings.fetch('adapter') == 'sqlite3'
|
40
|
+
|
41
|
+
scheme = settings.fetch('scheme')
|
42
|
+
database = settings.fetch('database')
|
43
|
+
username = settings.fetch('username')
|
44
|
+
password = settings.fetch('password')
|
45
|
+
port = DatabaseService::PORT
|
46
|
+
|
47
|
+
"#{scheme}://#{username}:#{password}@database:#{port}/#{database}"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -5,6 +5,7 @@ module Orchestration
|
|
5
5
|
class Services
|
6
6
|
def initialize(options = {})
|
7
7
|
@configurations = {
|
8
|
+
'application' => options.fetch(:application, nil),
|
8
9
|
'database' => options.fetch(:database, nil),
|
9
10
|
'mongo' => options.fetch(:mongo, nil),
|
10
11
|
'rabbitmq' => options.fetch(:rabbitmq, nil)
|
@@ -27,6 +28,7 @@ module Orchestration
|
|
27
28
|
|
28
29
|
def services_available
|
29
30
|
[
|
31
|
+
{ name: 'application', class: ApplicationService },
|
30
32
|
{ name: 'database', class: DatabaseService },
|
31
33
|
{ name: 'mongo', class: MongoService },
|
32
34
|
{ name: 'rabbitmq', class: RabbitMQService }
|
@@ -6,6 +6,8 @@ module Orchestration
|
|
6
6
|
end
|
7
7
|
|
8
8
|
require 'orchestration/docker_compose/services'
|
9
|
+
|
10
|
+
require 'orchestration/docker_compose/application_service'
|
9
11
|
require 'orchestration/docker_compose/database_service'
|
10
12
|
require 'orchestration/docker_compose/mongo_service'
|
11
13
|
require 'orchestration/docker_compose/rabbitmq_service'
|
@@ -9,7 +9,7 @@ module Orchestration
|
|
9
9
|
|
10
10
|
def initialize(*_args)
|
11
11
|
super
|
12
|
-
@env = Environment.new
|
12
|
+
@env = Environment.new
|
13
13
|
@terminal ||= Terminal.new
|
14
14
|
end
|
15
15
|
|
@@ -58,6 +58,7 @@ module Orchestration
|
|
58
58
|
return if File.exist?(path)
|
59
59
|
|
60
60
|
docker_compose = DockerCompose::Services.new(
|
61
|
+
application: configuration(:application),
|
61
62
|
database: configuration(:database),
|
62
63
|
mongo: configuration(:mongo),
|
63
64
|
rabbitmq: configuration(:rabbitmq)
|
@@ -68,9 +69,8 @@ module Orchestration
|
|
68
69
|
private
|
69
70
|
|
70
71
|
def configuration(service)
|
71
|
-
# REVIEW: At the moment we only handle test dependencies - it would be
|
72
|
-
# nice to also handle development dependencies.
|
73
72
|
{
|
73
|
+
application: Services::Application::Configuration,
|
74
74
|
database: Services::Database::Configuration,
|
75
75
|
mongo: Services::Mongo::Configuration,
|
76
76
|
rabbitmq: Services::RabbitMQ::Configuration
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Orchestration
|
4
|
+
module Services
|
5
|
+
module Application
|
6
|
+
class Configuration
|
7
|
+
def initialize(env)
|
8
|
+
@env = env
|
9
|
+
end
|
10
|
+
|
11
|
+
def environment
|
12
|
+
@env
|
13
|
+
end
|
14
|
+
|
15
|
+
def database_settings
|
16
|
+
Database::Configuration.new(@env).settings
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -33,6 +33,7 @@ module Orchestration
|
|
33
33
|
base = base_config(environments)
|
34
34
|
@adapter = adapter_object(base['adapter'])
|
35
35
|
@settings = base.merge(@adapter.credentials)
|
36
|
+
.merge('scheme' => scheme_name(base['adapter']))
|
36
37
|
@settings.merge!(default_port) unless @settings.key?('port')
|
37
38
|
end
|
38
39
|
|
@@ -84,15 +85,19 @@ module Orchestration
|
|
84
85
|
|
85
86
|
{
|
86
87
|
'host' => uri.hostname,
|
87
|
-
'adapter' =>
|
88
|
+
'adapter' => adapter_name(uri.scheme),
|
88
89
|
'port' => uri.port
|
89
90
|
}.merge(query_params(uri))
|
90
91
|
end
|
91
92
|
|
92
|
-
def
|
93
|
-
|
94
|
-
|
95
|
-
|
93
|
+
def scheme_name(adapter_name)
|
94
|
+
adapter_mapping.invert.fetch(adapter_name)
|
95
|
+
end
|
96
|
+
|
97
|
+
def adapter_name(scheme)
|
98
|
+
name = adapter_mapping.fetch(scheme, nil)
|
99
|
+
|
100
|
+
return name unless name.nil?
|
96
101
|
|
97
102
|
raise ArgumentError,
|
98
103
|
I18n.t('orchestration.unknown_scheme', scheme: scheme)
|
@@ -108,6 +113,14 @@ module Orchestration
|
|
108
113
|
raise DatabaseConfigurationError,
|
109
114
|
I18n.t('orchestration.database.missing_default')
|
110
115
|
end
|
116
|
+
|
117
|
+
def adapter_mapping
|
118
|
+
{
|
119
|
+
'mysql' => 'mysql2',
|
120
|
+
'postgres' => 'postgresql',
|
121
|
+
'sqlite3' => 'sqlite3'
|
122
|
+
}
|
123
|
+
end
|
111
124
|
end
|
112
125
|
end
|
113
126
|
end
|
@@ -6,6 +6,6 @@ RUN apt-get update \
|
|
6
6
|
&& mkdir /application
|
7
7
|
WORKDIR /application
|
8
8
|
COPY Gemfile Gemfile.lock ./
|
9
|
-
RUN bundle install --deployment
|
9
|
+
RUN bundle install --deployment
|
10
10
|
ADD .build/context.tar.gz .
|
11
|
-
CMD ["bundle", "exec", "rails", "server", "-p", "3000"]
|
11
|
+
CMD ["bundle", "exec", "rails", "server", "-p", "3000", "-b", "0.0.0.0"]
|
@@ -20,19 +20,26 @@ start:
|
|
20
20
|
stop:
|
21
21
|
docker-compose down
|
22
22
|
|
23
|
+
### Database utility commands ###
|
24
|
+
|
25
|
+
migrate: wait-database
|
26
|
+
@echo "Running migrations..."
|
27
|
+
@docker-compose run application bundle exec rake db:migrate
|
28
|
+
@echo "Migrations complete."
|
29
|
+
|
23
30
|
### Service healthcheck commands ###
|
24
31
|
|
25
32
|
wait: <%= wait_commands %>
|
26
33
|
@echo "All Containers ready."
|
27
34
|
|
28
35
|
wait-database:
|
29
|
-
@
|
36
|
+
@bin/rake orchestration:db:wait
|
30
37
|
|
31
38
|
wait-mongo:
|
32
|
-
@
|
39
|
+
@bin/rake orchestration:mongo:wait
|
33
40
|
|
34
41
|
wait-rabbitmq:
|
35
|
-
@
|
42
|
+
@bin/rake orchestration:rabbitmq:wait
|
36
43
|
|
37
44
|
### Docker build commands ###
|
38
45
|
|
@@ -45,9 +52,10 @@ docker-build:
|
|
45
52
|
git archive --format tar.gz -o docker/.build/context.tar.gz master
|
46
53
|
docker build --build-arg BUNDLE_GITHUB__COM \
|
47
54
|
--build-arg BUNDLE_BITBUCKET__ORG \
|
48
|
-
-t $(shell
|
55
|
+
-t $(shell bin/rake orchestration:docker:username)/<%= app_id %> \
|
56
|
+
-t $(shell bin/rake orchestration:docker:username)/<%= app_id %>:$(shell git rev-parse --short --verify master) \
|
49
57
|
./docker/
|
50
58
|
|
51
59
|
docker-push: VERSION := $(shell git rev-parse --short --verify master)
|
52
60
|
docker-push:
|
53
|
-
docker push $(shell
|
61
|
+
docker push $(shell bin/rake orchestration:docker:username)/<%= app_id %>:${VERSION}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: orchestration
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Farrell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -247,6 +247,7 @@ files:
|
|
247
247
|
- config/locales/en.yml
|
248
248
|
- lib/orchestration.rb
|
249
249
|
- lib/orchestration/docker_compose.rb
|
250
|
+
- lib/orchestration/docker_compose/application_service.rb
|
250
251
|
- lib/orchestration/docker_compose/database_service.rb
|
251
252
|
- lib/orchestration/docker_compose/mongo_service.rb
|
252
253
|
- lib/orchestration/docker_compose/rabbitmq_service.rb
|
@@ -259,6 +260,8 @@ files:
|
|
259
260
|
- lib/orchestration/railtie.rb
|
260
261
|
- lib/orchestration/service_check.rb
|
261
262
|
- lib/orchestration/services.rb
|
263
|
+
- lib/orchestration/services/application.rb
|
264
|
+
- lib/orchestration/services/application/configuration.rb
|
262
265
|
- lib/orchestration/services/database.rb
|
263
266
|
- lib/orchestration/services/database/adapters.rb
|
264
267
|
- lib/orchestration/services/database/adapters/mysql2.rb
|