orchestration 0.4.5 → 0.4.6

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: 04b4a99bc763cd0a467762c2299d15ba5ce96f16e2f6a49b0f084457b64ae79f
4
- data.tar.gz: 5f1ddcbef2c012e7b6f2016e54c05e111df88b91e6983635991880b7f9b18cbd
3
+ metadata.gz: b0e5ee806929f885562e72f8d9b646a2c4b349ea9d43efc8d40185de8fc1bd21
4
+ data.tar.gz: 22d24ea9b0ac4bf3ee4764c74f52bd4721dbb7b96b12de94fd8509998cb6df78
5
5
  SHA512:
6
- metadata.gz: 50f67324c925ff8339fe43efe4d81ffa091a4e15c5cab207c1abf55ce8546f32cea14644ac04f4852d3a8ee3cb1606d21d4e8fb8ac4c4d3ff61a2bf98a1c48e4
7
- data.tar.gz: af6f8845919db0b4d8f6c0ad980879357bd2946e8c34fcbeef479fd2b4e92dc1e25a238af98961ea68cc9325f0d2958ee1fae4b695488a0ed32f19ac436d7913
6
+ metadata.gz: f2c0b88548df5da741069990629bfa2d02c6439cdf2c68cc7e9addc8f0d6dbe4074d0ec107f10f7ac235f440c4a422cb6c68eb7d57829c41263cd3ca556edc32
7
+ data.tar.gz: 63a5b30a5674aef12c730c67cc19e04b64470ae1724516f3bcb9e9fc39bfcc70291c8af1389d1930b4e8dd0fceb844656191d2ee324d50b6ed3aeb0b0f3c1390
data/README.md CHANGED
@@ -35,7 +35,7 @@ The below screenshot demonstrates _Orchestration_ being installed in a brand new
35
35
  Add _Orchestration_ to your Gemfile:
36
36
 
37
37
  ```ruby
38
- gem 'orchestration', '~> 0.4.5'
38
+ gem 'orchestration', '~> 0.4.6'
39
39
  ```
40
40
 
41
41
  Install:
@@ -184,6 +184,14 @@ Note that _Orchestration_ will wait for all services to become fully available (
184
184
 
185
185
  _(See [sidecar containers](#sidecar-containers) if you are running your test/development server inside _Docker_)_.
186
186
 
187
+ ### (Local) Production
188
+
189
+ Run a production environment locally to simulate your deployment platform:
190
+
191
+ ```
192
+ make start env=production
193
+ ```
194
+
187
195
  ### Deployment to Docker Swarm
188
196
 
189
197
  To deploy your application to a local _Docker Swarm_ use:
@@ -207,6 +215,14 @@ To override this default, pass the `project_name` parameter:
207
215
  make deploy project_name=acme_anvil_production
208
216
  ```
209
217
 
218
+ This variable will also be available as `COMPOSE_PROJECT_NAME` for use within your `docker-compose.yml`. e.g. to explicitly name a network after the project name:
219
+
220
+ ```yaml
221
+ networks:
222
+ myapp:
223
+ name: "${COMPOSE_PROJECT_NAME}"
224
+ ```
225
+
210
226
  #### Use a custom `.env` file
211
227
 
212
228
  Specify a path to a local `.env` file (see [Docker Compose documentation](https://docs.docker.com/compose/environment-variables/#the-env-file)):
@@ -16,6 +16,8 @@ module Orchestration
16
16
  end
17
17
 
18
18
  def run
19
+ return echo_missing unless @service.configuration.configured?
20
+
19
21
  echo_start
20
22
  success = attempt_connection
21
23
  echo_ready if success
@@ -37,6 +39,14 @@ module Orchestration
37
39
  false
38
40
  end
39
41
 
42
+ def echo_missing
43
+ @terminal.write(
44
+ @service_name.to_sym,
45
+ "#{@service.configuration.error} (skipping)",
46
+ :error
47
+ )
48
+ end
49
+
40
50
  def echo_start
41
51
  @terminal.write(@service_name.to_sym, '', :status)
42
52
  end
@@ -3,7 +3,7 @@
3
3
  module Orchestration
4
4
  module Services
5
5
  module ConfigurationBase
6
- attr_reader :service_name, :env
6
+ attr_reader :service_name, :env, :error
7
7
 
8
8
  def self.included(base)
9
9
  base.extend(ClassMethods)
@@ -33,6 +33,14 @@ module Orchestration
33
33
  @service_name
34
34
  end
35
35
 
36
+ def configured?
37
+ port
38
+ true
39
+ rescue KeyError => error
40
+ @error = error
41
+ false
42
+ end
43
+
36
44
  def port
37
45
  return @env.app_port if @service_name == 'app'
38
46
 
@@ -3,7 +3,10 @@ ARG BUNDLE_BITBUCKET__ORG
3
3
  ARG BUNDLE_GITHUB__COM
4
4
  RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - \
5
5
  && apt-get update \
6
- && apt-get install -y nodejs gosu sendmail \
6
+ && DEBIAN_FRONTEND=noninteractive apt-get install -y \
7
+ nodejs \
8
+ gosu \
9
+ sendmail \
7
10
  && rm -rf /var/lib/apt/lists/* \
8
11
  && gem install bundler \
9
12
  && mkdir /app<%if defined?(Webpacker) %> \
@@ -1,7 +1,6 @@
1
1
  #!/bin/sh
2
- set -ue
3
- echo "Host user ID: ${HOST_UID}"
4
- set +u
2
+ HOST_UID=${HOST_UID:-$(id -u)}
3
+ set -e
5
4
  id owner >/dev/null 2>&1 || useradd -u ${HOST_UID} -m -o owner
6
5
  mkdir -p /app/tmp/pids
7
6
  chown -Rf owner:owner /app/tmp /app/log /app/db
@@ -1,16 +1,12 @@
1
1
  development:
2
2
  clients:
3
3
  default:
4
- hosts:
5
- - 127.0.0.1:<%= compose.call('development').local_port('mongo') %>
6
- database: development_db
4
+ uri: <%= "#{'<' + '%' + '='} ENV.fetch('MONGO_URL', 'mongodb://127.0.0.1:#{compose.call('development').local_port('mongo')}/development_db') #{'%' + '>'}" %>
7
5
 
8
6
  test:
9
7
  clients:
10
8
  default:
11
- hosts:
12
- - 127.0.0.1:<%= compose.call('test').local_port('mongo') %>
13
- database: test_db
9
+ uri: <%= "#{'<' + '%' + '='} ENV.fetch('MONGO_URL', 'mongodb://127.0.0.1:#{compose.call('test').local_port('mongo')}/test_db') #{'%' + '>'}" %>
14
10
 
15
11
  production:
16
12
  clients:
@@ -39,11 +39,15 @@ endif
39
39
  docker_organization=$(shell bash ${orchestration_dir}/yaml.bash docker_organization)
40
40
  docker_repository=$(shell bash ${orchestration_dir}/yaml.bash docker_repository)
41
41
 
42
+ ifeq (,$(project_name))
43
+ project_name = ${docker_repository}_${env}
44
+ endif
45
+
42
46
  compose_base=env HOST_UID=$(shell id -u) \
43
47
  DOCKER_ORGANIZATION="${docker_organization}" \
44
48
  DOCKER_REPOSITORY="${docker_repository}" \
49
+ COMPOSE_PROJECT_NAME="${project_name}" \
45
50
  docker-compose \
46
- -p "${docker_repository}_${env}" \
47
51
  -f "${orchestration_dir}/docker-compose.yml"
48
52
 
49
53
  git_branch ?= $(if $(branch),$(branch),$(shell git rev-parse --abbrev-ref HEAD))
@@ -68,7 +72,7 @@ endif
68
72
  start: _clean-logs
69
73
  @$(call print,'${yellow}Starting containers${reset} ...')
70
74
  ifeq (${env},$(filter ${env},test development))
71
- @${compose} up -d --force-recreate ${services} ${log} || ${fail}
75
+ @${compose} up --detach --force-recreate --renew-anon-volumes ${services} ${log} || ${fail}
72
76
  @[ -n '${sidecar}' ] && \
73
77
  ( \
74
78
  docker network connect '${network}' '$(shell hostname)' ${log} \
@@ -77,7 +81,7 @@ ifeq (${env},$(filter ${env},test development))
77
81
  ) \
78
82
  || ( [ -z '${sidecar}' ] || ${fail} )
79
83
  else
80
- @${compose} up -d --scale app=$${instances:-1} ${services} ${log} || ${fail}
84
+ @${compose} up --detach --scale app=$${instances:-1} ${services} ${log} || ${fail}
81
85
  endif
82
86
  @$(call printrawln,' ${green}started${reset} ${tick}')
83
87
  @$(call println,'${yellow}Waiting for services to become available${reset} ...')
@@ -207,9 +211,6 @@ endif
207
211
  ifndef manager
208
212
  @$(call println_error,'Missing `manager` parameter: `make deploy manager=swarm-manager.example.com`')
209
213
  endif
210
- ifeq (,${project_name})
211
- deploy: project_name = ${docker_repository}_${env}
212
- endif
213
214
  deploy: path := $(shell mktemp -d)
214
215
  deploy: RAILS_ENV := ${env}
215
216
  deploy: RACK_ENV := ${env}
@@ -1,11 +1,11 @@
1
1
  <% if compose.call('development').services.key?('rabbitmq') %>
2
2
  development:
3
- url: amqp://127.0.0.1:<%= compose.call('development').local_port('rabbitmq') %>
3
+ url: <%= "#{'<' + '%' + '='} ENV.fetch('RABBITMQ_URL', 'amqp://127.0.0.1:#{compose.call('development').local_port('rabbitmq')}') #{'%' + '>'}" %>
4
4
  <% end %>
5
5
 
6
6
  <% if compose.call('test').services.key?('rabbitmq') %>
7
7
  test:
8
- url: amqp://127.0.0.1:<%= compose.call('test').local_port('rabbitmq') %>
8
+ url: <%= "#{'<' + '%' + '='} ENV.fetch('RABBITMQ_URL', 'amqp://127.0.0.1:#{compose.call('test').local_port('rabbitmq')}') #{'%' + '>'}" %>
9
9
  <% end %>
10
10
 
11
11
  production:
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Orchestration
4
- VERSION = '0.4.5'
4
+ VERSION = '0.4.6'
5
5
  end
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.4.5
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Farrell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-22 00:00:00.000000000 Z
11
+ date: 2019-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: database_url