orchestration 0.6.16 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/.strong_versions.yml +1 -0
- data/README.md +29 -12
- data/lib/orchestration/docker_compose/app_service.rb +2 -2
- data/lib/orchestration/docker_compose/compose_configuration.rb +1 -1
- data/lib/orchestration/environment.rb +3 -3
- data/lib/orchestration/file_helpers.rb +4 -4
- data/lib/orchestration/install_generator.rb +5 -42
- data/lib/orchestration/make/orchestration.mk +25 -45
- data/lib/orchestration/make.rb +0 -2
- data/lib/orchestration/services/database/configuration.rb +5 -5
- data/lib/orchestration/services/mixins/configuration_base.rb +1 -1
- data/lib/orchestration/services/mixins/http_healthcheck.rb +1 -1
- data/lib/orchestration/services/mongo/configuration.rb +1 -1
- data/lib/orchestration/templates/Dockerfile.erb +9 -11
- data/lib/orchestration/templates/rabbitmq.yml.erb +1 -1
- data/lib/orchestration/terminal.rb +1 -6
- data/lib/orchestration/version.rb +1 -1
- data/lib/orchestration.rb +19 -58
- data/lib/tasks/orchestration.rake +1 -4
- data/orchestration.gemspec +21 -23
- metadata +46 -78
- data/.ruby-version +0 -1
- data/Gemfile.lock +0 -275
- data/lib/orchestration/healthcheck.bash +0 -16
- data/lib/orchestration/make/orchestration.mk.orig +0 -535
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7891efd1c4930036b2245fad46bc9bc78c0de97b3c2cce26ede48d5a6de34a2c
|
4
|
+
data.tar.gz: c56d7d3193fd6cafe76dc823924bcc1ba74fda288090d1424bfdce148789cb51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c82db0ac9646d8b93ad2ef72cff3216106e8558f670c086cd0647f5496559f0a0c32309b8e2680323e627345a9f6da9f2745d4d67a5a1d8d1e7a56d2fc91417c
|
7
|
+
data.tar.gz: c0fc26b8ea7f66f7a50b52de3991fe5f4a99ec73b9186312e397fce229c184f8bdf8182d8bca991a79cb5b95f24ed3ce1907048bf27dceff482437129ce18ad4
|
data/.gitignore
CHANGED
data/.strong_versions.yml
CHANGED
data/README.md
CHANGED
@@ -26,10 +26,18 @@ The below screenshot demonstrates _Orchestration_ being installed in a brand new
|
|
26
26
|
|
27
27
|
### Install
|
28
28
|
|
29
|
-
Add _Orchestration_ to your Gemfile
|
29
|
+
Add _Orchestration_ to your `Gemfile`:
|
30
|
+
|
31
|
+
_Ruby 3.x_:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
gem 'orchestration', '~> 0.7.0'
|
35
|
+
```
|
36
|
+
|
37
|
+
_Ruby 2.x_:
|
30
38
|
|
31
39
|
```ruby
|
32
|
-
gem 'orchestration', '~> 0.6.
|
40
|
+
gem 'orchestration', '~> 0.6.6'
|
33
41
|
```
|
34
42
|
|
35
43
|
Install:
|
@@ -52,12 +60,6 @@ To rebuild all build-out at any time, pass `force=yes` to the above install comm
|
|
52
60
|
|
53
61
|
You will be prompted to enter values for your _Docker_ organisation and repository name. For example, the _organisation_ and _repository_ for https://hub.docker.com/r/rubyorchestration/sampleapp are `rubyorchestration` and `sampleapp` respectively. If you are unsure of these values, they can be modified later by editing `.orchestration.yml` in the root of your project directory.
|
54
62
|
|
55
|
-
Override these values from the command line by passing `project` and `organization` variables:
|
56
|
-
|
57
|
-
```bash
|
58
|
-
rake orchestration:install project=myapp organization=myorg
|
59
|
-
```
|
60
|
-
|
61
63
|
#### Configuration files
|
62
64
|
|
63
65
|
_Orchestration_ generates the following files where appropriate. Backups are created if a file is replaced.
|
@@ -163,15 +165,30 @@ make push
|
|
163
165
|
|
164
166
|
### Development
|
165
167
|
|
166
|
-
|
168
|
+
An [`.env` file](https://docs.docker.com/compose/env-file/) is created automatically in your project root. This file is _not_ stored in version control. Set all application environment variables in this file.
|
167
169
|
|
168
170
|
#### Launching a development server
|
169
171
|
|
170
|
-
|
172
|
+
To load all variables from `.env` and launch a development server, run the following command:
|
171
173
|
|
172
174
|
```bash
|
173
|
-
|
174
|
-
|
175
|
+
make serve
|
176
|
+
```
|
177
|
+
|
178
|
+
To load a _Rails_ console:
|
179
|
+
```bash
|
180
|
+
make console
|
181
|
+
```
|
182
|
+
|
183
|
+
The application environment will be output on launch for convenience.
|
184
|
+
|
185
|
+
To pass extra commands to the _Rails_ server:
|
186
|
+
```bash
|
187
|
+
# Custom server, custom port
|
188
|
+
make serve server='webrick -p 3001'
|
189
|
+
|
190
|
+
# Default server, custom port, custom bind address
|
191
|
+
make serve server='-p 3001 -b 192.168.0.1'
|
175
192
|
```
|
176
193
|
|
177
194
|
### Testing
|
@@ -29,7 +29,7 @@ module Orchestration
|
|
29
29
|
|
30
30
|
def healthcheck
|
31
31
|
{
|
32
|
-
'test' => ['
|
32
|
+
'test' => ['bundle', 'exec', 'rake', 'orchestration:healthcheck'],
|
33
33
|
# Defaults according to
|
34
34
|
# https://docs.docker.com/engine/reference/builder/#healthcheck
|
35
35
|
# Except start_period which cannot be set to 0s
|
@@ -54,7 +54,7 @@ module Orchestration
|
|
54
54
|
raise ArgumentError,
|
55
55
|
I18n.t(
|
56
56
|
'orchestration.rake.app.unspported_web_server',
|
57
|
-
server
|
57
|
+
server:,
|
58
58
|
expected: %w[puma unicorn]
|
59
59
|
)
|
60
60
|
end
|
@@ -9,7 +9,7 @@ module Orchestration
|
|
9
9
|
def environment
|
10
10
|
return @environment unless @environment.nil?
|
11
11
|
|
12
|
-
ENV.fetch('RAILS_ENV')
|
12
|
+
ENV.fetch('RAILS_ENV', nil) || ENV.fetch('RACK_ENV', nil) || 'development'
|
13
13
|
end
|
14
14
|
|
15
15
|
def web_server
|
@@ -20,9 +20,9 @@ module Orchestration
|
|
20
20
|
def database_url
|
21
21
|
case environment
|
22
22
|
when 'development'
|
23
|
-
ENV.fetch('DEVELOPMENT_DATABASE_URL')
|
23
|
+
ENV.fetch('DEVELOPMENT_DATABASE_URL', nil) || ENV.fetch('DATABASE_URL', nil)
|
24
24
|
when 'test'
|
25
|
-
ENV.fetch('TEST_DATABASE_URL')
|
25
|
+
ENV.fetch('TEST_DATABASE_URL', nil) || ENV.fetch('DATABASE_URL', nil)
|
26
26
|
else
|
27
27
|
ENV.fetch('DATABASE_URL', nil)
|
28
28
|
end
|
@@ -6,7 +6,7 @@ module Orchestration
|
|
6
6
|
|
7
7
|
def orchestration_dir
|
8
8
|
path = @env.orchestration_root
|
9
|
-
FileUtils.
|
9
|
+
FileUtils.mkdir(path) unless Dir.exist?(path)
|
10
10
|
|
11
11
|
path
|
12
12
|
end
|
@@ -95,9 +95,9 @@ module Orchestration
|
|
95
95
|
end
|
96
96
|
|
97
97
|
def ensure_line_in_file(path, line, echo: true, regex: nil)
|
98
|
-
return if line_in_file?(path, line
|
98
|
+
return if line_in_file?(path, line:, regex:)
|
99
99
|
|
100
|
-
append_file(path, "\n#{line.chomp}\n", echo:
|
100
|
+
append_file(path, "\n#{line.chomp}\n", echo:)
|
101
101
|
true
|
102
102
|
end
|
103
103
|
|
@@ -131,7 +131,7 @@ module Orchestration
|
|
131
131
|
|
132
132
|
def force?
|
133
133
|
# Rake task was invoked with `force=yes`
|
134
|
-
ENV
|
134
|
+
ENV.fetch('force', nil) == 'yes'
|
135
135
|
end
|
136
136
|
end
|
137
137
|
end
|
@@ -17,10 +17,10 @@ module Orchestration
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def orchestration_configuration
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
relpath = relative_path(
|
20
|
+
path = @env.orchestration_configuration_path
|
21
|
+
@terminal.ask_setting('docker.organization')
|
22
|
+
@terminal.ask_setting('docker.repository', @env.default_app_name)
|
23
|
+
relpath = relative_path(path)
|
24
24
|
return @terminal.write(:create, relpath) unless @settings.exist? || force?
|
25
25
|
return @terminal.write(:update, relpath) if @settings.dirty?
|
26
26
|
|
@@ -28,15 +28,11 @@ module Orchestration
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def application_makefile
|
31
|
-
return unless build?('Makefile')
|
32
|
-
|
33
31
|
path = @env.root.join('Makefile')
|
34
32
|
simple_copy('application.mk', path) unless File.exist?(path)
|
35
33
|
end
|
36
34
|
|
37
35
|
def dockerfile
|
38
|
-
return unless build?('Dockerfile')
|
39
|
-
|
40
36
|
create_file(
|
41
37
|
orchestration_dir.join('Dockerfile'),
|
42
38
|
dockerfile_content,
|
@@ -45,8 +41,6 @@ module Orchestration
|
|
45
41
|
end
|
46
42
|
|
47
43
|
def entrypoint_sh
|
48
|
-
return unless build?('entrypoint.sh')
|
49
|
-
|
50
44
|
content = template('entrypoint.sh')
|
51
45
|
path = orchestration_dir.join('entrypoint.sh')
|
52
46
|
create_file(path, content, overwrite: false)
|
@@ -54,15 +48,12 @@ module Orchestration
|
|
54
48
|
end
|
55
49
|
|
56
50
|
def docker_compose
|
57
|
-
return unless build?('docker-compose.yml')
|
58
|
-
|
59
51
|
@docker_compose.docker_compose_test_yml
|
60
52
|
@docker_compose.docker_compose_development_yml
|
61
53
|
@docker_compose.docker_compose_deployment_yml
|
62
54
|
end
|
63
55
|
|
64
56
|
def puma
|
65
|
-
return unless build?('puma.rb')
|
66
57
|
return nil unless @env.web_server == 'puma'
|
67
58
|
|
68
59
|
content = template('puma.rb')
|
@@ -71,18 +62,16 @@ module Orchestration
|
|
71
62
|
end
|
72
63
|
|
73
64
|
def unicorn
|
74
|
-
return unless build?('unicorn.rb')
|
75
65
|
return nil unless @env.web_server == 'unicorn'
|
76
66
|
|
77
67
|
content = template('unicorn.rb')
|
78
68
|
path = @env.root.join('config', 'unicorn.rb')
|
79
69
|
create_file(path, content, backup: true)
|
80
70
|
regex = /gem\s+['"]unicorn['"]/
|
81
|
-
ensure_line_in_file(gemfile_path, "gem 'unicorn'", regex:
|
71
|
+
ensure_line_in_file(gemfile_path, "gem 'unicorn'", regex:)
|
82
72
|
end
|
83
73
|
|
84
74
|
def database_yml
|
85
|
-
return unless build?('database.yml')
|
86
75
|
return unless defined?(ActiveRecord)
|
87
76
|
|
88
77
|
adapter = DockerCompose::ComposeConfiguration.database_adapter_name
|
@@ -92,28 +81,22 @@ module Orchestration
|
|
92
81
|
end
|
93
82
|
|
94
83
|
def mongoid_yml
|
95
|
-
return unless build?('mongoid.yml')
|
96
84
|
return unless defined?(Mongoid)
|
97
85
|
|
98
86
|
service_config('mongoid.yml', Services::Mongo::Configuration)
|
99
87
|
end
|
100
88
|
|
101
89
|
def rabbitmq_yml
|
102
|
-
return unless build?('rabbitmq.yml')
|
103
90
|
return unless defined?(Bunny)
|
104
91
|
|
105
92
|
service_config('rabbitmq.yml', Services::RabbitMQ::Configuration)
|
106
93
|
end
|
107
94
|
|
108
95
|
def env
|
109
|
-
return unless build?('.env')
|
110
|
-
|
111
96
|
simple_copy('env', @env.root.join('.env'), overwrite: false)
|
112
97
|
end
|
113
98
|
|
114
99
|
def gitignore
|
115
|
-
return unless build?('.gitignore')
|
116
|
-
|
117
100
|
path = @env.root.join('.gitignore')
|
118
101
|
globs = %w[.build/ .deploy/ Gemfile Gemfile.lock docker-compose.local.yml]
|
119
102
|
lines = %w[orchestration/.sidecar .env deploy.tar] + globs.map do |line|
|
@@ -125,13 +108,6 @@ module Orchestration
|
|
125
108
|
|
126
109
|
private
|
127
110
|
|
128
|
-
def build?(filename)
|
129
|
-
return true unless ENV.key?('build')
|
130
|
-
return true if ENV.fetch('build') == filename
|
131
|
-
|
132
|
-
false
|
133
|
-
end
|
134
|
-
|
135
111
|
def t(key)
|
136
112
|
I18n.t("orchestration.#{key}")
|
137
113
|
end
|
@@ -173,19 +149,6 @@ module Orchestration
|
|
173
149
|
healthcheck: DockerCompose::AppService.healthcheck
|
174
150
|
)
|
175
151
|
end
|
176
|
-
|
177
|
-
def configure_orchestration_settings
|
178
|
-
@terminal.ask_setting(
|
179
|
-
'docker.organization',
|
180
|
-
override: ENV.fetch('organization', nil)
|
181
|
-
)
|
182
|
-
|
183
|
-
@terminal.ask_setting(
|
184
|
-
'docker.repository',
|
185
|
-
default: @env.default_app_name,
|
186
|
-
override: ENV.fetch('project', nil)
|
187
|
-
)
|
188
|
-
end
|
189
152
|
end
|
190
153
|
# rubocop:enable Metrics/ClassLength
|
191
154
|
end
|
@@ -2,8 +2,7 @@
|
|
2
2
|
### Environment setup ###
|
3
3
|
SHELL:=/bin/bash
|
4
4
|
MAKE:=mkpath=${mkpath} make --no-print-directory
|
5
|
-
|
6
|
-
export
|
5
|
+
|
7
6
|
TERM ?= 'dumb'
|
8
7
|
pwd:=$(shell pwd)
|
9
8
|
|
@@ -53,14 +52,14 @@ println=$(call print,$1'\n')
|
|
53
52
|
printraw=printf $1
|
54
53
|
stdout=${pwd}/log/orchestration.stdout.log
|
55
54
|
stderr=${pwd}/log/orchestration.stderr.log
|
56
|
-
log_path_length
|
55
|
+
log_path_length=$(shell echo "${stdout}" | wc -c)
|
57
56
|
ifndef verbose
|
58
57
|
log_tee:= 2>&1 | tee -a ${stdout}
|
59
58
|
log:= >>${stdout} 2>>${stderr}
|
60
59
|
progress_point:=perl -e 'printf("[${magenta}busy${reset}] "); while( my $$line = <STDIN> ) { printf("."); select()->flush(); }'
|
61
60
|
log_progress:= > >(tee -ai ${stdout} >&1 | ${progress_point}) 2> >(tee -ai ${stderr} 2>&1 | ${progress_point})
|
62
61
|
endif
|
63
|
-
hr
|
62
|
+
hr=$(call println,"$1$(shell head -c ${log_path_length} < /dev/zero | tr '\0' '=')${reset}")
|
64
63
|
managed_env_tag:=\# -|- ORCHESTRATION
|
65
64
|
standard_env_path:=${pwd}/.env
|
66
65
|
backup_env_path:=${pwd}/.env.orchestration.backup
|
@@ -108,9 +107,7 @@ endif
|
|
108
107
|
ifneq (${env},test)
|
109
108
|
ifeq (,$(findstring test,$(MAKECMDGOALS)))
|
110
109
|
ifeq (,$(findstring deploy,$(MAKECMDGOALS)))
|
111
|
-
|
112
|
-
-include ${env_path}
|
113
|
-
endif
|
110
|
+
-include ${env_path}
|
114
111
|
endif
|
115
112
|
endif
|
116
113
|
endif
|
@@ -125,9 +122,7 @@ ifneq (,$(findstring test,$(MAKECMDGOALS)))
|
|
125
122
|
env=test
|
126
123
|
endif
|
127
124
|
|
128
|
-
ifneq (,$(
|
129
|
-
env=$(RAILS_ENV)
|
130
|
-
else ifneq (,$(env))
|
125
|
+
ifneq (,$(env))
|
131
126
|
# `env` set by current shell.
|
132
127
|
else ifneq (,$(RAILS_ENV))
|
133
128
|
env=$(RAILS_ENV)
|
@@ -143,7 +138,7 @@ DOCKER_TAG ?= latest
|
|
143
138
|
ifneq (,$(wildcard ./Gemfile))
|
144
139
|
bundle_cmd = bundle exec
|
145
140
|
endif
|
146
|
-
rake=
|
141
|
+
rake=DEVPACK_DISABLE=1 RACK_ENV=${env} SECRET_KEY_BASE='placeholder-secret' RAILS_ENV=${env} ${bundle_cmd} rake
|
147
142
|
|
148
143
|
ifneq (,$(wildcard ${env_file}))
|
149
144
|
ifeq (,$(findstring deploy,$(MAKECMDGOALS)))
|
@@ -182,39 +177,32 @@ ifeq (,$(findstring deploy,$(MAKECMDGOALS)))
|
|
182
177
|
ifeq (,${sidecar_suffix})
|
183
178
|
$(warning Unable to generate project suffix; project name collisions may occur.)
|
184
179
|
endif
|
185
|
-
|
180
|
+
compose_project_name = ${project_base}_${sidecar_suffix}
|
186
181
|
else
|
187
|
-
|
182
|
+
compose_project_name = ${project_base}
|
188
183
|
endif
|
189
184
|
else
|
190
|
-
|
185
|
+
compose_project_name = ${project_base}
|
191
186
|
endif
|
192
187
|
|
193
|
-
|
194
|
-
|
195
|
-
else
|
196
|
-
compose_project_name = ${compose_project_name_base}
|
197
|
-
endif
|
198
|
-
|
199
|
-
compose_base:=env -i \
|
200
|
-
PATH="$(PATH)" \
|
188
|
+
compose_base=env -i \
|
189
|
+
PATH=$(PATH) \
|
201
190
|
HOST_UID=$(shell id -u) \
|
202
191
|
DOCKER_ORGANIZATION="${docker_organization}" \
|
203
192
|
DOCKER_REPOSITORY="${docker_repository}" \
|
204
193
|
COMPOSE_PROJECT_NAME="${compose_project_name}" \
|
205
|
-
COMPOSE_PROJECT_NAME_SUFFIX="${COMPOSE_PROJECT_NAME_SUFFIX}" \
|
206
194
|
${sidecar_compose} \
|
207
195
|
docker-compose \
|
208
196
|
-f ${orchestration_dir}/docker-compose.${env}.yml
|
209
197
|
|
210
|
-
git_branch
|
198
|
+
git_branch ?= $(if $(branch),$(branch),$(shell git rev-parse --abbrev-ref HEAD 2>/dev/null || echo no-branch))
|
211
199
|
ifndef dev
|
212
|
-
git_version
|
200
|
+
git_version ?= $(shell git rev-parse --short --verify ${git_branch} 2>/dev/null || echo no-version)
|
213
201
|
else
|
214
|
-
git_version
|
202
|
+
git_version = dev
|
215
203
|
endif
|
216
204
|
|
217
|
-
docker_image
|
205
|
+
docker_image=${docker_organization}/${docker_repository}:${git_version}
|
218
206
|
|
219
207
|
compose=${compose_base}
|
220
208
|
compose_human=docker-compose -f ${orchestration_dir_name}/docker-compose.${env}.yml
|
@@ -228,16 +216,11 @@ all: build
|
|
228
216
|
|
229
217
|
### Container management commands ###
|
230
218
|
|
231
|
-
.PHONY: pull
|
232
|
-
pull:
|
233
|
-
@$(call system,${compose_human} pull)
|
234
|
-
@${compose} pull
|
235
|
-
|
236
219
|
.PHONY: start
|
237
220
|
ifndef network
|
238
221
|
start: network := ${compose_project_name}
|
239
222
|
endif
|
240
|
-
start: _create-log-directory _clean-logs
|
223
|
+
start: _create-log-directory _clean-logs
|
241
224
|
ifneq (,${compose_services})
|
242
225
|
@$(call system,${compose_human} up --detach)
|
243
226
|
ifeq (${env},$(filter ${env},test development))
|
@@ -322,7 +305,7 @@ db-console:
|
|
322
305
|
|
323
306
|
.PHONY: setup
|
324
307
|
ifneq (,$(wildcard config/database.yml))
|
325
|
-
setup: url
|
308
|
+
setup: url = $(shell ${rake} orchestration:db:url RAILS_ENV=${env} 2>/dev/null)
|
326
309
|
endif
|
327
310
|
setup: _log-notify
|
328
311
|
@$(call echo,Setting up ${env_human} environment)
|
@@ -330,16 +313,16 @@ setup: _log-notify
|
|
330
313
|
ifneq (,$(wildcard config/database.yml))
|
331
314
|
@$(call echo,Preparing ${env_human} database)
|
332
315
|
@$(call system,rake db:create RAILS_ENV="${env}")
|
333
|
-
@${rake} db:create RAILS_ENV=${env}
|
316
|
+
@${rake} db:create RAILS_ENV=${env} ${log} || : ${log}
|
334
317
|
ifneq (,$(wildcard db/structure.sql))
|
335
|
-
@$(call system,rake db:structure:load RAILS_ENV="${env}"
|
318
|
+
@$(call system,rake db:structure:load RAILS_ENV="${env}" DATABASE_URL="${url}")
|
336
319
|
@${rake} db:structure:load RAILS_ENV="${env}" DATABASE_URL='${url}' ${log} || ${exit_fail}
|
337
320
|
else ifneq (,$(wildcard db/schema.rb))
|
338
|
-
@$(call system,rake db:schema:load RAILS_ENV="${env}"
|
321
|
+
@$(call system,rake db:schema:load RAILS_ENV="${env}" DATABASE_URL="${url}")
|
339
322
|
@${rake} db:schema:load RAILS_ENV="${env}" DATABASE_URL='${url}' ${log} || ${exit_fail}
|
340
323
|
endif
|
341
|
-
@$(call system,rake db:migrate RAILS_ENV="${env}"
|
342
|
-
@${rake} db:migrate RAILS_ENV
|
324
|
+
@$(call system,rake db:migrate RAILS_ENV="${env}" DATABASE_URL="${url}")
|
325
|
+
@${rake} db:migrate RAILS_ENV=${env} ${log} || ${exit_fail}
|
343
326
|
endif
|
344
327
|
@if $(MAKE) -n post-setup >/dev/null 2>&1; then \
|
345
328
|
$(call system,make post-setup RAILS_ENV="${env}") \
|
@@ -393,13 +376,14 @@ tag:
|
|
393
376
|
.PHONY: deploy
|
394
377
|
deploy: _log-notify _clean-logs
|
395
378
|
ifdef env_file
|
396
|
-
deploy: env_file_option =
|
379
|
+
deploy: env_file_option = --env-file ${env_file}
|
397
380
|
endif
|
398
381
|
deploy: RAILS_ENV := ${env}
|
399
382
|
deploy: RACK_ENV := ${env}
|
400
383
|
deploy: DOCKER_TAG = ${git_version}
|
401
384
|
deploy: base_vars = DOCKER_ORGANIZATION=${docker_organization} DOCKER_REPOSITORY=${docker_repository} DOCKER_TAG=${git_version}
|
402
|
-
deploy:
|
385
|
+
deploy: compose_deploy := ${base_vars} COMPOSE_PROJECT_NAME=${project_base} HOST_UID=$(shell id -u) docker-compose ${env_file_option} --project-name ${project_base} -f orchestration/docker-compose.deployment.yml
|
386
|
+
deploy: config_cmd = ${compose_deploy} config
|
403
387
|
deploy: remote_cmd = cat | docker stack deploy --prune --with-registry-auth -c - ${project_base}
|
404
388
|
deploy: ssh_cmd = ssh "${manager}"
|
405
389
|
deploy: deploy_cmd := ${config_cmd} | ${ssh_cmd} "/bin/bash -lc '${remote_cmd}'"
|
@@ -455,8 +439,6 @@ build: _create-log-directory check-local-changes
|
|
455
439
|
@$(call echo,Preparing build context from ${cyan}${git_branch}${reset} (${cyan}${git_version}${reset})${reset})
|
456
440
|
@$(call system,git archive --format "tar" -o "${context}" "${git_branch}")
|
457
441
|
@mkdir -p ${orchestration_dir}/.build ${log} || ${exit_fail}
|
458
|
-
@cp '$(shell bundle info --path orchestration)/lib/orchestration/healthcheck.bash' '${orchestration_dir}/healthcheck'
|
459
|
-
@chmod +x '${orchestration_dir}/healthcheck'
|
460
442
|
ifndef dev
|
461
443
|
@git show ${git_branch}:./Gemfile > ${orchestration_dir}/.build/Gemfile 2>${stderr} || ${exit_fail}
|
462
444
|
@git show ${git_branch}:./Gemfile.lock > ${orchestration_dir}/.build/Gemfile.lock 2>${stderr} || ${exit_fail}
|
@@ -464,8 +446,6 @@ ifndef dev
|
|
464
446
|
else
|
465
447
|
@tar -cvf '${context}' . ${log} || ${exit_fail}
|
466
448
|
endif
|
467
|
-
@tar --append --file '${context}' '${orchestration_dir}/healthcheck'
|
468
|
-
@rm '${orchestration_dir}/healthcheck'
|
469
449
|
ifdef include
|
470
450
|
@$(call echo,Including files from: ${cyan}${include}${reset})
|
471
451
|
@(while read line; do \
|
data/lib/orchestration/make.rb
CHANGED
@@ -21,10 +21,10 @@ module Orchestration
|
|
21
21
|
def settings(healthcheck: false)
|
22
22
|
{
|
23
23
|
adapter: adapter.name,
|
24
|
-
host
|
25
|
-
port
|
26
|
-
username
|
27
|
-
password
|
24
|
+
host:,
|
25
|
+
port:,
|
26
|
+
username:,
|
27
|
+
password:,
|
28
28
|
database: healthcheck ? adapter.credentials['database'] : database
|
29
29
|
}.transform_keys(&:to_s)
|
30
30
|
end
|
@@ -64,7 +64,7 @@ module Orchestration
|
|
64
64
|
return {} unless File.exist?(database_configuration_path) || custom?
|
65
65
|
|
66
66
|
yaml = ERB.new(File.read(database_configuration_path)).result
|
67
|
-
YAML.safe_load(yaml,
|
67
|
+
YAML.safe_load(yaml, aliases: true)[@env.environment] || {}
|
68
68
|
end
|
69
69
|
|
70
70
|
def url_config
|
@@ -64,7 +64,7 @@ module Orchestration
|
|
64
64
|
return {} unless File.exist?(@env.mongoid_configuration_path)
|
65
65
|
|
66
66
|
yaml = File.read(@env.mongoid_configuration_path)
|
67
|
-
config = YAML.safe_load(yaml,
|
67
|
+
config = YAML.safe_load(yaml, aliases: true)
|
68
68
|
env = config.fetch(@env.environment, nil)
|
69
69
|
return {} if env.nil?
|
70
70
|
|
@@ -2,22 +2,20 @@ FROM ruby:<%= ruby_version %>
|
|
2
2
|
ARG BUNDLE_BITBUCKET__ORG
|
3
3
|
ARG BUNDLE_GITHUB__COM
|
4
4
|
ARG GIT_COMMIT
|
5
|
-
|
6
|
-
|
5
|
+
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - \
|
6
|
+
&& apt-get update \
|
7
7
|
&& DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
8
|
+
nodejs \
|
8
9
|
gosu \
|
9
10
|
sendmail \
|
10
|
-
ca-certificates \
|
11
|
-
curl \
|
12
|
-
gnupg \
|
13
|
-
&& mkdir -p /etc/apt/keyrings \
|
14
|
-
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
|
15
|
-
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \
|
16
|
-
&& apt-get update \
|
17
|
-
&& DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs \
|
18
11
|
&& rm -rf /var/lib/apt/lists/* \
|
19
12
|
&& gem install bundler \
|
20
13
|
&& mkdir /app<%if defined?(Webpacker) %> \
|
14
|
+
&& curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash \
|
15
|
+
&& . /root/.bashrc \
|
16
|
+
&& nvm install 14.16.0 \
|
17
|
+
&& npm config set user 0 \
|
18
|
+
&& npm config set unsafe-perm true \
|
21
19
|
&& npm install -g yarn<% end %>
|
22
20
|
WORKDIR /app
|
23
21
|
COPY .build/Gemfile .build/Gemfile.lock ./
|
@@ -25,7 +23,7 @@ RUN bundle config set deployment 'true' \
|
|
25
23
|
&& bundle config set without 'development test' \
|
26
24
|
&& bundle install
|
27
25
|
ADD .build/context.tar .
|
28
|
-
<% if defined?(Webpacker) %>RUN NODE_ENV=production RAILS_ENV=production yarn install && NODE_ENV=production RAILS_ENV=production SECRET_KEY_BASE=placeholder-secret bundle exec rake assets:precompile<% elsif Rake::Task.tasks.map(&:name).include?('assets:precompile') %>RUN NODE_ENV=production RAILS_ENV=production SECRET_KEY_BASE=placeholder-secret bundle exec rake assets:precompile<% end %>
|
26
|
+
<% if defined?(Webpacker) %>RUN . /root/.bashrc ; NODE_ENV=production RAILS_ENV=production yarn install && NODE_ENV=production RAILS_ENV=production SECRET_KEY_BASE=placeholder-secret bundle exec rake assets:precompile<% elsif Rake::Task.tasks.map(&:name).include?('assets:precompile') %>RUN NODE_ENV=production RAILS_ENV=production SECRET_KEY_BASE=placeholder-secret bundle exec rake assets:precompile<% end %>
|
29
27
|
RUN echo "${GIT_COMMIT}" > /app/GIT_COMMIT
|
30
28
|
HEALTHCHECK --interval=<%= healthcheck['interval'] %> \
|
31
29
|
--timeout=<%= healthcheck['timeout'] %> \
|
@@ -39,19 +39,14 @@ module Orchestration
|
|
39
39
|
result
|
40
40
|
end
|
41
41
|
|
42
|
-
def ask_setting(setting, default
|
42
|
+
def ask_setting(setting, default = nil)
|
43
43
|
return unless @settings.get(setting).nil?
|
44
|
-
return @settings.set(setting, override) unless override.nil?
|
45
44
|
|
46
45
|
write(:setup, t("settings.#{setting}.description"))
|
47
46
|
prompt = t("settings.#{setting}.prompt")
|
48
47
|
@settings.set(setting, read(prompt, default))
|
49
48
|
end
|
50
49
|
|
51
|
-
def print_variable(variable, value)
|
52
|
-
$stderr.print "#{Paint[variable, :blue]}#{Paint['=', :white]}#{Paint[value, :cyan]}"
|
53
|
-
end
|
54
|
-
|
55
50
|
private
|
56
51
|
|
57
52
|
def prompt(message, default)
|