orchestration 0.3.12 → 0.3.13

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: fa88aaad54c45cf3a049016f35f7fbe14a93e98c1f804253c6092d32581ad4bb
4
- data.tar.gz: 5eff5d0d6e44485812f320ac938ff081fa49daf8b88c59ffa65c33450420bfeb
3
+ metadata.gz: 0b45aa732e39c5ac61b9805a5872f2d9674fb93ab1019f01dd5b1036b5a3e649
4
+ data.tar.gz: b0d4c6059142bac5e727586ae55de030dc5f75ed9a4acf128a1f260323bee2e2
5
5
  SHA512:
6
- metadata.gz: e9f031ebae8eeed8122e6b3a37db600848fa2e02726162aac785b20844e1f7911a56d3d9a5cf949e585a0c4cb74b434afc3727721beabee29d707a6d25563113
7
- data.tar.gz: 456825bd84a2f32ede7b4e9dc0d5720b4c15abebb35dbf244620e1f3f3f05a251ba0e7718da5c6384d1062a1553dfc61c6494f6caff9e6c42ee0fd4864922ab2
6
+ metadata.gz: 705db40fc17fe876fb20b4c0319ec29bb66e89e4202a2e12ea1bea386130636dc52302047e2ce985f972c42e398ab0d09afd13ef0d0be1521d62a58fd2933925
7
+ data.tar.gz: f28843374e586e7d8fd299e588aa2b95602993faca0207c59a7e9f121658711db8c2c24bec2b58d72fa405b7141e90dd578bbf97b3722e096138ca047c3aeea9
data/README.md CHANGED
@@ -11,7 +11,7 @@ _Orchestration_ is a toolkit for testing, building, and deploying _Ruby_ (includ
11
11
  Add _Orchestration_ to your Gemfile:
12
12
 
13
13
  ```ruby
14
- gem 'orchestration', '~> 0.3.12'
14
+ gem 'orchestration', '~> 0.3.13'
15
15
  ```
16
16
 
17
17
  Install:
@@ -22,6 +22,10 @@ module Orchestration
22
22
  create_compose_file(:development)
23
23
  end
24
24
 
25
+ def docker_compose_local_yml
26
+ create_compose_file(:local)
27
+ end
28
+
25
29
  def docker_compose_production_yml
26
30
  create_compose_file(:production)
27
31
  end
@@ -80,7 +84,7 @@ module Orchestration
80
84
  %i[database mongo rabbitmq]
81
85
  when :production
82
86
  %i[haproxy app database mongo rabbitmq]
83
- when nil
87
+ when :local, nil
84
88
  []
85
89
  else
86
90
  raise ArgumentError, environment.inspect
@@ -56,7 +56,7 @@ module Orchestration
56
56
 
57
57
  def gitignore
58
58
  path = @env.root.join('.gitignore')
59
- globs = %w[.build/ .deploy/ Gemfile Gemfile.lock]
59
+ globs = %w[.build/ .deploy/ Gemfile Gemfile.lock docker-compose.local.yml]
60
60
  entries = %w[.env deploy.tar] + globs.map do |entry|
61
61
  "#{@env.orchestration_dir_name}/#{entry}"
62
62
  end
@@ -86,6 +86,7 @@ module Orchestration
86
86
  @docker_compose.docker_compose_yml
87
87
  @docker_compose.docker_compose_test_yml
88
88
  @docker_compose.docker_compose_development_yml
89
+ @docker_compose.docker_compose_local_yml
89
90
  @docker_compose.docker_compose_production_yml
90
91
  @docker_compose.docker_compose_override_yml
91
92
  end
@@ -34,6 +34,11 @@ module Orchestration
34
34
  @settings = merged_settings
35
35
  return if @adapter.name == 'sqlite3'
36
36
  return unless %w[test development].include?(@env.environment)
37
+
38
+ merge_port
39
+ end
40
+
41
+ def merge_port
37
42
  return if environment.key?('port') || url_config['port']
38
43
 
39
44
  @settings.merge!('port' => local_port) if @env.docker_compose_config?
@@ -58,10 +58,10 @@ pull:
58
58
  @${compose} pull
59
59
 
60
60
  .PHONY: logs
61
- service := app
61
+ logs: service := app
62
62
  logs:
63
63
  ifndef manager
64
- @$(error Missing `manager` parameter: `make logs manager=swarm-manager.example.com`)
64
+ @$(error Missing `manager` parameter: `make logs manager=swarm-manager.example.com`)
65
65
  else
66
66
  ssh ${manager} "docker service logs -f ${project_name}_${service}"
67
67
  endif
@@ -29,21 +29,24 @@ compose_base:=env HOST_UID=$(shell id -u) \
29
29
  DOCKER_REPOSITORY=${docker_repository} \
30
30
  docker-compose \
31
31
  -p ${docker_repository}_${env} \
32
- -f <%= env.orchestration_dir_name %>/docker-compose.yml
32
+ -f <%= env.orchestration_dir_name %>/docker-compose.yml \
33
33
 
34
34
  git_branch:=$(if $(branch),$(branch),$(shell git rev-parse --abbrev-ref HEAD))
35
35
  git_version:=$(shell git rev-parse --short --verify ${git_branch})
36
36
 
37
37
  compose:=${compose_base} -f <%= env.orchestration_dir_name %>/docker-compose.${env}.yml -f <%= env.orchestration_dir_name %>/docker-compose.override.yml
38
38
 
39
+ ifneq (,$(wildcard <%= env.orchestration_dir_name %>/docker-compose.local.yml))
40
+ compose:=${compose} -f <%= env.orchestration_dir_name %>/docker-compose.local.yml
41
+ endif
42
+
39
43
  ### Container management commands ###
40
44
 
41
45
  .PHONY: start
42
46
  start:
43
47
  @echo "Starting containers..."
44
48
  ifeq (${env},$(filter ${env},test development))
45
- @${compose} up -d
46
- @docker network connect ${docker_repository}_${env}_default $${hostname} 2>/dev/null || :
49
+ @(docker ps --format "{{.ID}}" | grep -q $(shell hostname) && ${compose} up -d && docker network connect ${docker_repository}_${env}_default $(shell hostname)) || ${compose} up -d
47
50
  else
48
51
  @${compose} up -d --scale app=$${instances:-1}
49
52
  endif
@@ -90,6 +93,33 @@ bundle:
90
93
  @tar -C <%= env.orchestration_dir_name %>/.deploy -cf ./deploy.tar ./${docker_repository}
91
94
  @echo 'Deployment bundle written to ./deploy.tar'
92
95
 
96
+ .PHONY: deploy
97
+ deploy:
98
+ ifndef manager
99
+ @$(error Missing `manager` parameter: `make deploy manager=swarm-manager.example.com`)
100
+ else
101
+ @echo 'Deploying stack via ${manager}...'
102
+ endif
103
+
104
+ ifndef env_file
105
+ $(MAKE) bundle \
106
+ && workdir=$$(mktemp -d) \
107
+ && mv deploy.tar $${workdir}/ \
108
+ && cd $${workdir} \
109
+ && tar xf deploy.tar \
110
+ && cd ${docker_repository} \
111
+ && tar -cf - . | ssh ${manager} 'cd $$(mktemp -d) && chmod 0700 . && cat - | tar -x && make deploy-stack && rm -r $$(pwd)'
112
+ else
113
+ $(MAKE) bundle \
114
+ && workdir=$$(mktemp -d) \
115
+ && mv deploy.tar $${workdir}/ \
116
+ && cd $${workdir} \
117
+ && tar xf deploy.tar \
118
+ && cd ${docker_repository} \
119
+ && cp "${env_file}" ./.env \
120
+ && tar -cf - . | ssh ${manager} 'cd $$(mktemp -d) && chmod 0700 . && cat - | tar -x && make deploy-stack && rm -r $$(pwd)'
121
+ endif
122
+
93
123
  ### Database utility commands ###
94
124
 
95
125
  .PHONY: migrate
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Orchestration
4
- VERSION = '0.3.12'
4
+ VERSION = '0.3.13'
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.3.12
4
+ version: 0.3.13
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-01-29 00:00:00.000000000 Z
11
+ date: 2019-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize