dru 0.6.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +77 -0
- data/Gemfile.lock +10 -73
- data/README.md +67 -16
- data/dru.gemspec +1 -14
- data/exe/dru +2 -4
- data/lib/dru.rb +4 -3
- data/lib/dru/argv.rb +46 -7
- data/lib/dru/cli.rb +8 -61
- data/lib/dru/command.rb +28 -93
- data/lib/dru/commands/attach.rb +13 -9
- data/lib/dru/commands/docker_compose.rb +1 -3
- data/lib/dru/config.rb +4 -2
- data/lib/dru/version.rb +1 -1
- metadata +17 -204
- data/CODE_OF_CONDUCT.md +0 -74
- data/lib/dru/commands/down.rb +0 -13
- data/lib/dru/commands/exec.rb +0 -13
- data/lib/dru/commands/runner.rb +0 -19
- data/lib/dru/commands/up.rb +0 -31
- data/lib/dru/container_command.rb +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8712f6e940546178246f68aa0272b599a90a9f4c94cb02263b444ebe11f01f4b
|
4
|
+
data.tar.gz: ec001fa5801d5d355d79f7fcc98f03ce84d0a028d4ef33a31efa4bcf160b370f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53c266f1b5d69ee119b0e540057677198387f0795208d9c260a96ac3b5fdbf10b1b73a9fc00890c94dad9c3b51c3d2295eab693361b665e6118abf817a4da6f2
|
7
|
+
data.tar.gz: 3545358f7885e0fc64aa4f268e2aae67cc2ca646cfb462dc03b6c2b63276e44e94cac93d535a0fe462081cb5cee20b5196fc0919b072f8a8c3daee9534c112ea
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# Ruby CircleCI 2.1 configuration file
|
2
|
+
#
|
3
|
+
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
|
4
|
+
#
|
5
|
+
version: 2.1
|
6
|
+
|
7
|
+
workflows:
|
8
|
+
version: 2
|
9
|
+
|
10
|
+
commit:
|
11
|
+
jobs:
|
12
|
+
- build
|
13
|
+
- tests:
|
14
|
+
requires:
|
15
|
+
- build
|
16
|
+
- upload-coverage:
|
17
|
+
requires:
|
18
|
+
- tests
|
19
|
+
|
20
|
+
defaults: &defaults
|
21
|
+
working_directory: ~/repo
|
22
|
+
docker:
|
23
|
+
- image: circleci/ruby:2.5.1
|
24
|
+
|
25
|
+
jobs:
|
26
|
+
build:
|
27
|
+
<<: *defaults
|
28
|
+
steps:
|
29
|
+
- run:
|
30
|
+
name: Download cc-test-reporter
|
31
|
+
command: |
|
32
|
+
mkdir -p tmp/
|
33
|
+
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./tmp/cc-test-reporter
|
34
|
+
chmod +x ./tmp/cc-test-reporter
|
35
|
+
- persist_to_workspace:
|
36
|
+
root: tmp
|
37
|
+
paths:
|
38
|
+
- cc-test-reporter
|
39
|
+
|
40
|
+
tests:
|
41
|
+
<<: *defaults
|
42
|
+
steps:
|
43
|
+
- checkout
|
44
|
+
- attach_workspace:
|
45
|
+
at: ~/repo/tmp
|
46
|
+
# Download and cache dependencies
|
47
|
+
- restore_cache:
|
48
|
+
keys:
|
49
|
+
- v1-dependencies-{{ checksum "Gemfile.lock" }}
|
50
|
+
# fallback to using the latest cache if no exact match is found
|
51
|
+
- v1-dependencies-
|
52
|
+
- run:
|
53
|
+
name: Install dependencies
|
54
|
+
command: |
|
55
|
+
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
56
|
+
- save_cache:
|
57
|
+
paths:
|
58
|
+
- ./vendor/bundle
|
59
|
+
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
|
60
|
+
- run:
|
61
|
+
name: Run tests
|
62
|
+
command: |
|
63
|
+
bundle exec rspec
|
64
|
+
./tmp/cc-test-reporter format-coverage -t simplecov -o tmp/codeclimate.json coverage/.resultset.json
|
65
|
+
- persist_to_workspace:
|
66
|
+
root: tmp
|
67
|
+
paths:
|
68
|
+
- codeclimate.json
|
69
|
+
upload-coverage:
|
70
|
+
<<: *defaults
|
71
|
+
steps:
|
72
|
+
- attach_workspace:
|
73
|
+
at: ~/repo/tmp
|
74
|
+
- run:
|
75
|
+
name: Upload coverage results to Code Climate
|
76
|
+
command: |
|
77
|
+
./tmp/cc-test-reporter upload-coverage -i tmp/codeclimate.json
|
data/Gemfile.lock
CHANGED
@@ -1,41 +1,26 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
dru (0.
|
4
|
+
dru (1.0.0)
|
5
5
|
pastel (~> 0.7.2)
|
6
6
|
thor (~> 0.20.0)
|
7
|
-
tty-color (~> 0.4.2)
|
8
7
|
tty-command (~> 0.8.0)
|
9
8
|
tty-config (~> 0.2.0)
|
10
|
-
tty-cursor (~> 0.5.0)
|
11
|
-
tty-editor (~> 0.4.0)
|
12
|
-
tty-file (~> 0.6.0)
|
13
|
-
tty-font (~> 0.2.0)
|
14
|
-
tty-markdown (~> 0.4.0)
|
15
|
-
tty-pager (~> 0.11.0)
|
16
|
-
tty-platform (~> 0.1.0)
|
17
|
-
tty-progressbar (~> 0.15.0)
|
18
|
-
tty-prompt (~> 0.16.1)
|
19
|
-
tty-screen (~> 0.6.4)
|
20
|
-
tty-spinner (~> 0.8.0)
|
21
|
-
tty-table (~> 0.10.0)
|
22
|
-
tty-tree (~> 0.1.0)
|
23
9
|
tty-which (~> 0.3.0)
|
24
10
|
|
25
11
|
GEM
|
26
12
|
remote: https://rubygems.org/
|
27
13
|
specs:
|
28
14
|
diff-lcs (1.3)
|
15
|
+
docile (1.3.1)
|
29
16
|
equatable (0.5.0)
|
30
|
-
|
31
|
-
necromancer (0.4.0)
|
17
|
+
json (2.2.0)
|
32
18
|
pastel (0.7.2)
|
33
19
|
equatable (~> 0.5.0)
|
34
20
|
tty-color (~> 0.4.0)
|
35
21
|
rake (10.5.0)
|
36
22
|
rake-compiler (1.0.5)
|
37
23
|
rake
|
38
|
-
rouge (3.1.1)
|
39
24
|
rspec (3.8.0)
|
40
25
|
rspec-core (~> 3.8.0)
|
41
26
|
rspec-expectations (~> 3.8.0)
|
@@ -49,66 +34,17 @@ GEM
|
|
49
34
|
diff-lcs (>= 1.2.0, < 2.0)
|
50
35
|
rspec-support (~> 3.8.0)
|
51
36
|
rspec-support (3.8.0)
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
37
|
+
simplecov (0.16.1)
|
38
|
+
docile (~> 1.1)
|
39
|
+
json (>= 1.8, < 3)
|
40
|
+
simplecov-html (~> 0.10.0)
|
41
|
+
simplecov-html (0.10.2)
|
57
42
|
thor (0.20.3)
|
58
|
-
timers (4.2.0)
|
59
43
|
tty-color (0.4.3)
|
60
44
|
tty-command (0.8.2)
|
61
45
|
pastel (~> 0.7.0)
|
62
46
|
tty-config (0.2.0)
|
63
|
-
tty-cursor (0.5.0)
|
64
|
-
tty-editor (0.4.0)
|
65
|
-
tty-prompt (~> 0.16.0)
|
66
|
-
tty-which (~> 0.3.0)
|
67
|
-
tty-file (0.6.0)
|
68
|
-
diff-lcs (~> 1.3.0)
|
69
|
-
pastel (~> 0.7.2)
|
70
|
-
tty-prompt (~> 0.16.1)
|
71
|
-
tty-font (0.2.0)
|
72
|
-
tty-markdown (0.4.0)
|
73
|
-
kramdown (~> 1.16.2)
|
74
|
-
pastel (~> 0.7.2)
|
75
|
-
rouge (~> 3.1.0)
|
76
|
-
strings (~> 0.1.0)
|
77
|
-
tty-color (~> 0.4.2)
|
78
|
-
tty-screen (~> 0.6.4)
|
79
|
-
tty-pager (0.11.0)
|
80
|
-
strings (~> 0.1.0)
|
81
|
-
tty-screen (~> 0.6.4)
|
82
|
-
tty-which (~> 0.3.0)
|
83
|
-
tty-platform (0.1.0)
|
84
|
-
tty-progressbar (0.15.1)
|
85
|
-
tty-cursor (~> 0.5.0)
|
86
|
-
tty-screen (~> 0.6.4)
|
87
|
-
unicode-display_width (~> 1.3)
|
88
|
-
tty-prompt (0.16.1)
|
89
|
-
necromancer (~> 0.4.0)
|
90
|
-
pastel (~> 0.7.0)
|
91
|
-
timers (~> 4.0)
|
92
|
-
tty-cursor (~> 0.5.0)
|
93
|
-
tty-reader (~> 0.3.0)
|
94
|
-
tty-reader (0.3.0)
|
95
|
-
tty-cursor (~> 0.5.0)
|
96
|
-
tty-screen (~> 0.6.4)
|
97
|
-
wisper (~> 2.0.0)
|
98
|
-
tty-screen (0.6.5)
|
99
|
-
tty-spinner (0.8.0)
|
100
|
-
tty-cursor (>= 0.5.0)
|
101
|
-
tty-table (0.10.0)
|
102
|
-
equatable (~> 0.5.0)
|
103
|
-
necromancer (~> 0.4.0)
|
104
|
-
pastel (~> 0.7.2)
|
105
|
-
strings (~> 0.1.0)
|
106
|
-
tty-screen (~> 0.6.4)
|
107
|
-
tty-tree (0.1.0)
|
108
47
|
tty-which (0.3.0)
|
109
|
-
unicode-display_width (1.4.0)
|
110
|
-
unicode_utils (1.4.0)
|
111
|
-
wisper (2.0.0)
|
112
48
|
|
113
49
|
PLATFORMS
|
114
50
|
ruby
|
@@ -119,6 +55,7 @@ DEPENDENCIES
|
|
119
55
|
rake (~> 10.0)
|
120
56
|
rake-compiler
|
121
57
|
rspec (~> 3.0)
|
58
|
+
simplecov (~> 0.16.1)
|
122
59
|
|
123
60
|
BUNDLED WITH
|
124
|
-
1.
|
61
|
+
1.17.3
|
data/README.md
CHANGED
@@ -1,28 +1,75 @@
|
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/dru.svg)](https://badge.fury.io/rb/dru)
|
2
|
+
[![CircleCI](https://circleci.com/gh/nebulab/dru/tree/master.svg?style=svg)](https://circleci.com/gh/nebulab/dru/tree/master)
|
3
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/9049d097bf908467eb85/maintainability)](https://codeclimate.com/github/nebulab/dru/maintainability)
|
4
|
+
[![Test Coverage](https://api.codeclimate.com/v1/badges/9049d097bf908467eb85/test_coverage)](https://codeclimate.com/github/nebulab/dru/test_coverage)
|
5
|
+
|
1
6
|
# Dru
|
2
7
|
|
3
|
-
|
8
|
+
DRU is a run utility to work on your projects with docker-compose where you can't put your config files inside the folder and also enhance the docker-compose command with custom commands, custom aliases, and environments support.
|
4
9
|
|
5
|
-
|
10
|
+
## Why should you use DRU?
|
6
11
|
|
7
|
-
|
12
|
+
Sometimes when we are working on projects, we can't put docker related configuration files into the project folder
|
13
|
+
or push it into our version control system.
|
8
14
|
|
9
|
-
|
15
|
+
Sure, we can always put the docker configuration files in a different place, but every time we have to run a command, it looks like:
|
10
16
|
|
11
|
-
|
12
|
-
|
13
|
-
|
17
|
+
$ docker-compose -f ~/config_folder/docker-compose.yml up
|
18
|
+
|
19
|
+
and if we have another docker configuration for a different environment the things go even worst:
|
20
|
+
|
21
|
+
$ docker-compose -f ~/config_folder/docker-compose.yml -f ~/config_folder/docker-compose.test.yml up
|
22
|
+
|
23
|
+
By following some simple conventions, DRU let we run the first command with:
|
24
|
+
|
25
|
+
$ dru up
|
14
26
|
|
15
|
-
|
27
|
+
and the second will be like:
|
16
28
|
|
17
|
-
$
|
29
|
+
$ dru -e test up
|
18
30
|
|
19
|
-
|
31
|
+
Furthermore, if we need to access the docker container shell, with vanilla docker-compose:
|
32
|
+
|
33
|
+
$ docker-compose -f ~/config_folder/docker-compose.yml run --rm --entrypoint sh container_name
|
34
|
+
|
35
|
+
with DRU:
|
36
|
+
|
37
|
+
$ dru shell container_name
|
38
|
+
|
39
|
+
## Installation
|
20
40
|
|
21
41
|
$ gem install dru
|
22
42
|
|
23
43
|
## Usage
|
24
44
|
|
25
|
-
|
45
|
+
Run:
|
46
|
+
|
47
|
+
$ dru help
|
48
|
+
|
49
|
+
for the list of the available commands.
|
50
|
+
|
51
|
+
All commands follow the same conventions. When you run a DRU command, by default it will look for a `docker-compose.yml` file into the `~/.dru/project_folder` where `project_folder` has the same name as the current working directory.
|
52
|
+
|
53
|
+
Suppose that you are in a directory called `example_project`, when you run a DRU command (e.g. `dru up`) it will search for a `docker-compose.yml` file into the `~/.dru/example_project` folder.
|
54
|
+
|
55
|
+
DRU also supports environments, that means that if you add the `-e test` option, it will combine the `~/.dru/example_project/docker-compose.yml` and `~/.dru/example_project/docker-compose.test.yml` into a single configuration.
|
56
|
+
|
57
|
+
Essentially it will run `docker-compose -f ~/.dru/example_project/docker-compose.yml -f ~/.dru/example_project/docker-compose.test.yml` when the second file name is given by the environment option. See [docker-compose documentation](https://docs.docker.com/compose/reference/overview/#specifying-multiple-compose-files) for more informations.
|
58
|
+
|
59
|
+
## Configuration
|
60
|
+
|
61
|
+
To override the default configuration you have to create the file `.druconfig` under your home folder:
|
62
|
+
|
63
|
+
```yaml
|
64
|
+
# ~/.druconfig
|
65
|
+
|
66
|
+
# default: ~/.dru if you like, you can set a custom location (path) for your docker configurations projects like ~/docker-config
|
67
|
+
docker_projects_folder: ~/.dru
|
68
|
+
|
69
|
+
# optional: use this if you want to create custom aliases
|
70
|
+
alias:
|
71
|
+
shell: run --rm --entrypoint sh
|
72
|
+
```
|
26
73
|
|
27
74
|
## Development
|
28
75
|
|
@@ -32,12 +79,16 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
79
|
|
33
80
|
## Contributing
|
34
81
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
82
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/nebulab/dru. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
83
|
+
|
84
|
+
## License
|
85
|
+
|
86
|
+
DRU is copyright © 2019 [Nebulab](http://nebulab.it/). It is free software, and may be redistributed under the terms specified in the [license](LICENSE.txt).
|
36
87
|
|
37
|
-
##
|
88
|
+
## About
|
38
89
|
|
39
|
-
|
90
|
+
![Nebulab](http://nebulab.it/assets/images/public/logo.svg)
|
40
91
|
|
41
|
-
|
92
|
+
DRU is funded and maintained by the [Nebulab](http://nebulab.it/) team.
|
42
93
|
|
43
|
-
|
94
|
+
We firmly believe in the power of open-source. [Contact us](http://nebulab.it/contact-us/) if you like our work and you need help with your project design or development.
|
data/dru.gemspec
CHANGED
@@ -35,22 +35,8 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.require_paths = ["lib"]
|
36
36
|
spec.extensions = ["ext/dru/extconf.rb"]
|
37
37
|
|
38
|
-
spec.add_dependency "tty-color", "~> 0.4.2"
|
39
38
|
spec.add_dependency "tty-command", "~> 0.8.0"
|
40
39
|
spec.add_dependency "tty-config", "~> 0.2.0"
|
41
|
-
spec.add_dependency "tty-cursor", "~> 0.5.0"
|
42
|
-
spec.add_dependency "tty-editor", "~> 0.4.0"
|
43
|
-
spec.add_dependency "tty-file", "~> 0.6.0"
|
44
|
-
spec.add_dependency "tty-font", "~> 0.2.0"
|
45
|
-
spec.add_dependency "tty-markdown", "~> 0.4.0"
|
46
|
-
spec.add_dependency "tty-pager", "~> 0.11.0"
|
47
|
-
spec.add_dependency "tty-platform", "~> 0.1.0"
|
48
|
-
spec.add_dependency "tty-progressbar", "~> 0.15.0"
|
49
|
-
spec.add_dependency "tty-prompt", "~> 0.16.1"
|
50
|
-
spec.add_dependency "tty-screen", "~> 0.6.4"
|
51
|
-
spec.add_dependency "tty-spinner", "~> 0.8.0"
|
52
|
-
spec.add_dependency "tty-table", "~> 0.10.0"
|
53
|
-
spec.add_dependency "tty-tree", "~> 0.1.0"
|
54
40
|
spec.add_dependency "tty-which", "~> 0.3.0"
|
55
41
|
spec.add_dependency "pastel", "~> 0.7.2"
|
56
42
|
spec.add_dependency "thor", "~> 0.20.0"
|
@@ -59,4 +45,5 @@ Gem::Specification.new do |spec|
|
|
59
45
|
spec.add_development_dependency "rake", "~> 10.0"
|
60
46
|
spec.add_development_dependency "rake-compiler"
|
61
47
|
spec.add_development_dependency "rspec", "~> 3.0"
|
48
|
+
spec.add_development_dependency "simplecov", "~> 0.16.1"
|
62
49
|
end
|
data/exe/dru
CHANGED
@@ -6,13 +6,11 @@ $:.unshift(lib_path) if !$:.include?(lib_path)
|
|
6
6
|
require 'dru'
|
7
7
|
|
8
8
|
Signal.trap('INT') do
|
9
|
-
warn("\n#{caller.join("\n")}: interrupted")
|
10
9
|
exit(1)
|
11
10
|
end
|
12
11
|
|
13
12
|
begin
|
14
|
-
Dru::CLI.start(Dru::Argv.
|
15
|
-
rescue Dru::CLI::Error
|
16
|
-
puts "ERROR: #{err.message}"
|
13
|
+
Dru::CLI.start(Dru::Argv.parse)
|
14
|
+
rescue Dru::CLI::Error
|
17
15
|
exit 1
|
18
16
|
end
|
data/lib/dru.rb
CHANGED
@@ -4,10 +4,11 @@ require "dru/cli"
|
|
4
4
|
|
5
5
|
module Dru
|
6
6
|
DRUCONFIG = File.expand_path('~/.druconfig')
|
7
|
+
DOCKER_COMMAND = 'docker'.freeze
|
7
8
|
DOCKER_COMPOSE_COMMAND = 'docker-compose'.freeze
|
8
|
-
DOCKER_COMPOSE_COMMANDS = %w[build bundle config create events images kill
|
9
|
-
logs pause port ps pull push restart rm scale
|
10
|
-
start stop top unpause]
|
9
|
+
DOCKER_COMPOSE_COMMANDS = %w[build bundle config create down events exec images kill
|
10
|
+
logs pause port ps pull push restart rm run scale
|
11
|
+
start stop top unpause up]
|
11
12
|
|
12
13
|
def self.config
|
13
14
|
Config.instance.tap { |instance| instance.config_file_path = DRUCONFIG }
|
data/lib/dru/argv.rb
CHANGED
@@ -1,27 +1,66 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'shellwords'
|
4
|
+
|
3
5
|
module Dru
|
4
6
|
class Argv
|
5
7
|
attr_reader :argv
|
6
8
|
|
9
|
+
def self.parse(*args)
|
10
|
+
new(*args).parse
|
11
|
+
end
|
12
|
+
|
7
13
|
def initialize(argv = ARGV)
|
8
|
-
@argv = argv
|
14
|
+
@argv = argv.dup
|
9
15
|
end
|
10
16
|
|
11
17
|
def parse
|
12
|
-
return argv unless
|
18
|
+
return argv unless known_command
|
13
19
|
|
14
|
-
|
20
|
+
if dru_command?(known_command)
|
21
|
+
parse_dru_command
|
22
|
+
elsif docker_compose_command?(known_command)
|
23
|
+
parse_docker_compose_command
|
24
|
+
else
|
25
|
+
parse_alias_command
|
26
|
+
end
|
15
27
|
end
|
16
28
|
|
17
29
|
private
|
18
30
|
|
19
|
-
def
|
20
|
-
argv.
|
31
|
+
def parse_docker_compose_command
|
32
|
+
argv.insert(known_command_index, Thor::Options::OPTS_END)
|
33
|
+
end
|
34
|
+
|
35
|
+
def parse_dru_command
|
36
|
+
argv.unshift(argv.delete(known_command))
|
37
|
+
end
|
38
|
+
|
39
|
+
def parse_alias_command
|
40
|
+
argv[known_command_index] = Shellwords.split(Dru.config.alias[known_command])
|
41
|
+
@argv = self.class.parse(argv.flatten)
|
42
|
+
end
|
43
|
+
|
44
|
+
def known_command
|
45
|
+
argv[known_command_index] if known_command_index
|
46
|
+
end
|
47
|
+
|
48
|
+
def known_command_index
|
49
|
+
@known_command_index ||= argv.index do |arg|
|
50
|
+
dru_command?(arg) || docker_compose_command?(arg) || alias_command?(arg)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def docker_compose_command?(command)
|
55
|
+
Dru::DOCKER_COMPOSE_COMMANDS.include?(command)
|
56
|
+
end
|
57
|
+
|
58
|
+
def dru_command?(command)
|
59
|
+
Dru::CLI.commands.keys.push('help').include?(command)
|
21
60
|
end
|
22
61
|
|
23
|
-
def
|
24
|
-
Dru
|
62
|
+
def alias_command?(command)
|
63
|
+
Dru.config.alias.respond_to?(command)
|
25
64
|
end
|
26
65
|
end
|
27
66
|
end
|
data/lib/dru/cli.rb
CHANGED
@@ -16,6 +16,8 @@ module Dru
|
|
16
16
|
|
17
17
|
default_command :docker_compose
|
18
18
|
|
19
|
+
stop_on_unknown_option! :attach, :up
|
20
|
+
|
19
21
|
def self.help(shell, subcommand = false)
|
20
22
|
shell.say `#{DOCKER_COMPOSE_COMMAND} help`
|
21
23
|
shell.say
|
@@ -50,73 +52,18 @@ Usage:
|
|
50
52
|
end
|
51
53
|
end
|
52
54
|
|
53
|
-
desc '
|
54
|
-
method_option :help, aliases: '-h', type: :boolean,
|
55
|
-
desc: 'Display usage information'
|
56
|
-
def down(*)
|
57
|
-
if options[:help]
|
58
|
-
invoke :help, ['down']
|
59
|
-
else
|
60
|
-
require_relative 'commands/down'
|
61
|
-
Dru::Commands::Down.new.execute
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
desc 'attach', 'Attach local standard input, output, and error streams to a running container'
|
55
|
+
desc 'attach [OPTIONS] SERVICE', 'Attach local standard input, output, and error streams to a running service'
|
66
56
|
method_option :help, aliases: '-h', type: :boolean,
|
67
57
|
desc: 'Display usage information'
|
68
|
-
method_option :
|
69
|
-
|
70
|
-
def attach(
|
71
|
-
if options[:help]
|
58
|
+
method_option :detach_keys, type: :string, default: 'ctrl-d',
|
59
|
+
desc: 'Override the key sequence for detaching a container'
|
60
|
+
def attach(service = nil)
|
61
|
+
if options[:help] || service.nil?
|
72
62
|
invoke :help, ['attach']
|
73
63
|
else
|
74
64
|
require_relative 'commands/attach'
|
75
|
-
Dru::Commands::Attach.new(options: options).execute
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
desc 'exec', 'Execute a command in a running container.'
|
80
|
-
method_option :help, aliases: '-h', type: :boolean,
|
81
|
-
desc: 'Display usage information'
|
82
|
-
method_option :container, aliases: '-c', type: :string, default: 'app',
|
83
|
-
desc: 'Container name'
|
84
|
-
def exec(*command)
|
85
|
-
if options[:help]
|
86
|
-
invoke :help, ['exec']
|
87
|
-
else
|
88
|
-
require_relative 'commands/exec'
|
89
|
-
Dru::Commands::Exec.new(command: command, options: options).execute
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
desc 'up', 'Build, (re)create, start, and attach to default container'
|
94
|
-
method_option :help, aliases: '-h', type: :boolean,
|
95
|
-
desc: 'Display usage information'
|
96
|
-
method_option :detach, aliases: '-d', type: :boolean,
|
97
|
-
desc: 'Detached mode'
|
98
|
-
def up(*)
|
99
|
-
if options[:help]
|
100
|
-
invoke :help, ['up']
|
101
|
-
else
|
102
|
-
require_relative 'commands/up'
|
103
|
-
Dru::Commands::Up.new(options: options).execute
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
desc 'run', 'Command description...'
|
108
|
-
method_option :help, aliases: '-h', type: :boolean,
|
109
|
-
desc: 'Display usage information'
|
110
|
-
method_option :container, aliases: '-c', type: :string, default: 'app',
|
111
|
-
desc: 'Container name'
|
112
|
-
def runner(*command)
|
113
|
-
if options[:help]
|
114
|
-
invoke :help, ['runner']
|
115
|
-
else
|
116
|
-
require_relative 'commands/runner'
|
117
|
-
Dru::Commands::Runner.new(command: command, options: options).execute
|
65
|
+
Dru::Commands::Attach.new(service: service, options: options).execute
|
118
66
|
end
|
119
67
|
end
|
120
|
-
map %w(run) => :runner
|
121
68
|
end
|
122
69
|
end
|
data/lib/dru/command.rb
CHANGED
@@ -6,16 +6,8 @@ module Dru
|
|
6
6
|
class Command
|
7
7
|
extend Forwardable
|
8
8
|
|
9
|
-
class MissingContainerError < StandardError
|
10
|
-
def initialize(msg = 'Missing container')
|
11
|
-
super
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
9
|
attr_accessor :options
|
16
10
|
|
17
|
-
def_delegators :command, :run
|
18
|
-
|
19
11
|
# Execute this command
|
20
12
|
#
|
21
13
|
# @api public
|
@@ -36,76 +28,6 @@ module Dru
|
|
36
28
|
TTY::Command.new({ printer: :quiet, uuid: false }.merge(options))
|
37
29
|
end
|
38
30
|
|
39
|
-
# The cursor movement
|
40
|
-
#
|
41
|
-
# @see http://www.rubydoc.info/gems/tty-cursor
|
42
|
-
#
|
43
|
-
# @api public
|
44
|
-
def cursor
|
45
|
-
require 'tty-cursor'
|
46
|
-
TTY::Cursor
|
47
|
-
end
|
48
|
-
|
49
|
-
# Open a file or text in the user's preferred editor
|
50
|
-
#
|
51
|
-
# @see http://www.rubydoc.info/gems/tty-editor
|
52
|
-
#
|
53
|
-
# @api public
|
54
|
-
def editor
|
55
|
-
require 'tty-editor'
|
56
|
-
TTY::Editor
|
57
|
-
end
|
58
|
-
|
59
|
-
# File manipulation utility methods
|
60
|
-
#
|
61
|
-
# @see http://www.rubydoc.info/gems/tty-file
|
62
|
-
#
|
63
|
-
# @api public
|
64
|
-
def generator
|
65
|
-
require 'tty-file'
|
66
|
-
TTY::File
|
67
|
-
end
|
68
|
-
|
69
|
-
# Terminal output paging
|
70
|
-
#
|
71
|
-
# @see http://www.rubydoc.info/gems/tty-pager
|
72
|
-
#
|
73
|
-
# @api public
|
74
|
-
def pager(**options)
|
75
|
-
require 'tty-pager'
|
76
|
-
TTY::Pager.new(options)
|
77
|
-
end
|
78
|
-
|
79
|
-
# Terminal platform and OS properties
|
80
|
-
#
|
81
|
-
# @see http://www.rubydoc.info/gems/tty-pager
|
82
|
-
#
|
83
|
-
# @api public
|
84
|
-
def platform
|
85
|
-
require 'tty-platform'
|
86
|
-
TTY::Platform.new
|
87
|
-
end
|
88
|
-
|
89
|
-
# The interactive prompt
|
90
|
-
#
|
91
|
-
# @see http://www.rubydoc.info/gems/tty-prompt
|
92
|
-
#
|
93
|
-
# @api public
|
94
|
-
def prompt(**options)
|
95
|
-
require 'tty-prompt'
|
96
|
-
TTY::Prompt.new(options)
|
97
|
-
end
|
98
|
-
|
99
|
-
# Get terminal screen properties
|
100
|
-
#
|
101
|
-
# @see http://www.rubydoc.info/gems/tty-screen
|
102
|
-
#
|
103
|
-
# @api public
|
104
|
-
def screen
|
105
|
-
require 'tty-screen'
|
106
|
-
TTY::Screen
|
107
|
-
end
|
108
|
-
|
109
31
|
# The unix which utility
|
110
32
|
#
|
111
33
|
# @see http://www.rubydoc.info/gems/tty-which
|
@@ -142,26 +64,39 @@ module Dru
|
|
142
64
|
File.join(project_configuration_path, 'docker-compose.yml')
|
143
65
|
end
|
144
66
|
|
145
|
-
def
|
146
|
-
|
147
|
-
|
148
|
-
File.
|
67
|
+
def override_docker_compose
|
68
|
+
override = environment || 'override'
|
69
|
+
docker_compose_file = File.join(project_configuration_path, "docker-compose.#{override}.yml")
|
70
|
+
return unless File.exist?(docker_compose_file)
|
71
|
+
docker_compose_file
|
149
72
|
end
|
150
73
|
|
151
74
|
def docker_compose_paths
|
152
|
-
docker_compose_default_path +
|
75
|
+
docker_compose_default_path + docker_compose_override_path
|
153
76
|
end
|
154
77
|
|
155
|
-
def
|
156
|
-
|
157
|
-
|
158
|
-
else
|
159
|
-
command(options).run(DOCKER_COMPOSE_COMMAND, *docker_compose_paths, *args)
|
78
|
+
def run(*command, **options)
|
79
|
+
command(options).run!(*command, { in: '/dev/tty', err: '/dev/tty' }.merge(options)).tap do |result|
|
80
|
+
raise Dru::CLI::Error, result.err unless result.success?
|
160
81
|
end
|
161
82
|
end
|
162
83
|
|
163
|
-
def
|
164
|
-
|
84
|
+
def run_docker_compose_command(*command, **options)
|
85
|
+
run(DOCKER_COMPOSE_COMMAND, '-p', docker_compose_project_name, *docker_compose_paths, *command, **options)
|
86
|
+
end
|
87
|
+
|
88
|
+
def run_docker_command(*command, **options)
|
89
|
+
run(DOCKER_COMMAND, *command, **options)
|
90
|
+
end
|
91
|
+
|
92
|
+
def container_name_to_id(container_name)
|
93
|
+
run_docker_compose_command('ps', '-q', container_name, only_output_on_error: true).out.strip
|
94
|
+
end
|
95
|
+
|
96
|
+
def docker_compose_project_name
|
97
|
+
return project_name unless environment
|
98
|
+
|
99
|
+
"#{project_name}_#{environment}"
|
165
100
|
end
|
166
101
|
|
167
102
|
private
|
@@ -170,10 +105,10 @@ module Dru
|
|
170
105
|
['-f', default_docker_compose]
|
171
106
|
end
|
172
107
|
|
173
|
-
def
|
174
|
-
return [] unless
|
108
|
+
def docker_compose_override_path
|
109
|
+
return [] unless override_docker_compose
|
175
110
|
|
176
|
-
['-f',
|
111
|
+
['-f', override_docker_compose]
|
177
112
|
end
|
178
113
|
end
|
179
114
|
end
|
data/lib/dru/commands/attach.rb
CHANGED
@@ -1,25 +1,29 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative '../
|
4
|
-
require_relative './down'
|
3
|
+
require_relative '../command'
|
5
4
|
|
6
5
|
module Dru
|
7
6
|
module Commands
|
8
|
-
class Attach < Dru::
|
9
|
-
|
7
|
+
class Attach < Dru::Command
|
8
|
+
ATTACH_COMMAND = 'attach'
|
9
|
+
|
10
|
+
def initialize(service:, options:)
|
11
|
+
@service = service
|
12
|
+
@options = options
|
13
|
+
end
|
10
14
|
|
11
15
|
def execute(input: $stdin, output: $stdout)
|
12
|
-
|
16
|
+
run_docker_command(ATTACH_COMMAND, detach_keys, container_id)
|
13
17
|
end
|
14
18
|
|
15
19
|
private
|
16
20
|
|
17
|
-
def
|
18
|
-
|
21
|
+
def detach_keys
|
22
|
+
"--detach-keys=#{@options[:detach_keys]}"
|
19
23
|
end
|
20
24
|
|
21
|
-
def
|
22
|
-
|
25
|
+
def container_id
|
26
|
+
container_name_to_id(@service)
|
23
27
|
end
|
24
28
|
end
|
25
29
|
end
|
@@ -5,15 +5,13 @@ require_relative '../command'
|
|
5
5
|
module Dru
|
6
6
|
module Commands
|
7
7
|
class DockerCompose < Dru::Command
|
8
|
-
attr_reader :command
|
9
|
-
|
10
8
|
def initialize(options:, command:)
|
11
9
|
@options = options
|
12
10
|
@command = command
|
13
11
|
end
|
14
12
|
|
15
13
|
def execute(input: $stdin, output: $stdout)
|
16
|
-
run_docker_compose_command(
|
14
|
+
run_docker_compose_command(*@command, tty: true)
|
17
15
|
end
|
18
16
|
end
|
19
17
|
end
|
data/lib/dru/config.rb
CHANGED
@@ -8,10 +8,11 @@ module Dru
|
|
8
8
|
extend Forwardable
|
9
9
|
include Singleton
|
10
10
|
|
11
|
-
def_delegators :configs, :docker_projects_folder
|
11
|
+
def_delegators :configs, :docker_projects_folder, :alias
|
12
12
|
|
13
13
|
DEFAULT = {
|
14
|
-
'docker_projects_folder' => "~/.dru"
|
14
|
+
'docker_projects_folder' => "~/.dru",
|
15
|
+
'alias' => {}
|
15
16
|
}.freeze
|
16
17
|
|
17
18
|
attr_reader :config_file_path
|
@@ -29,6 +30,7 @@ module Dru
|
|
29
30
|
|
30
31
|
def user_configs
|
31
32
|
return {} unless config_file_path && File.file?(config_file_path)
|
33
|
+
|
32
34
|
YAML.load_file(config_file_path) || {}
|
33
35
|
end
|
34
36
|
end
|
data/lib/dru/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dru
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Rimondi
|
@@ -9,22 +9,8 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-03-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: tty-color
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
requirements:
|
18
|
-
- - "~>"
|
19
|
-
- !ruby/object:Gem::Version
|
20
|
-
version: 0.4.2
|
21
|
-
type: :runtime
|
22
|
-
prerelease: false
|
23
|
-
version_requirements: !ruby/object:Gem::Requirement
|
24
|
-
requirements:
|
25
|
-
- - "~>"
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
version: 0.4.2
|
28
14
|
- !ruby/object:Gem::Dependency
|
29
15
|
name: tty-command
|
30
16
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,188 +39,6 @@ dependencies:
|
|
53
39
|
- - "~>"
|
54
40
|
- !ruby/object:Gem::Version
|
55
41
|
version: 0.2.0
|
56
|
-
- !ruby/object:Gem::Dependency
|
57
|
-
name: tty-cursor
|
58
|
-
requirement: !ruby/object:Gem::Requirement
|
59
|
-
requirements:
|
60
|
-
- - "~>"
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: 0.5.0
|
63
|
-
type: :runtime
|
64
|
-
prerelease: false
|
65
|
-
version_requirements: !ruby/object:Gem::Requirement
|
66
|
-
requirements:
|
67
|
-
- - "~>"
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: 0.5.0
|
70
|
-
- !ruby/object:Gem::Dependency
|
71
|
-
name: tty-editor
|
72
|
-
requirement: !ruby/object:Gem::Requirement
|
73
|
-
requirements:
|
74
|
-
- - "~>"
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
version: 0.4.0
|
77
|
-
type: :runtime
|
78
|
-
prerelease: false
|
79
|
-
version_requirements: !ruby/object:Gem::Requirement
|
80
|
-
requirements:
|
81
|
-
- - "~>"
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
version: 0.4.0
|
84
|
-
- !ruby/object:Gem::Dependency
|
85
|
-
name: tty-file
|
86
|
-
requirement: !ruby/object:Gem::Requirement
|
87
|
-
requirements:
|
88
|
-
- - "~>"
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
version: 0.6.0
|
91
|
-
type: :runtime
|
92
|
-
prerelease: false
|
93
|
-
version_requirements: !ruby/object:Gem::Requirement
|
94
|
-
requirements:
|
95
|
-
- - "~>"
|
96
|
-
- !ruby/object:Gem::Version
|
97
|
-
version: 0.6.0
|
98
|
-
- !ruby/object:Gem::Dependency
|
99
|
-
name: tty-font
|
100
|
-
requirement: !ruby/object:Gem::Requirement
|
101
|
-
requirements:
|
102
|
-
- - "~>"
|
103
|
-
- !ruby/object:Gem::Version
|
104
|
-
version: 0.2.0
|
105
|
-
type: :runtime
|
106
|
-
prerelease: false
|
107
|
-
version_requirements: !ruby/object:Gem::Requirement
|
108
|
-
requirements:
|
109
|
-
- - "~>"
|
110
|
-
- !ruby/object:Gem::Version
|
111
|
-
version: 0.2.0
|
112
|
-
- !ruby/object:Gem::Dependency
|
113
|
-
name: tty-markdown
|
114
|
-
requirement: !ruby/object:Gem::Requirement
|
115
|
-
requirements:
|
116
|
-
- - "~>"
|
117
|
-
- !ruby/object:Gem::Version
|
118
|
-
version: 0.4.0
|
119
|
-
type: :runtime
|
120
|
-
prerelease: false
|
121
|
-
version_requirements: !ruby/object:Gem::Requirement
|
122
|
-
requirements:
|
123
|
-
- - "~>"
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
version: 0.4.0
|
126
|
-
- !ruby/object:Gem::Dependency
|
127
|
-
name: tty-pager
|
128
|
-
requirement: !ruby/object:Gem::Requirement
|
129
|
-
requirements:
|
130
|
-
- - "~>"
|
131
|
-
- !ruby/object:Gem::Version
|
132
|
-
version: 0.11.0
|
133
|
-
type: :runtime
|
134
|
-
prerelease: false
|
135
|
-
version_requirements: !ruby/object:Gem::Requirement
|
136
|
-
requirements:
|
137
|
-
- - "~>"
|
138
|
-
- !ruby/object:Gem::Version
|
139
|
-
version: 0.11.0
|
140
|
-
- !ruby/object:Gem::Dependency
|
141
|
-
name: tty-platform
|
142
|
-
requirement: !ruby/object:Gem::Requirement
|
143
|
-
requirements:
|
144
|
-
- - "~>"
|
145
|
-
- !ruby/object:Gem::Version
|
146
|
-
version: 0.1.0
|
147
|
-
type: :runtime
|
148
|
-
prerelease: false
|
149
|
-
version_requirements: !ruby/object:Gem::Requirement
|
150
|
-
requirements:
|
151
|
-
- - "~>"
|
152
|
-
- !ruby/object:Gem::Version
|
153
|
-
version: 0.1.0
|
154
|
-
- !ruby/object:Gem::Dependency
|
155
|
-
name: tty-progressbar
|
156
|
-
requirement: !ruby/object:Gem::Requirement
|
157
|
-
requirements:
|
158
|
-
- - "~>"
|
159
|
-
- !ruby/object:Gem::Version
|
160
|
-
version: 0.15.0
|
161
|
-
type: :runtime
|
162
|
-
prerelease: false
|
163
|
-
version_requirements: !ruby/object:Gem::Requirement
|
164
|
-
requirements:
|
165
|
-
- - "~>"
|
166
|
-
- !ruby/object:Gem::Version
|
167
|
-
version: 0.15.0
|
168
|
-
- !ruby/object:Gem::Dependency
|
169
|
-
name: tty-prompt
|
170
|
-
requirement: !ruby/object:Gem::Requirement
|
171
|
-
requirements:
|
172
|
-
- - "~>"
|
173
|
-
- !ruby/object:Gem::Version
|
174
|
-
version: 0.16.1
|
175
|
-
type: :runtime
|
176
|
-
prerelease: false
|
177
|
-
version_requirements: !ruby/object:Gem::Requirement
|
178
|
-
requirements:
|
179
|
-
- - "~>"
|
180
|
-
- !ruby/object:Gem::Version
|
181
|
-
version: 0.16.1
|
182
|
-
- !ruby/object:Gem::Dependency
|
183
|
-
name: tty-screen
|
184
|
-
requirement: !ruby/object:Gem::Requirement
|
185
|
-
requirements:
|
186
|
-
- - "~>"
|
187
|
-
- !ruby/object:Gem::Version
|
188
|
-
version: 0.6.4
|
189
|
-
type: :runtime
|
190
|
-
prerelease: false
|
191
|
-
version_requirements: !ruby/object:Gem::Requirement
|
192
|
-
requirements:
|
193
|
-
- - "~>"
|
194
|
-
- !ruby/object:Gem::Version
|
195
|
-
version: 0.6.4
|
196
|
-
- !ruby/object:Gem::Dependency
|
197
|
-
name: tty-spinner
|
198
|
-
requirement: !ruby/object:Gem::Requirement
|
199
|
-
requirements:
|
200
|
-
- - "~>"
|
201
|
-
- !ruby/object:Gem::Version
|
202
|
-
version: 0.8.0
|
203
|
-
type: :runtime
|
204
|
-
prerelease: false
|
205
|
-
version_requirements: !ruby/object:Gem::Requirement
|
206
|
-
requirements:
|
207
|
-
- - "~>"
|
208
|
-
- !ruby/object:Gem::Version
|
209
|
-
version: 0.8.0
|
210
|
-
- !ruby/object:Gem::Dependency
|
211
|
-
name: tty-table
|
212
|
-
requirement: !ruby/object:Gem::Requirement
|
213
|
-
requirements:
|
214
|
-
- - "~>"
|
215
|
-
- !ruby/object:Gem::Version
|
216
|
-
version: 0.10.0
|
217
|
-
type: :runtime
|
218
|
-
prerelease: false
|
219
|
-
version_requirements: !ruby/object:Gem::Requirement
|
220
|
-
requirements:
|
221
|
-
- - "~>"
|
222
|
-
- !ruby/object:Gem::Version
|
223
|
-
version: 0.10.0
|
224
|
-
- !ruby/object:Gem::Dependency
|
225
|
-
name: tty-tree
|
226
|
-
requirement: !ruby/object:Gem::Requirement
|
227
|
-
requirements:
|
228
|
-
- - "~>"
|
229
|
-
- !ruby/object:Gem::Version
|
230
|
-
version: 0.1.0
|
231
|
-
type: :runtime
|
232
|
-
prerelease: false
|
233
|
-
version_requirements: !ruby/object:Gem::Requirement
|
234
|
-
requirements:
|
235
|
-
- - "~>"
|
236
|
-
- !ruby/object:Gem::Version
|
237
|
-
version: 0.1.0
|
238
42
|
- !ruby/object:Gem::Dependency
|
239
43
|
name: tty-which
|
240
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -333,6 +137,20 @@ dependencies:
|
|
333
137
|
- - "~>"
|
334
138
|
- !ruby/object:Gem::Version
|
335
139
|
version: '3.0'
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: simplecov
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - "~>"
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: 0.16.1
|
147
|
+
type: :development
|
148
|
+
prerelease: false
|
149
|
+
version_requirements: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - "~>"
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: 0.16.1
|
336
154
|
description: " A ruby tool to simplify the development workflow with Docker Compose
|
337
155
|
and Docker.\n"
|
338
156
|
email:
|
@@ -344,10 +162,10 @@ extensions:
|
|
344
162
|
- ext/dru/extconf.rb
|
345
163
|
extra_rdoc_files: []
|
346
164
|
files:
|
165
|
+
- ".circleci/config.yml"
|
347
166
|
- ".gitignore"
|
348
167
|
- ".rspec"
|
349
168
|
- ".travis.yml"
|
350
|
-
- CODE_OF_CONDUCT.md
|
351
169
|
- Gemfile
|
352
170
|
- Gemfile.lock
|
353
171
|
- LICENSE.txt
|
@@ -367,12 +185,7 @@ files:
|
|
367
185
|
- lib/dru/commands/.gitkeep
|
368
186
|
- lib/dru/commands/attach.rb
|
369
187
|
- lib/dru/commands/docker_compose.rb
|
370
|
-
- lib/dru/commands/down.rb
|
371
|
-
- lib/dru/commands/exec.rb
|
372
|
-
- lib/dru/commands/runner.rb
|
373
|
-
- lib/dru/commands/up.rb
|
374
188
|
- lib/dru/config.rb
|
375
|
-
- lib/dru/container_command.rb
|
376
189
|
- lib/dru/templates/.gitkeep
|
377
190
|
- lib/dru/templates/attach/.gitkeep
|
378
191
|
- lib/dru/templates/docker_compose/.gitkeep
|
data/CODE_OF_CONDUCT.md
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
2
|
-
|
3
|
-
## Our Pledge
|
4
|
-
|
5
|
-
In the interest of fostering an open and welcoming environment, we as
|
6
|
-
contributors and maintainers pledge to making participation in our project and
|
7
|
-
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
-
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
-
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
-
orientation.
|
11
|
-
|
12
|
-
## Our Standards
|
13
|
-
|
14
|
-
Examples of behavior that contributes to creating a positive environment
|
15
|
-
include:
|
16
|
-
|
17
|
-
* Using welcoming and inclusive language
|
18
|
-
* Being respectful of differing viewpoints and experiences
|
19
|
-
* Gracefully accepting constructive criticism
|
20
|
-
* Focusing on what is best for the community
|
21
|
-
* Showing empathy towards other community members
|
22
|
-
|
23
|
-
Examples of unacceptable behavior by participants include:
|
24
|
-
|
25
|
-
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
-
advances
|
27
|
-
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
-
* Public or private harassment
|
29
|
-
* Publishing others' private information, such as a physical or electronic
|
30
|
-
address, without explicit permission
|
31
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
-
professional setting
|
33
|
-
|
34
|
-
## Our Responsibilities
|
35
|
-
|
36
|
-
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
-
behavior and are expected to take appropriate and fair corrective action in
|
38
|
-
response to any instances of unacceptable behavior.
|
39
|
-
|
40
|
-
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
-
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
-
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
-
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
-
threatening, offensive, or harmful.
|
45
|
-
|
46
|
-
## Scope
|
47
|
-
|
48
|
-
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
-
when an individual is representing the project or its community. Examples of
|
50
|
-
representing a project or community include using an official project e-mail
|
51
|
-
address, posting via an official social media account, or acting as an appointed
|
52
|
-
representative at an online or offline event. Representation of a project may be
|
53
|
-
further defined and clarified by project maintainers.
|
54
|
-
|
55
|
-
## Enforcement
|
56
|
-
|
57
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
-
reported by contacting the project team at christian.rimondi@gmail.com. All
|
59
|
-
complaints will be reviewed and investigated and will result in a response that
|
60
|
-
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
-
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
-
Further details of specific enforcement policies may be posted separately.
|
63
|
-
|
64
|
-
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
-
faith may face temporary or permanent repercussions as determined by other
|
66
|
-
members of the project's leadership.
|
67
|
-
|
68
|
-
## Attribution
|
69
|
-
|
70
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
-
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
-
|
73
|
-
[homepage]: http://contributor-covenant.org
|
74
|
-
[version]: http://contributor-covenant.org/version/1/4/
|
data/lib/dru/commands/down.rb
DELETED
data/lib/dru/commands/exec.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative '../container_command'
|
4
|
-
|
5
|
-
module Dru
|
6
|
-
module Commands
|
7
|
-
class Exec < Dru::ContainerCommand
|
8
|
-
def execute(input: $stdin, output: $stdout)
|
9
|
-
run_docker_compose_command('exec', container, *@command, tty: true)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
data/lib/dru/commands/runner.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative '../container_command'
|
4
|
-
|
5
|
-
module Dru
|
6
|
-
module Commands
|
7
|
-
class Runner < Dru::ContainerCommand
|
8
|
-
def execute(input: $stdin, output: $stdout)
|
9
|
-
run_docker_compose_command('run', '--rm', '--entrypoint', 'sh -c', container, command, tty: true)
|
10
|
-
end
|
11
|
-
|
12
|
-
private
|
13
|
-
|
14
|
-
def command
|
15
|
-
@command.join(' ')
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
data/lib/dru/commands/up.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative '../command'
|
4
|
-
require_relative './attach'
|
5
|
-
|
6
|
-
module Dru
|
7
|
-
module Commands
|
8
|
-
class Up < Dru::Command
|
9
|
-
def initialize(options:)
|
10
|
-
@options = options
|
11
|
-
end
|
12
|
-
|
13
|
-
def execute(input: $stdin, output: $stdout)
|
14
|
-
start_docker_compose
|
15
|
-
return if options[:detach]
|
16
|
-
|
17
|
-
attach_to_default_container
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def start_docker_compose
|
23
|
-
run_docker_compose_command('up', '-d')
|
24
|
-
end
|
25
|
-
|
26
|
-
def attach_to_default_container
|
27
|
-
Attach.new(options: { container: 'app' }).execute
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative './command'
|
4
|
-
|
5
|
-
module Dru
|
6
|
-
class ContainerCommand < Command
|
7
|
-
def initialize(command: nil, options:)
|
8
|
-
raise MissingContainerError unless options[:container]
|
9
|
-
|
10
|
-
@options = options
|
11
|
-
@command = command || []
|
12
|
-
end
|
13
|
-
|
14
|
-
def execute(input: $stdin, output: $stdout)
|
15
|
-
raise NotImplementedError
|
16
|
-
end
|
17
|
-
|
18
|
-
protected
|
19
|
-
|
20
|
-
def container
|
21
|
-
options[:container]
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|