orchestration 0.6.0 → 0.6.4
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 +4 -4
- data/README.md +3 -1
- data/UPGRADE.md +90 -0
- data/config/locales/en.yml +1 -0
- data/lib/orchestration/docker_compose/app_service.rb +4 -3
- data/lib/orchestration/docker_compose/compose_configuration.rb +2 -0
- data/lib/orchestration/environment.rb +8 -4
- data/lib/orchestration/install_generator.rb +0 -1
- data/lib/orchestration/make/orchestration.mk +15 -8
- data/lib/orchestration/templates/Dockerfile.erb +3 -1
- data/lib/orchestration/templates/application.mk.erb +1 -1
- data/lib/orchestration/templates/puma.rb.erb +1 -1
- data/lib/orchestration/version.rb +1 -1
- data/lib/tasks/orchestration.rake +13 -1
- data/orchestration.gemspec +2 -1
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99bdeb106830843d2a0e600151a4d80b411d21e86f25010d6c2379810ef85273
|
4
|
+
data.tar.gz: 4b3828ec78541d1680d3e5749c0a2e428bed328313d17e13d3f4e0dc1bdb0e8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e5a03e78c1e442daa079a5d92540df52a148b7ea08b8fa3ecd55919d045e7fc239d5638d8a850565044b9c1d7065b39c4401a72db0daef0d299c622e86ee02f
|
7
|
+
data.tar.gz: e2061ef7628599f65c05d28380376ef841a329f85408c2dfa84172907ada7392dc0ba556b01a6559f3869b1f7b6809304615ebe91a9970e71adc31d04a0e82ed
|
data/README.md
CHANGED
@@ -13,6 +13,8 @@ make deploy manager=user@swarm.example.com env_file=/var/configs/myapp.env
|
|
13
13
|
|
14
14
|
_Orchestration_ has been successfully used to build continuous delivery pipelines for numerous production applications with a wide range or requirements.
|
15
15
|
|
16
|
+
See [upgrade guide](UPGRADE.md) if you are upgrading from `0.5.x` to `0.6.x`.
|
17
|
+
|
16
18
|
## Example
|
17
19
|
|
18
20
|
The below screenshot demonstrates _Orchestration_ being installed in a brand new _Rails_ application with support for _PostgreSQL_ (via the _PG_ gem) and _RabbitMQ_ (via the _Bunny_ gem):
|
@@ -27,7 +29,7 @@ The below screenshot demonstrates _Orchestration_ being installed in a brand new
|
|
27
29
|
Add _Orchestration_ to your Gemfile:
|
28
30
|
|
29
31
|
```ruby
|
30
|
-
gem 'orchestration', '~> 0.6.
|
32
|
+
gem 'orchestration', '~> 0.6.4'
|
31
33
|
```
|
32
34
|
|
33
35
|
Install:
|
data/UPGRADE.md
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
# Upgrade guide
|
2
|
+
|
3
|
+
## 0.5 to 0.6
|
4
|
+
|
5
|
+
### Delete/rename files
|
6
|
+
|
7
|
+
Delete all files from `orchestration/` directory except:
|
8
|
+
|
9
|
+
* `docker-compose.production.yml`
|
10
|
+
* `docker-compose.development.yml`
|
11
|
+
* `docker-compose.test.yml`
|
12
|
+
* `Dockerfile`
|
13
|
+
* `entrypoint.sh`
|
14
|
+
|
15
|
+
Rename:
|
16
|
+
|
17
|
+
```bash
|
18
|
+
orchestration/docker-compose.production.yml => orchestration/docker-compose.deployment.yml
|
19
|
+
```
|
20
|
+
|
21
|
+
Any environment-specific compose files (e.g. `staging`) should also be removed as the same compose file is now used for all deployment stages.
|
22
|
+
|
23
|
+
### Update Makefile
|
24
|
+
|
25
|
+
Remove the first line of the main `Makefile` (in root of project) and replace it with the new `include` declaration:
|
26
|
+
|
27
|
+
#### OLD
|
28
|
+
|
29
|
+
```make
|
30
|
+
include orchestration/Makefile
|
31
|
+
```
|
32
|
+
|
33
|
+
#### NEW
|
34
|
+
|
35
|
+
```make
|
36
|
+
include $(shell bundle exec ruby -e 'require "orchestration/make"')
|
37
|
+
```
|
38
|
+
|
39
|
+
#### Post-setup target
|
40
|
+
|
41
|
+
Add a new target anywhere in the `Makefile` called `post-setup`:
|
42
|
+
|
43
|
+
```make
|
44
|
+
.PHONY: post-setup
|
45
|
+
post-setup:
|
46
|
+
echo 'doing post setup stuff'
|
47
|
+
```
|
48
|
+
|
49
|
+
Replace the body of this target with any commands that you want to take place once the initial setup (launching development/test containers, running migrations, etc.) is complete. For example, running migrations for a secondary database.
|
50
|
+
|
51
|
+
### Continuous Integration files
|
52
|
+
|
53
|
+
Update any continuous integration scripts (e.g. `Jenkinsfile`) to run the `setup` target before `test`, e.g.:
|
54
|
+
|
55
|
+
#### OLD
|
56
|
+
|
57
|
+
```Jenkinsfile
|
58
|
+
stage('Test') {
|
59
|
+
steps {
|
60
|
+
sh 'make test sidecar=1'
|
61
|
+
}
|
62
|
+
}
|
63
|
+
```
|
64
|
+
|
65
|
+
#### NEW
|
66
|
+
|
67
|
+
```Jenkinsfile
|
68
|
+
stage('Test') {
|
69
|
+
steps {
|
70
|
+
sh 'make setup test sidecar=1'
|
71
|
+
}
|
72
|
+
}
|
73
|
+
```
|
74
|
+
|
75
|
+
(`sidecar` may or may not be needed depending on your setup but, if it was there prior to upgrade, then it should remain after upgrade).
|
76
|
+
|
77
|
+
### General Usage
|
78
|
+
|
79
|
+
All _Orchestration_ commands behave exactly the same as before with the exception of the `test` target. Now, instead of running `make test` to launch all containers and then run tests, _Rubocop_, etc., you must run `make setup test`.
|
80
|
+
|
81
|
+
This will set up the test environment and then run tests. You may then run `make test` to just run tests without having to go through the full setup process again.
|
82
|
+
|
83
|
+
Similarly you can set up the development environment by just running `make setup`.
|
84
|
+
|
85
|
+
To set up the test environment and run tests as two separate steps (i.e. equivalent of using the shorthand `make setup test`) you can run:
|
86
|
+
|
87
|
+
```bash
|
88
|
+
make setup RAILS_ENV=test
|
89
|
+
make test
|
90
|
+
```
|
data/config/locales/en.yml
CHANGED
@@ -29,6 +29,7 @@ en:
|
|
29
29
|
rake:
|
30
30
|
config: "Parse and output Orchestration config (internal use)"
|
31
31
|
healthcheck: "Execute healthcheck; used for HEALTHCHECK command in Docker image"
|
32
|
+
compose_services: "Output configured services for a given environment (RAILS_ENV)"
|
32
33
|
install: "Install Orchestration tools"
|
33
34
|
install_makefile: "(Re)create orchestration/Makefile"
|
34
35
|
wait: "Wait for development/test dependencies to be available"
|
@@ -98,9 +98,10 @@ module Orchestration
|
|
98
98
|
'RAILS_LOG_TO_STDOUT' => '1',
|
99
99
|
'RAILS_SERVE_STATIC_FILES' => '1',
|
100
100
|
'WEB_PRELOAD_APP' => '1',
|
101
|
-
'WEB_HEALTHCHECK_PATH' => '/',
|
101
|
+
'WEB_HEALTHCHECK_PATH' => '/healthcheck',
|
102
|
+
'WEB_PORT' => 8080,
|
102
103
|
'DATABASE_URL' => database_url
|
103
|
-
}.merge(inherited_environment.
|
104
|
+
}.merge(inherited_environment.to_h { |key| [key, nil] }).merge(rabbitmq_urls)
|
104
105
|
end
|
105
106
|
|
106
107
|
def rabbitmq_urls
|
@@ -114,7 +115,7 @@ module Orchestration
|
|
114
115
|
'postgresql' => 'postgresql://postgres:password@database-local:5432/production',
|
115
116
|
'mysql2' => 'mysql2://root:password@database-local:3306/production',
|
116
117
|
'sqlite3' => 'sqlite3:db/production.sqlite3'
|
117
|
-
}.fetch(DockerCompose::ComposeConfiguration.database_adapter_name)
|
118
|
+
}.fetch(DockerCompose::ComposeConfiguration.database_adapter_name, nil)
|
118
119
|
end
|
119
120
|
|
120
121
|
def inherited_environment
|
@@ -69,12 +69,12 @@ module Orchestration
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def default_app_name
|
72
|
-
default = docker_filter(root.basename.to_s)
|
72
|
+
default = docker_filter(root.basename.to_s, underscore: true)
|
73
73
|
return default unless defined?(Rails)
|
74
74
|
# Edge case if Rails is used as a dependency but we are not a Rails app:
|
75
75
|
return default if rails_application == Object
|
76
76
|
|
77
|
-
docker_filter(rails_application.name.underscore)
|
77
|
+
docker_filter(rails_application.name.underscore, underscore: true)
|
78
78
|
end
|
79
79
|
|
80
80
|
def rabbitmq_url
|
@@ -126,10 +126,14 @@ module Orchestration
|
|
126
126
|
app_class.parent
|
127
127
|
end
|
128
128
|
|
129
|
-
def docker_filter(string)
|
129
|
+
def docker_filter(string, underscore: false)
|
130
130
|
# Filter out characters not accepted by Docker Hub
|
131
131
|
permitted = [('0'..'9'), ('a'..'z')].map(&:to_a).flatten
|
132
|
-
string.chars.select
|
132
|
+
string.chars.select do |char|
|
133
|
+
next true if underscore && char == '_'
|
134
|
+
|
135
|
+
permitted.include?(char)
|
136
|
+
end.join
|
133
137
|
end
|
134
138
|
end
|
135
139
|
end
|
@@ -141,6 +141,8 @@ docker_config:=$(shell DEVPACK_DISABLE=1 RAILS_ENV=development ${bundle_cmd} rak
|
|
141
141
|
docker_organization=$(word 1,$(docker_config))
|
142
142
|
docker_repository=$(word 2,$(docker_config))
|
143
143
|
|
144
|
+
compose_services:=$(shell ${rake} orchestration:compose_services RAILS_ENV=${env})
|
145
|
+
|
144
146
|
ifeq (,$(project_name))
|
145
147
|
project_base = ${docker_repository}_${env}
|
146
148
|
else
|
@@ -209,9 +211,10 @@ ifndef network
|
|
209
211
|
start: network := ${compose_project_name}
|
210
212
|
endif
|
211
213
|
start: _create-log-directory _clean-logs
|
214
|
+
ifneq (,${compose_services})
|
212
215
|
@$(call system,${compose_human} up --detach)
|
213
216
|
ifeq (${env},$(filter ${env},test development))
|
214
|
-
|
217
|
+
${compose} up --detach --force-recreate --renew-anon-volumes --remove-orphans ${services} ${log} || ${exit_fail}
|
215
218
|
@[ -n '${sidecar}' ] && \
|
216
219
|
( \
|
217
220
|
$(call echo,(joining dependency network ${cyan}${network}${reset})) ; \
|
@@ -229,10 +232,12 @@ endif
|
|
229
232
|
@$(call echo,${env_human} containers started ${tick})
|
230
233
|
@$(call echo,Waiting for services to become available)
|
231
234
|
@$(call make,wait) 2>${stderr} || ${exit_fail}
|
235
|
+
endif
|
232
236
|
|
233
237
|
.PHONY: stop
|
234
238
|
stop: network := ${compose_project_name}
|
235
239
|
stop:
|
240
|
+
ifneq (,${compose_services})
|
236
241
|
@$(call echo,Stopping ${env_human} containers)
|
237
242
|
@$(call system,${compose_human} down)
|
238
243
|
@if docker ps --format "{{.ID}}" | grep -q $(shell hostname) ; \
|
@@ -244,6 +249,7 @@ stop:
|
|
244
249
|
${compose} down ${log} || ${exit_fail} ; \
|
245
250
|
fi
|
246
251
|
@$(call echo,${env_human} containers stopped ${tick})
|
252
|
+
endif
|
247
253
|
|
248
254
|
.PHONY: logs
|
249
255
|
logs:
|
@@ -288,7 +294,9 @@ db-console:
|
|
288
294
|
@${rake} orchestration:db:console RAILS_ENV=${env}
|
289
295
|
|
290
296
|
.PHONY: setup
|
297
|
+
ifneq (,$(wildcard config/database.yml))
|
291
298
|
setup: url = $(shell ${rake} orchestration:db:url RAILS_ENV=${env})
|
299
|
+
endif
|
292
300
|
setup: _log-notify
|
293
301
|
@$(call echo,Setting up ${env_human} environment)
|
294
302
|
@$(call make,start env=${env})
|
@@ -297,8 +305,8 @@ ifneq (,$(wildcard config/database.yml))
|
|
297
305
|
@$(call system,rake db:create DATABASE_URL="${url}")
|
298
306
|
@${rake} db:create RAILS_ENV=${env} ${log} || : ${log}
|
299
307
|
ifneq (,$(wildcard db/structure.sql))
|
300
|
-
@$(call system,rake db:
|
301
|
-
@${rake} db:
|
308
|
+
@$(call system,rake db:schema:load DATABASE_URL="${url}")
|
309
|
+
@${rake} db:schema:load DATABASE_URL='${url}' ${log} || ${exit_fail}
|
302
310
|
else ifneq (,$(wildcard db/schema.rb))
|
303
311
|
@$(call system,rake db:schema:load DATABASE_URL="${url}")
|
304
312
|
@${rake} db:schema:load DATABASE_URL='${url}' ${log} || ${exit_fail}
|
@@ -306,9 +314,9 @@ ifneq (,$(wildcard config/database.yml))
|
|
306
314
|
@$(call system,rake db:migrate DATABASE_URL="${url}")
|
307
315
|
@${rake} db:migrate RAILS_ENV=${env}
|
308
316
|
endif
|
309
|
-
|
310
|
-
|
311
|
-
&& $(MAKE) post-setup RAILS_ENV=${env}
|
317
|
+
@if $(MAKE) -n post-setup >/dev/null 2>&1; then \
|
318
|
+
$(call system,make post-setup RAILS_ENV=${env}) \
|
319
|
+
&& $(MAKE) post-setup RAILS_ENV=${env}; fi
|
312
320
|
@$(call echo,${env_human} environment setup complete ${tick})
|
313
321
|
|
314
322
|
.PHONY: dump
|
@@ -437,12 +445,11 @@ endif
|
|
437
445
|
ifdef include
|
438
446
|
@$(call echo,Including files from: ${cyan}${include}${reset})
|
439
447
|
@(while read line; do \
|
440
|
-
_system () { echo '${system_prefix}' $$1 }
|
441
448
|
export line; \
|
442
449
|
include_dir="${build_dir}/$$(dirname "$${line}")/" && \
|
443
450
|
mkdir -p "$${include_dir}" && cp "$${line}" "$${include_dir}" \
|
444
451
|
&& (cd '${orchestration_dir}/.build/' && tar rf 'context.tar' "$${line}"); \
|
445
|
-
|
452
|
+
echo "${system_prefix}" "tar rf 'context.tar' '$${line}'"; \
|
446
453
|
done < '${include}') ${log} || ${exit_fail}
|
447
454
|
@$(call echo,Build context ${green}ready${reset} ${tick})
|
448
455
|
endif
|
@@ -19,7 +19,9 @@ RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - \
|
|
19
19
|
&& npm install -g yarn<% end %>
|
20
20
|
WORKDIR /app
|
21
21
|
COPY .build/Gemfile .build/Gemfile.lock ./
|
22
|
-
RUN bundle
|
22
|
+
RUN bundle config set deployment 'true' \
|
23
|
+
&& bundle config set without 'development test' \
|
24
|
+
&& bundle install
|
23
25
|
ADD .build/context.tar .
|
24
26
|
<% if defined?(Webpacker) %>RUN . /root/.bashrc ; NODE_ENV=production RAILS_ENV=production yarn install && NODE_ENV=production RAILS_ENV=production SECRET_KEY_BASE=abc123 bundle exec rake assets:precompile<% elsif Rake::Task.tasks.map(&:name).include?('assets:precompile') %>RUN NODE_ENV=production RAILS_ENV=production SECRET_KEY_BASE=abc123 bundle exec rake assets:precompile<% end %>
|
25
27
|
RUN echo "${GIT_COMMIT}" > /app/GIT_COMMIT
|
@@ -24,7 +24,7 @@ test:
|
|
24
24
|
#
|
25
25
|
.PHONY: post-setup
|
26
26
|
post-setup:
|
27
|
-
|
27
|
+
@# Setup tasks that are not already provided by Orchestration go here.
|
28
28
|
|
29
29
|
#
|
30
30
|
# Launch all dependencies needed for a development environment and set up the
|
@@ -22,7 +22,13 @@ namespace :orchestration do
|
|
22
22
|
namespace :db do
|
23
23
|
desc I18n.t('orchestration.rake.db.url')
|
24
24
|
task :url do
|
25
|
-
|
25
|
+
config = Rails.application.config_for(:database)
|
26
|
+
|
27
|
+
if config[:adapter] == 'sqlite3'
|
28
|
+
puts "sqlite3:#{config[:database]}"
|
29
|
+
else
|
30
|
+
puts DatabaseUrl.to_active_record_url(config)
|
31
|
+
end
|
26
32
|
end
|
27
33
|
|
28
34
|
desc I18n.t('orchestration.rake.db.console')
|
@@ -33,6 +39,12 @@ namespace :orchestration do
|
|
33
39
|
end
|
34
40
|
end
|
35
41
|
|
42
|
+
desc I18n.t('orchestration.rake.compose_services')
|
43
|
+
task :compose_services do
|
44
|
+
config = Orchestration::DockerCompose::ComposeConfiguration.new(Orchestration::Environment.new)
|
45
|
+
puts config.services.keys.join(' ') unless config.services.nil? || config.services.empty?
|
46
|
+
end
|
47
|
+
|
36
48
|
desc I18n.t('orchestration.rake.healthcheck')
|
37
49
|
task :healthcheck do
|
38
50
|
Orchestration::DockerHealthcheck.execute
|
data/orchestration.gemspec
CHANGED
@@ -14,6 +14,7 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.summary = 'Docker orchestration toolkit'
|
15
15
|
spec.description = 'Tools to help launch apps in Docker'
|
16
16
|
spec.homepage = url
|
17
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
17
18
|
|
18
19
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
19
20
|
`git ls-files -z`.split("\x0").reject do |f|
|
@@ -21,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
24
|
-
spec.required_ruby_version = '~> 2.
|
25
|
+
spec.required_ruby_version = '~> 2.7'
|
25
26
|
spec.bindir = 'bin'
|
26
27
|
spec.executables = []
|
27
28
|
spec.require_paths = ['lib']
|
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.6.
|
4
|
+
version: 0.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Farrell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: database_url
|
@@ -349,6 +349,7 @@ files:
|
|
349
349
|
- Makefile
|
350
350
|
- README.md
|
351
351
|
- Rakefile
|
352
|
+
- UPGRADE.md
|
352
353
|
- bin/console
|
353
354
|
- bin/setup
|
354
355
|
- config/locales/en.yml
|
@@ -413,7 +414,8 @@ files:
|
|
413
414
|
- orchestration.gemspec
|
414
415
|
homepage: https://github.com/bobf/orchestration
|
415
416
|
licenses: []
|
416
|
-
metadata:
|
417
|
+
metadata:
|
418
|
+
rubygems_mfa_required: 'true'
|
417
419
|
post_install_message:
|
418
420
|
rdoc_options: []
|
419
421
|
require_paths:
|
@@ -422,14 +424,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
422
424
|
requirements:
|
423
425
|
- - "~>"
|
424
426
|
- !ruby/object:Gem::Version
|
425
|
-
version: '2.
|
427
|
+
version: '2.7'
|
426
428
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
427
429
|
requirements:
|
428
430
|
- - ">="
|
429
431
|
- !ruby/object:Gem::Version
|
430
432
|
version: '0'
|
431
433
|
requirements: []
|
432
|
-
rubygems_version: 3.
|
434
|
+
rubygems_version: 3.1.6
|
433
435
|
signing_key:
|
434
436
|
specification_version: 4
|
435
437
|
summary: Docker orchestration toolkit
|