dip 3.5.1 → 3.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +54 -40
- data/exe/dip +2 -2
- data/lib/dip.rb +1 -1
- data/lib/dip/commands/console.rb +1 -1
- data/lib/dip/config.rb +29 -35
- data/lib/dip/environment.rb +1 -1
- data/lib/dip/ext/hash.rb +35 -0
- data/lib/dip/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3246e04b08a0a56b6e0affd8eff3d770647145546f3c47425291fd8f6f731da4
|
4
|
+
data.tar.gz: d68016e14a196cb6265dcc7a37782df46d1ba911921aab9bc42d7e62e6ed7230
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a846265e4fae5e87cd5e4e0ff75c7c7b4c6a600113fe5ffe509bec059aff169c53e45512408034fba1c22e6e23dcf9802730aee64952f05e301f9734bd9f775
|
7
|
+
data.tar.gz: bf3372c2dcae8432c1faf37a2d807b5214f1aa26f934195191a5abfcc8d37cd60c87683e9b59769ec5d4ee5028001e9410287cccc4d38b2ddb8db51041d53c94
|
data/README.md
CHANGED
@@ -6,30 +6,57 @@
|
|
6
6
|
|
7
7
|
Docker Interaction Process
|
8
8
|
|
9
|
-
|
9
|
+
Command line utility that gives the "native" interaction with applications configured with Docker Compose. It is for the local development only. In practice, it creates the feeling that you work without containers.
|
10
10
|
|
11
|
-
|
11
|
+
<a href="https://evilmartians.com/?utm_source=dip">
|
12
|
+
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54"></a>
|
12
13
|
|
13
|
-
##
|
14
|
+
## Presentations and examples
|
15
|
+
|
16
|
+
- [Local development with Docker containers](https://slides.com/bibendi/dip)
|
17
|
+
- [Dockerized Ruby on Rails application](https://github.com/bibendi/dip-example-rails)
|
18
|
+
- [Dockerized Node.js application](https://github.com/bibendi/yt-graphql-react-event-booking-api)
|
19
|
+
- [Dockerized Ruby gem](https://github.com/bibendi/schked)
|
20
|
+
|
21
|
+
[![asciicast](https://asciinema.org/a/210236.svg)](https://asciinema.org/a/210236)
|
22
|
+
|
23
|
+
## Integration with shell
|
24
|
+
|
25
|
+
Dip can be injected into current shell. For now, it supported ZSH only.
|
14
26
|
|
15
27
|
```sh
|
16
|
-
|
28
|
+
dip console | source /dev/stdin
|
17
29
|
```
|
18
30
|
|
19
|
-
|
31
|
+
After that we can type commands without `dip` prefix. For example:
|
20
32
|
|
21
|
-
|
33
|
+
```sh
|
34
|
+
<run-command> *any-args
|
35
|
+
compose *any-compose-arg
|
36
|
+
up <service>
|
37
|
+
down
|
38
|
+
provision
|
39
|
+
```
|
40
|
+
|
41
|
+
When we change the current directory, all shell aliases will be automatically removed. But when we will enter back to a directory with a dip.yml file, then shell aliases will be renewed.
|
42
|
+
|
43
|
+
Also, in shell mode Dip is trying to determine passed manually environment variables. For example:
|
44
|
+
|
45
|
+
```sh
|
46
|
+
VERSION=20180515103400 rails db:migrate:down
|
47
|
+
```
|
48
|
+
|
49
|
+
## Installation
|
22
50
|
|
51
|
+
```sh
|
52
|
+
gem install dip
|
53
|
+
```
|
23
54
|
|
24
55
|
## Docker installation
|
25
56
|
|
26
57
|
- [Ubuntu](docs/docker-ubuntu-install.md)
|
27
58
|
- [Mac OS](docs/docker-for-mac-install.md)
|
28
59
|
|
29
|
-
## Examples
|
30
|
-
|
31
|
-
- [Modern Rails application with webpack](https://github.com/bibendi/dip-example-rails)
|
32
|
-
|
33
60
|
## Usage
|
34
61
|
|
35
62
|
```sh
|
@@ -39,6 +66,15 @@ dip SUBCOMMAND --help
|
|
39
66
|
|
40
67
|
### dip.yml
|
41
68
|
|
69
|
+
The configuration file `dip.yml` should be placed in a project root directory.
|
70
|
+
Also, in some cases, you may want to change the default config path by providing an environment variable `DIP_FILE`.
|
71
|
+
If nearby places `dip.override.yml` file it would be merged into the main config.
|
72
|
+
|
73
|
+
Below is an example of real config.
|
74
|
+
`dip.yml` reference will be written soon.
|
75
|
+
Also, you can check out examples in the top.
|
76
|
+
|
77
|
+
|
42
78
|
```yml
|
43
79
|
version: '2'
|
44
80
|
|
@@ -53,7 +89,7 @@ compose:
|
|
53
89
|
project_name: bear
|
54
90
|
|
55
91
|
interaction:
|
56
|
-
|
92
|
+
bash:
|
57
93
|
service: app
|
58
94
|
compose_run_options: [no-deps]
|
59
95
|
|
@@ -77,16 +113,16 @@ interaction:
|
|
77
113
|
subcommands:
|
78
114
|
s:
|
79
115
|
service: web
|
80
|
-
|
116
|
+
compose_run_options: [service-ports]
|
81
117
|
|
82
118
|
psql:
|
83
119
|
service: app
|
84
120
|
command: psql -h pg -U postgres
|
85
121
|
|
86
122
|
provision:
|
123
|
+
- dip compose down --volumes
|
87
124
|
- dip compose up -d pg redis
|
88
|
-
- dip
|
89
|
-
- dip rake db:migrate
|
125
|
+
- dip bash -c ./bin/setup
|
90
126
|
```
|
91
127
|
|
92
128
|
### dip run
|
@@ -119,32 +155,6 @@ dip compose COMMAND [OPTIONS]
|
|
119
155
|
dip compose up -d redis
|
120
156
|
```
|
121
157
|
|
122
|
-
### Integration with shell
|
123
|
-
|
124
|
-
Dip can be injected into current shell. For now, it supported ZSH only.
|
125
|
-
|
126
|
-
```sh
|
127
|
-
dip console | source /dev/stdin
|
128
|
-
```
|
129
|
-
|
130
|
-
After that we can type commands without `dip` prefix. For example:
|
131
|
-
|
132
|
-
```sh
|
133
|
-
<run-command> *any-args
|
134
|
-
compose *any-compose-arg
|
135
|
-
up <service>
|
136
|
-
down
|
137
|
-
provision
|
138
|
-
```
|
139
|
-
|
140
|
-
When we change the current directory, all shell aliases will be automatically removed. But when we will enter back to a directory with a dip.yml file, then shell aliases will be renewed.
|
141
|
-
|
142
|
-
Also, in shell mode Dip is trying to determine passed manually environment variables. For example:
|
143
|
-
|
144
|
-
```sh
|
145
|
-
VERSION=20180515103400 rails db:migrate:down
|
146
|
-
```
|
147
|
-
|
148
158
|
### dip ssh
|
149
159
|
|
150
160
|
Runs ssh-agent container based on https://github.com/whilp/ssh-agent with your ~/.ssh/id_rsa.
|
@@ -237,3 +247,7 @@ dip dns up
|
|
237
247
|
cd foo-project
|
238
248
|
dip compose exec foo-web curl http://www.bar-app.docker/api/v1/baz_service
|
239
249
|
```
|
250
|
+
|
251
|
+
## Changelog
|
252
|
+
|
253
|
+
https://github.com/bibendi/dip/releases
|
data/exe/dip
CHANGED
data/lib/dip.rb
CHANGED
data/lib/dip/commands/console.rb
CHANGED
data/lib/dip/config.rb
CHANGED
@@ -3,16 +3,35 @@
|
|
3
3
|
require "yaml"
|
4
4
|
require "erb"
|
5
5
|
|
6
|
+
require "dip/ext/hash"
|
7
|
+
|
8
|
+
using ActiveSupportHashHelpers
|
9
|
+
|
6
10
|
module Dip
|
7
11
|
class Config
|
8
12
|
DEFAULT_PATH = "dip.yml"
|
9
13
|
|
10
|
-
|
11
|
-
|
12
|
-
|
14
|
+
class << self
|
15
|
+
def exist?
|
16
|
+
File.exist?(path)
|
17
|
+
end
|
18
|
+
|
19
|
+
def path
|
20
|
+
ENV["DIP_FILE"] || File.join(Dir.pwd, DEFAULT_PATH)
|
21
|
+
end
|
22
|
+
|
23
|
+
def override_path
|
24
|
+
path.gsub(/\.yml$/, ".override.yml")
|
25
|
+
end
|
13
26
|
|
14
|
-
|
15
|
-
|
27
|
+
def load_yaml(file_path = path)
|
28
|
+
return {} unless File.exist?(file_path)
|
29
|
+
|
30
|
+
YAML.safe_load(
|
31
|
+
ERB.new(File.read(file_path)).result,
|
32
|
+
[], [], true
|
33
|
+
).deep_symbolize_keys!
|
34
|
+
end
|
16
35
|
end
|
17
36
|
|
18
37
|
%i[environment compose interaction provision].each do |key|
|
@@ -28,39 +47,14 @@ module Dip
|
|
28
47
|
private
|
29
48
|
|
30
49
|
def config
|
31
|
-
@config
|
32
|
-
end
|
33
|
-
|
34
|
-
def load
|
35
|
-
raise ArgumentError, "Dip config not found at path '#{@path}'" unless exist?
|
50
|
+
return @config if @config
|
36
51
|
|
37
|
-
|
38
|
-
ERB.new(File.read(@path)).result,
|
39
|
-
[], [], true
|
40
|
-
)
|
52
|
+
raise ArgumentError, "Dip config not found at path '#{self.class.path}'" unless self.class.exist?
|
41
53
|
|
42
|
-
|
54
|
+
config = self.class.load_yaml
|
55
|
+
config.deep_merge!(self.class.load_yaml(self.class.override_path))
|
43
56
|
|
44
|
-
@config
|
45
|
-
end
|
46
|
-
|
47
|
-
# rubocop:disable Metrics/MethodLength
|
48
|
-
def deep_symbolyze_keys!(object)
|
49
|
-
case object
|
50
|
-
when Hash
|
51
|
-
object.keys.each do |key|
|
52
|
-
value = object.delete(key)
|
53
|
-
key = key.to_sym if key.is_a?(String)
|
54
|
-
object[key] = deep_symbolyze_keys!(value)
|
55
|
-
end
|
56
|
-
|
57
|
-
object
|
58
|
-
when Array
|
59
|
-
object.map! { |e| deep_symbolyze_keys!(e) }
|
60
|
-
else
|
61
|
-
object
|
62
|
-
end
|
57
|
+
@config = config
|
63
58
|
end
|
64
|
-
# rubocop:enable Metrics/MethodLength
|
65
59
|
end
|
66
60
|
end
|
data/lib/dip/environment.rb
CHANGED
data/lib/dip/ext/hash.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# active_support helpers
|
4
|
+
module ActiveSupportHashHelpers
|
5
|
+
refine Hash do
|
6
|
+
def deep_symbolize_keys!
|
7
|
+
deep_transform_keys! { |key| key.respond_to?(:to_sym) ? key.to_sym : key }
|
8
|
+
end
|
9
|
+
|
10
|
+
def deep_transform_keys!(&block)
|
11
|
+
keys.each do |key|
|
12
|
+
value = delete(key)
|
13
|
+
self[yield(key)] = value.is_a?(Hash) ? value.deep_transform_keys!(&block) : value
|
14
|
+
end
|
15
|
+
|
16
|
+
self
|
17
|
+
end
|
18
|
+
|
19
|
+
def deep_merge(other_hash, &block)
|
20
|
+
dup.deep_merge!(other_hash, &block)
|
21
|
+
end
|
22
|
+
|
23
|
+
def deep_merge!(other_hash, &block)
|
24
|
+
merge!(other_hash) do |key, this_val, other_val|
|
25
|
+
if this_val.is_a?(Hash) && other_val.is_a?(Hash)
|
26
|
+
this_val.deep_merge(other_val, &block)
|
27
|
+
elsif block_given?
|
28
|
+
block.call(key, this_val, other_val)
|
29
|
+
else
|
30
|
+
other_val
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/dip/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bibendi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -28,14 +28,14 @@ dependencies:
|
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.16'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.16'
|
41
41
|
- !ruby/object:Gem::Dependency
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '12.3'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '12.3'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,6 +150,7 @@ files:
|
|
150
150
|
- lib/dip/commands/ssh.rb
|
151
151
|
- lib/dip/config.rb
|
152
152
|
- lib/dip/environment.rb
|
153
|
+
- lib/dip/ext/hash.rb
|
153
154
|
- lib/dip/run_vars.rb
|
154
155
|
- lib/dip/version.rb
|
155
156
|
homepage: https://github.com/bibendi/dip
|