orchestration 0.6.5 → 0.6.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 22c01beaeb79e418062c87c7d0d8d9fdc472cc479c16a47d9be01ca0278abc04
4
- data.tar.gz: 78ad03978e9fcdb0ebf9cf1a02af1395dc356cdf5dac048eb06ab741396f4166
3
+ metadata.gz: 4d60dd6a324c493308690336d31236ab4e25ff8d6def5b54c77c5d8f1f77186f
4
+ data.tar.gz: 642a8a710f2b7a6989fba3e6146768d521ceb0c35d0cee693601824e2d43029e
5
5
  SHA512:
6
- metadata.gz: 94d8bdc996d37ae9b51bfd3a44f945e0f30b466d3bebb753b535c9e63558962d0661905fd4690677e946789bef76d9276f7047c4c990e7d9cfe6518b584e752f
7
- data.tar.gz: 9f785e2f76dac85f01c36db3fbc3d24724e52e4f36aaffe95f388e782b98b0d6f351b173383a42950405b3fe427901c4ba49c5a6e64d61f0b88c385e0a581393
6
+ metadata.gz: 7d4f6dc1c456af1cf954699dc9fed1a1990622aea6e220cfec88dd0ebe56576b75f5574cde538c1688b7f724eecc7da616a1d58c844e6ba09f479fa3b2254b05
7
+ data.tar.gz: 596b42d049cabec555f8b13cfeaf728d9780f0cfd90138b93a887f4271e25ea5286dbfd2c57bf1c33032ac561c4ec5716dc7294e5c788b342bc99a28cc18918f
data/.gitignore CHANGED
@@ -9,8 +9,6 @@
9
9
  # rspec failure tracking
10
10
  .rspec_status
11
11
 
12
- Gemfile.lock
13
-
14
12
  *.swp
15
13
  *.swo
16
14
 
@@ -34,5 +32,3 @@ docker/.build/
34
32
  docker/.context.tar
35
33
 
36
34
  .DS_Store
37
-
38
- .ruby-version
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.6.9
data/.strong_versions.yml CHANGED
@@ -1,2 +1,3 @@
1
1
  ignore:
2
2
  - i18n
3
+ - rails
data/Gemfile.lock ADDED
@@ -0,0 +1,246 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ orchestration (0.6.7)
5
+ database_url (~> 0.1.2)
6
+ erubis (~> 2.7)
7
+ i18n (>= 0.5)
8
+ paint (~> 2.0)
9
+ rails (>= 4.1)
10
+ thor (~> 1.0)
11
+
12
+ GEM
13
+ remote: https://rubygems.org/
14
+ specs:
15
+ actioncable (6.1.4.7)
16
+ actionpack (= 6.1.4.7)
17
+ activesupport (= 6.1.4.7)
18
+ nio4r (~> 2.0)
19
+ websocket-driver (>= 0.6.1)
20
+ actionmailbox (6.1.4.7)
21
+ actionpack (= 6.1.4.7)
22
+ activejob (= 6.1.4.7)
23
+ activerecord (= 6.1.4.7)
24
+ activestorage (= 6.1.4.7)
25
+ activesupport (= 6.1.4.7)
26
+ mail (>= 2.7.1)
27
+ actionmailer (6.1.4.7)
28
+ actionpack (= 6.1.4.7)
29
+ actionview (= 6.1.4.7)
30
+ activejob (= 6.1.4.7)
31
+ activesupport (= 6.1.4.7)
32
+ mail (~> 2.5, >= 2.5.4)
33
+ rails-dom-testing (~> 2.0)
34
+ actionpack (6.1.4.7)
35
+ actionview (= 6.1.4.7)
36
+ activesupport (= 6.1.4.7)
37
+ rack (~> 2.0, >= 2.0.9)
38
+ rack-test (>= 0.6.3)
39
+ rails-dom-testing (~> 2.0)
40
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
41
+ actiontext (6.1.4.7)
42
+ actionpack (= 6.1.4.7)
43
+ activerecord (= 6.1.4.7)
44
+ activestorage (= 6.1.4.7)
45
+ activesupport (= 6.1.4.7)
46
+ nokogiri (>= 1.8.5)
47
+ actionview (6.1.4.7)
48
+ activesupport (= 6.1.4.7)
49
+ builder (~> 3.1)
50
+ erubi (~> 1.4)
51
+ rails-dom-testing (~> 2.0)
52
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
53
+ activejob (6.1.4.7)
54
+ activesupport (= 6.1.4.7)
55
+ globalid (>= 0.3.6)
56
+ activemodel (6.1.4.7)
57
+ activesupport (= 6.1.4.7)
58
+ activerecord (6.1.4.7)
59
+ activemodel (= 6.1.4.7)
60
+ activesupport (= 6.1.4.7)
61
+ activestorage (6.1.4.7)
62
+ actionpack (= 6.1.4.7)
63
+ activejob (= 6.1.4.7)
64
+ activerecord (= 6.1.4.7)
65
+ activesupport (= 6.1.4.7)
66
+ marcel (~> 1.0.0)
67
+ mini_mime (>= 1.1.0)
68
+ activesupport (6.1.4.7)
69
+ concurrent-ruby (~> 1.0, >= 1.0.2)
70
+ i18n (>= 1.6, < 2)
71
+ minitest (>= 5.1)
72
+ tzinfo (~> 2.0)
73
+ zeitwerk (~> 2.3)
74
+ addressable (2.8.0)
75
+ public_suffix (>= 2.0.2, < 5.0)
76
+ amq-protocol (2.3.2)
77
+ ast (2.4.2)
78
+ bson (4.15.0)
79
+ builder (3.2.4)
80
+ bunny (2.19.0)
81
+ amq-protocol (~> 2.3, >= 2.3.1)
82
+ sorted_set (~> 1, >= 1.0.2)
83
+ concurrent-ruby (1.1.10)
84
+ crack (0.4.5)
85
+ rexml
86
+ crass (1.0.6)
87
+ database_url (0.1.2)
88
+ devpack (0.3.3)
89
+ diff-lcs (1.5.0)
90
+ erubi (1.10.0)
91
+ erubis (2.7.0)
92
+ globalid (1.0.0)
93
+ activesupport (>= 5.0)
94
+ hashdiff (1.0.1)
95
+ i18n (1.10.0)
96
+ concurrent-ruby (~> 1.0)
97
+ loofah (2.18.0)
98
+ crass (~> 1.0.2)
99
+ nokogiri (>= 1.5.9)
100
+ mail (2.7.1)
101
+ mini_mime (>= 0.1.1)
102
+ marcel (1.0.2)
103
+ method_source (1.0.0)
104
+ mini_mime (1.1.2)
105
+ minitest (5.15.0)
106
+ mongo (2.17.1)
107
+ bson (>= 4.8.2, < 5.0.0)
108
+ mongoid (7.4.0)
109
+ activemodel (>= 5.1, < 7.1, != 7.0.0)
110
+ mongo (>= 2.10.5, < 3.0.0)
111
+ ruby2_keywords (~> 0.0.5)
112
+ mysql2 (0.5.4)
113
+ nio4r (2.5.8)
114
+ nokogiri (1.13.6-x86_64-linux)
115
+ racc (~> 1.4)
116
+ paint (2.2.1)
117
+ parallel (1.22.1)
118
+ parser (3.1.2.0)
119
+ ast (~> 2.4.1)
120
+ pg (1.3.5)
121
+ public_suffix (4.0.7)
122
+ racc (1.6.0)
123
+ rack (2.2.3)
124
+ rack-test (1.1.0)
125
+ rack (>= 1.0, < 3)
126
+ rails (6.1.4.7)
127
+ actioncable (= 6.1.4.7)
128
+ actionmailbox (= 6.1.4.7)
129
+ actionmailer (= 6.1.4.7)
130
+ actionpack (= 6.1.4.7)
131
+ actiontext (= 6.1.4.7)
132
+ actionview (= 6.1.4.7)
133
+ activejob (= 6.1.4.7)
134
+ activemodel (= 6.1.4.7)
135
+ activerecord (= 6.1.4.7)
136
+ activestorage (= 6.1.4.7)
137
+ activesupport (= 6.1.4.7)
138
+ bundler (>= 1.15.0)
139
+ railties (= 6.1.4.7)
140
+ sprockets-rails (>= 2.0.0)
141
+ rails-dom-testing (2.0.3)
142
+ activesupport (>= 4.2.0)
143
+ nokogiri (>= 1.6)
144
+ rails-html-sanitizer (1.4.2)
145
+ loofah (~> 2.3)
146
+ railties (6.1.4.7)
147
+ actionpack (= 6.1.4.7)
148
+ activesupport (= 6.1.4.7)
149
+ method_source
150
+ rake (>= 0.13)
151
+ thor (~> 1.0)
152
+ rainbow (3.1.1)
153
+ rake (10.5.0)
154
+ rbtree (0.4.5)
155
+ regexp_parser (2.4.0)
156
+ rexml (3.2.5)
157
+ rspec (3.11.0)
158
+ rspec-core (~> 3.11.0)
159
+ rspec-expectations (~> 3.11.0)
160
+ rspec-mocks (~> 3.11.0)
161
+ rspec-core (3.11.0)
162
+ rspec-support (~> 3.11.0)
163
+ rspec-expectations (3.11.0)
164
+ diff-lcs (>= 1.2.0, < 2.0)
165
+ rspec-support (~> 3.11.0)
166
+ rspec-its (1.3.0)
167
+ rspec-core (>= 3.0.0)
168
+ rspec-expectations (>= 3.0.0)
169
+ rspec-mocks (3.11.1)
170
+ diff-lcs (>= 1.2.0, < 2.0)
171
+ rspec-support (~> 3.11.0)
172
+ rspec-support (3.11.0)
173
+ rubocop (1.30.0)
174
+ parallel (~> 1.10)
175
+ parser (>= 3.1.0.0)
176
+ rainbow (>= 2.2.2, < 4.0)
177
+ regexp_parser (>= 1.8, < 3.0)
178
+ rexml (>= 3.2.5, < 4.0)
179
+ rubocop-ast (>= 1.18.0, < 2.0)
180
+ ruby-progressbar (~> 1.7)
181
+ unicode-display_width (>= 1.4.0, < 3.0)
182
+ rubocop-ast (1.18.0)
183
+ parser (>= 3.1.1.0)
184
+ rubocop-rails (2.14.2)
185
+ activesupport (>= 4.2.0)
186
+ rack (>= 1.1)
187
+ rubocop (>= 1.7.0, < 2.0)
188
+ rubocop-rake (0.5.1)
189
+ rubocop
190
+ rubocop-rspec (2.11.1)
191
+ rubocop (~> 1.19)
192
+ ruby-progressbar (1.11.0)
193
+ ruby2_keywords (0.0.5)
194
+ set (1.0.2)
195
+ sorted_set (1.0.3)
196
+ rbtree
197
+ set (~> 1.0)
198
+ sprockets (4.0.3)
199
+ concurrent-ruby (~> 1.0)
200
+ rack (> 1, < 3)
201
+ sprockets-rails (3.4.2)
202
+ actionpack (>= 5.2)
203
+ activesupport (>= 5.2)
204
+ sprockets (>= 3.0.0)
205
+ sqlite3 (1.4.2)
206
+ strong_versions (0.4.5)
207
+ i18n (>= 0.5)
208
+ paint (~> 2.0)
209
+ thor (1.2.1)
210
+ tzinfo (2.0.4)
211
+ concurrent-ruby (~> 1.0)
212
+ unicode-display_width (2.1.0)
213
+ webmock (3.14.0)
214
+ addressable (>= 2.8.0)
215
+ crack (>= 0.3.2)
216
+ hashdiff (>= 0.4.0, < 2.0.0)
217
+ websocket-driver (0.7.5)
218
+ websocket-extensions (>= 0.1.0)
219
+ websocket-extensions (0.1.5)
220
+ zeitwerk (2.5.4)
221
+
222
+ PLATFORMS
223
+ x86_64-linux
224
+
225
+ DEPENDENCIES
226
+ activerecord (~> 6.0)
227
+ bunny (~> 2.12)
228
+ devpack (~> 0.3.2)
229
+ mongoid (~> 7.0)
230
+ mysql2 (~> 0.5.2)
231
+ orchestration!
232
+ pg (~> 1.1)
233
+ rails (~> 6.0)
234
+ rake (~> 10.0)
235
+ rspec (~> 3.0)
236
+ rspec-its (~> 1.2)
237
+ rubocop (~> 1.12)
238
+ rubocop-rails (~> 2.9)
239
+ rubocop-rake (~> 0.5.1)
240
+ rubocop-rspec (~> 2.2)
241
+ sqlite3 (~> 1.3)
242
+ strong_versions (~> 0.4.5)
243
+ webmock (~> 3.4)
244
+
245
+ BUNDLED WITH
246
+ 2.3.11
data/README.md CHANGED
@@ -29,7 +29,7 @@ The below screenshot demonstrates _Orchestration_ being installed in a brand new
29
29
  Add _Orchestration_ to your Gemfile:
30
30
 
31
31
  ```ruby
32
- gem 'orchestration', '~> 0.6.5'
32
+ gem 'orchestration', '~> 0.6.8'
33
33
  ```
34
34
 
35
35
  Install:
data/UPGRADE.md CHANGED
@@ -1,6 +1,18 @@
1
- # Upgrade guide
1
+ # Upgrade guide (0.5 to 0.6)
2
2
 
3
- ## 0.5 to 0.6
3
+ ## Automatic Upgrade
4
+
5
+ A _Rake_ task is provided to automatically upgrade your application:
6
+
7
+ ```bash
8
+ bundle exec rake orchestration:upgrade
9
+ ```
10
+
11
+ Obsolete files will be removed and required modifications to existing files will be applied.
12
+
13
+ It is recommended to manually verify the validity of all changes to ensure that no custom configuration is lost.
14
+
15
+ ## Manual Upgrade
4
16
 
5
17
  ### Delete/rename files
6
18
 
@@ -48,6 +60,14 @@ post-setup:
48
60
 
49
61
  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
62
 
63
+ ### Update Dockerfile healthcheck
64
+
65
+ Edit `orchestration/Dockerfile` and edit the `HEALTHCHECK` directive's `CMD` to:
66
+
67
+ ```
68
+ CMD ["bundle","exec","rake","orchestration:healthcheck"]
69
+ ```
70
+
51
71
  ### Continuous Integration files
52
72
 
53
73
  Update any continuous integration scripts (e.g. `Jenkinsfile`) to run the `setup` target before `test`, e.g.:
@@ -28,6 +28,7 @@ en:
28
28
 
29
29
  rake:
30
30
  config: "Parse and output Orchestration config (internal use)"
31
+ upgrade: "Upgrade from Orchestration 0.5.x to 0.6.x"
31
32
  healthcheck: "Execute healthcheck; used for HEALTHCHECK command in Docker image"
32
33
  compose_services: "Output configured services for a given environment (RAILS_ENV)"
33
34
  install: "Install Orchestration tools"
@@ -9,7 +9,7 @@ module Orchestration
9
9
  def environment
10
10
  return @environment unless @environment.nil?
11
11
 
12
- ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
12
+ ENV.fetch('RAILS_ENV') { ENV.fetch('RACK_ENV', 'development') }
13
13
  end
14
14
 
15
15
  def web_server
@@ -20,16 +20,16 @@ module Orchestration
20
20
  def database_url
21
21
  case environment
22
22
  when 'development'
23
- ENV['DEVELOPMENT_DATABASE_URL'] || ENV['DATABASE_URL']
23
+ ENV.fetch('DEVELOPMENT_DATABASE_URL') { ENV.fetch('DATABASE_URL', nil) }
24
24
  when 'test'
25
- ENV['TEST_DATABASE_URL'] || ENV['DATABASE_URL']
25
+ ENV.fetch('TEST_DATABASE_URL') { ENV.fetch('DATABASE_URL', nil) }
26
26
  else
27
- ENV['DATABASE_URL']
27
+ ENV.fetch('DATABASE_URL', nil)
28
28
  end
29
29
  end
30
30
 
31
31
  def mongo_url
32
- ENV['MONGO_URL']
32
+ ENV.fetch('MONGO_URL', nil)
33
33
  end
34
34
 
35
35
  def mongoid_configuration_path
@@ -99,13 +99,23 @@ exit_fail=( \
99
99
  )
100
100
 
101
101
  ifdef env_file
102
- -include ${env_file}
102
+ env_path=${env_file}
103
103
  else
104
- ifneq (${env},test)
105
- ifeq (,$(findstring test,$(MAKECMDGOALS)))
106
- -include .env
104
+ env_path=.env
107
105
  endif
106
+
107
+ ifneq (${env},test)
108
+ ifeq (,$(findstring test,$(MAKECMDGOALS)))
109
+ ifeq (,$(findstring deploy,$(MAKECMDGOALS)))
110
+ ifeq (,$(findstring setup,$(MAKECMDGOALS)))
111
+ -include ${env_path}
112
+ endif
113
+ endif
114
+ endif
108
115
  endif
116
+
117
+ ifneq (,$(findstring deploy,$(MAKECMDGOALS)))
118
+ RAILS_ENV=$(shell grep '^RAILS_ENV=' '${env_path}' | tail -n1 | sed 's/^RAILS_ENV=//')
109
119
  endif
110
120
 
111
121
  export
@@ -114,7 +124,9 @@ ifneq (,$(findstring test,$(MAKECMDGOALS)))
114
124
  env=test
115
125
  endif
116
126
 
117
- ifneq (,$(env))
127
+ ifneq (,$(RAILS_ENV))
128
+ env=$(RAILS_ENV)
129
+ else ifneq (,$(env))
118
130
  # `env` set by current shell.
119
131
  else ifneq (,$(RAILS_ENV))
120
132
  env=$(RAILS_ENV)
@@ -130,11 +142,13 @@ DOCKER_TAG ?= latest
130
142
  ifneq (,$(wildcard ./Gemfile))
131
143
  bundle_cmd = bundle exec
132
144
  endif
133
- rake=DEVPACK_DISABLE=1 RACK_ENV=${env} RAILS_ENV=${env} ${bundle_cmd} rake
145
+ rake=DEVPACK_DISABLE=1 RACK_ENV=${env} SECRET_KEY_BASE='placeholder-secret' RAILS_ENV=${env} ${bundle_cmd} rake
134
146
 
135
147
  ifneq (,$(wildcard ${env_file}))
136
- rake_cmd:=${rake}
137
- rake=. ${env_file} && ${rake_cmd}
148
+ ifeq (,$(findstring deploy,$(MAKECMDGOALS)))
149
+ rake_cmd:=${rake}
150
+ rake=. ${env_file} && ${rake_cmd}
151
+ endif
138
152
  endif
139
153
 
140
154
  docker_config:=$(shell DEVPACK_DISABLE=1 RAILS_ENV=development ${bundle_cmd} rake orchestration:config 2>/dev/null || echo no-org no-repo)
@@ -206,11 +220,16 @@ all: build
206
220
 
207
221
  ### Container management commands ###
208
222
 
223
+ .PHONY: pull
224
+ pull:
225
+ @$(call system,${compose_human} pull)
226
+ @${compose} pull
227
+
209
228
  .PHONY: start
210
229
  ifndef network
211
230
  start: network := ${compose_project_name}
212
231
  endif
213
- start: _create-log-directory _clean-logs
232
+ start: _create-log-directory _clean-logs pull
214
233
  ifneq (,${compose_services})
215
234
  @$(call system,${compose_human} up --detach)
216
235
  ifeq (${env},$(filter ${env},test development))
@@ -295,27 +314,27 @@ db-console:
295
314
 
296
315
  .PHONY: setup
297
316
  ifneq (,$(wildcard config/database.yml))
298
- setup: url = $(shell ${rake} orchestration:db:url RAILS_ENV=${env})
317
+ setup: url = $(shell ${rake} orchestration:db:url RAILS_ENV=${env} 2>/dev/null)
299
318
  endif
300
319
  setup: _log-notify
301
320
  @$(call echo,Setting up ${env_human} environment)
302
321
  @$(call make,start env=${env})
303
322
  ifneq (,$(wildcard config/database.yml))
304
323
  @$(call echo,Preparing ${env_human} database)
305
- @$(call system,rake db:create DATABASE_URL="${url}")
306
- @${rake} db:create RAILS_ENV=${env} ${log} || : ${log}
324
+ @$(call system,rake db:create RAILS_ENV="${env}")
325
+ @${rake} db:create RAILS_ENV=${env} DATABASE_URL='${url}' ${log} || : ${log}
307
326
  ifneq (,$(wildcard db/structure.sql))
308
- @$(call system,rake db:schema:load DATABASE_URL="${url}")
309
- @${rake} db:schema:load DATABASE_URL='${url}' ${log} || ${exit_fail}
327
+ @$(call system,rake db:structure:load RAILS_ENV="${env}" ${url_prefix}DATABASE_URL="${url}")
328
+ @${rake} db:structure:load RAILS_ENV="${env}" DATABASE_URL='${url}' ${log} || ${exit_fail}
310
329
  else ifneq (,$(wildcard db/schema.rb))
311
- @$(call system,rake db:schema:load DATABASE_URL="${url}")
312
- @${rake} db:schema:load DATABASE_URL='${url}' ${log} || ${exit_fail}
330
+ @$(call system,rake db:schema:load RAILS_ENV="${env}" ${url_prefix}DATABASE_URL="${url}")
331
+ @${rake} db:schema:load RAILS_ENV="${env}" DATABASE_URL='${url}' ${log} || ${exit_fail}
313
332
  endif
314
- @$(call system,rake db:migrate DATABASE_URL="${url}")
315
- @${rake} db:migrate RAILS_ENV=${env}
333
+ @$(call system,rake db:migrate RAILS_ENV="${env}" ${url_prefix}DATABASE_URL="${url}")
334
+ @${rake} db:migrate RAILS_ENV="${env}" DATABASE_URL='${url}' ${log} || ${exit_fail}
316
335
  endif
317
336
  @if $(MAKE) -n post-setup >/dev/null 2>&1; then \
318
- $(call system,make post-setup RAILS_ENV=${env}) \
337
+ $(call system,make post-setup RAILS_ENV="${env}") \
319
338
  && $(MAKE) post-setup RAILS_ENV=${env}; fi
320
339
  @$(call echo,${env_human} environment setup complete ${tick})
321
340
 
@@ -422,15 +441,9 @@ wait-listener:
422
441
  build: _log-notify _clean-logs
423
442
  build: build_dir = ${orchestration_dir}/.build
424
443
  build: context = ${build_dir}/context.tar
425
- build: build_args := --build-arg GIT_COMMIT='${git_version}'
444
+ build: build_args := --build-arg GIT_COMMIT='${git_version}' $(shell grep '^ARG ' orchestration/Dockerfile | sed -e 's/=.*$$//' -e 's/^ARG /--build-arg /')
426
445
  build: tag_human = ${cyan}${docker_organization}/${docker_repository}:${git_version}${reset}
427
446
  build: latest_tag_human = ${cyan}${docker_organization}/${docker_repository}:latest${reset}
428
- ifdef BUNDLE_GITHUB__COM
429
- build: build_args := ${build_args} --build-arg BUNDLE_GITHUB__COM
430
- endif
431
- ifdef BUNDLE_BITBUCKET__ORG
432
- build: build_args := ${build_args} --build-arg BUNDLE_BITBUCKET__ORG
433
- endif
434
447
  build: _create-log-directory check-local-changes
435
448
  @$(call echo,Preparing build context from ${cyan}${git_branch}${reset} (${cyan}${git_version}${reset})${reset})
436
449
  @$(call system,git archive --format "tar" -o "${context}" "${git_branch}")
@@ -23,7 +23,7 @@ RUN bundle config set deployment 'true' \
23
23
  && bundle config set without 'development test' \
24
24
  && bundle install
25
25
  ADD .build/context.tar .
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 %>
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 %>
27
27
  RUN echo "${GIT_COMMIT}" > /app/GIT_COMMIT
28
28
  HEALTHCHECK --interval=<%= healthcheck['interval'] %> \
29
29
  --timeout=<%= healthcheck['timeout'] %> \
@@ -12,4 +12,4 @@ test:
12
12
 
13
13
  production:
14
14
  url: <%%= ENV['RABBITMQ_URL'] %>
15
- url: <%%= ENV['RABBITMQ_MANAGEMENT_URL'] %>
15
+ management_url: <%%= ENV['RABBITMQ_MANAGEMENT_URL'] %>
@@ -3,9 +3,13 @@
3
3
  module Orchestration
4
4
  COLOR_MAP = {
5
5
  failure: %i[red bright],
6
+ success: %i[green],
7
+ info: %i[blue],
6
8
  error: %i[red],
7
9
  ready: %i[green],
8
10
  create: %i[green],
11
+ delete: %i[red],
12
+ rename: %i[blue],
9
13
  update: %i[yellow],
10
14
  backup: %i[blue],
11
15
  status: %i[blue],
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Orchestration
4
- VERSION = '0.6.5'
4
+ VERSION = '0.6.8'
5
5
  end
data/lib/orchestration.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  require 'erb'
4
4
  require 'pathname'
5
5
  require 'socket'
6
+ require 'yaml'
6
7
 
7
8
  require 'database_url'
8
9
  require 'erubis'
@@ -19,13 +19,106 @@ namespace :orchestration do
19
19
  puts "#{config['docker']['organization']} #{config['docker']['repository']}"
20
20
  end
21
21
 
22
+ desc I18n.t('orchestration.rake.upgrade')
23
+ task :upgrade do
24
+ terminal = Orchestration::Terminal.new(Orchestration::Environment.new.settings)
25
+ %w[
26
+ orchestration/docker-compose.yml
27
+ orchestration/docker-compose.override.yml
28
+ orchestration/Makefile
29
+ orchestration/deploy.mk
30
+ orchestration/yaml.bash
31
+ orchestration/healthcheck.rb
32
+ ].each.map { |path| Pathname.new(path) }.each do |path|
33
+ next unless path.exist?
34
+
35
+ terminal.write(:delete, path)
36
+ path.unlink
37
+ end
38
+
39
+ src = 'orchestration/docker-compose.production.yml'
40
+ dest = 'orchestration/docker-compose.deployment.yml'
41
+ if File.exist?(src)
42
+ terminal.write(:rename, "#{src} => #{dest}")
43
+ File.rename(src, dest)
44
+ end
45
+
46
+ makefile = File.read('Makefile')
47
+ makefile.gsub!(
48
+ %r{^include orchestration/Makefile$},
49
+ %[include $(shell bundle exec ruby -e 'require "orchestration/make"')]
50
+ )
51
+ makefile.gsub!(/^test: test-setup$/, 'test:')
52
+ lines = makefile.lines(chomp: true)
53
+ post_setup_start = lines.index('ifndef light')
54
+ if post_setup_start.nil?
55
+ updated_makefile = lines.join("\n")
56
+ post_setup = []
57
+ else
58
+ post_setup_end = post_setup_start + lines[post_setup_start..].index('endif')
59
+ post_setup = lines[(post_setup_start + 1)...post_setup_end]
60
+ updated_makefile = lines.each.with_index.reject do |_line, index|
61
+ (post_setup_start..post_setup_end).cover?(index)
62
+ end.map(&:first).join("\n")
63
+ end
64
+ if makefile.match(/^post-setup:$/).nil?
65
+ updated_makefile += %(
66
+
67
+ .PHONY: post-setup
68
+ post-setup:
69
+ @# Setup tasks that are not already provided by Orchestration go here.
70
+ #{post_setup.join("\n")}
71
+ )
72
+ end
73
+ if updated_makefile != makefile
74
+ terminal.write(:update, 'Makefile')
75
+ File.write('Makefile', updated_makefile)
76
+ end
77
+
78
+ %w[orchestration/docker-compose.test.yml orchestration/docker-compose.development.yml].each do |path|
79
+ terminal.write(:update, path)
80
+ config = YAML.safe_load(File.read(path))
81
+ config['networks'] ||= {}
82
+ config['networks']['local'] = { 'name' => '${COMPOSE_PROJECT_NAME}' }
83
+ config['services'] ||= {}
84
+ config['services'].each do |name, service|
85
+ service['networks'] = { 'local' => { 'aliases' => [name] } }
86
+ end
87
+ File.write(path, config.to_yaml)
88
+ end
89
+
90
+ dockerfile_path = 'orchestration/Dockerfile'
91
+ dockerfile = File.read(dockerfile_path)
92
+ updated_dockerfile = dockerfile.dup
93
+ updated_dockerfile.gsub!(
94
+ 'CMD ["ruby","/app/orchestration/healthcheck.rb"]',
95
+ 'CMD ["bundle","exec","rake","orchestration:healthcheck"]'
96
+ )
97
+ if updated_dockerfile != dockerfile
98
+ terminal.write(:update, dockerfile_path)
99
+ File.write(dockerfile_path, updated_dockerfile)
100
+ end
101
+
102
+ terminal.write(:success, 'Upgrade complete.')
103
+ terminal.write(:info, '`make test` will now only run tests, skipping setup.')
104
+ terminal.write(:info, 'Run `make setup test` to load test containers, run migrations, etc.')
105
+ terminal.write(:info, 'Run `make setup` to load development environment.')
106
+ terminal.write(:info, 'Run `make setup RAILS_ENV=test` to load test environment without running tests.')
107
+ terminal.write(:info, 'Edit the `post-setup` recipe in `Makefile` to perform custom setup actions.')
108
+ end
109
+
22
110
  namespace :db do
23
111
  desc I18n.t('orchestration.rake.db.url')
24
112
  task :url do
25
- config = Rails.application.config_for(:database)
113
+ ENV['DATABASE_URL'] = nil
114
+ ENV['DEVELOPMENT_DATABASE_URL'] = nil
115
+ ENV['TEST_DATABASE_URL'] = nil
116
+ config = Rails.application.config_for(:database).transform_keys(&:to_sym)
26
117
 
27
118
  if config[:adapter] == 'sqlite3'
28
119
  puts "sqlite3:#{config[:database]}"
120
+ elsif !config[:url].nil?
121
+ puts config[:url]
29
122
  else
30
123
  puts DatabaseUrl.to_active_record_url(config)
31
124
  end
@@ -71,7 +164,7 @@ namespace :orchestration do
71
164
  end
72
165
 
73
166
  adapter::Healthcheck.start(
74
- nil, nil, config_path: path, service_name: name, sidecar: ENV['sidecar']
167
+ nil, nil, config_path: path, service_name: name, sidecar: ENV.fetch('sidecar', nil)
75
168
  )
76
169
  end
77
170
  end
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  end
23
23
  end
24
24
 
25
- spec.required_ruby_version = '~> 2.7'
25
+ spec.required_ruby_version = '>= 2.6'
26
26
  spec.bindir = 'bin'
27
27
  spec.executables = []
28
28
  spec.require_paths = ['lib']
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
31
31
  spec.add_runtime_dependency 'erubis', '~> 2.7'
32
32
  spec.add_runtime_dependency 'i18n', '>= 0.5'
33
33
  spec.add_runtime_dependency 'paint', '~> 2.0'
34
- spec.add_runtime_dependency 'rails', '~> 6.0'
34
+ spec.add_runtime_dependency 'rails', '>= 4.1'
35
35
  spec.add_runtime_dependency 'thor', '~> 1.0'
36
36
 
37
37
  spec.add_development_dependency 'activerecord', '~> 6.0'
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.5
4
+ version: 0.6.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Farrell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-11 00:00:00.000000000 Z
11
+ date: 2022-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: database_url
@@ -70,16 +70,16 @@ dependencies:
70
70
  name: rails
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '6.0'
75
+ version: '4.1'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: '6.0'
82
+ version: '4.1'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: thor
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -342,9 +342,11 @@ files:
342
342
  - ".gitignore"
343
343
  - ".rspec"
344
344
  - ".rubocop.yml"
345
+ - ".ruby-version"
345
346
  - ".strong_versions.yml"
346
347
  - ".travis.yml"
347
348
  - Gemfile
349
+ - Gemfile.lock
348
350
  - LICENSE
349
351
  - Makefile
350
352
  - README.md
@@ -422,16 +424,16 @@ require_paths:
422
424
  - lib
423
425
  required_ruby_version: !ruby/object:Gem::Requirement
424
426
  requirements:
425
- - - "~>"
427
+ - - ">="
426
428
  - !ruby/object:Gem::Version
427
- version: '2.7'
429
+ version: '2.6'
428
430
  required_rubygems_version: !ruby/object:Gem::Requirement
429
431
  requirements:
430
432
  - - ">="
431
433
  - !ruby/object:Gem::Version
432
434
  version: '0'
433
435
  requirements: []
434
- rubygems_version: 3.1.6
436
+ rubygems_version: 3.0.3.1
435
437
  signing_key:
436
438
  specification_version: 4
437
439
  summary: Docker orchestration toolkit