wp-docker 0.0.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -4
- data/bin/wp-docker +50 -68
- data/lib/commands/_loader.rb +4 -1
- data/lib/commands/cli.rb +6 -0
- data/lib/commands/help.rb +4 -4
- data/lib/commands/remove.rb +15 -0
- data/lib/commands/shell.rb +13 -4
- data/lib/commands/start.rb +15 -0
- data/lib/commands/stop.rb +15 -0
- data/lib/config_manager.rb +23 -5
- data/lib/docker_manager.rb +12 -3
- data/lib/version.rb +3 -0
- data/wp-docker.gemspec +3 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 251fed4e3a00b33681ceacf7e1e8d115252671dc
|
4
|
+
data.tar.gz: '08944dc38a10df399711d91358e773777d5a7bf1'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b24012f68ccd1e8aeca2a4f25169248439f3bc98ae5e9449acb2324126b8a16e74a36f1177918c198ff91d51af92e2cf0c011ed64d309c05c8bf4bc09f1bacfe
|
7
|
+
data.tar.gz: cedc1bed35dcd00b00ff774c35a3b1156ef631c5f23680a74e4af8a72189bbb093263ecc7cceac5adf35f540e94d1e19edcbfc9ada97204eee1f30a562f34111
|
data/README.md
CHANGED
@@ -1,14 +1,24 @@
|
|
1
|
-
# WP-
|
1
|
+
# WP-Docker
|
2
2
|
|
3
|
-
The easiest to
|
3
|
+
The easiest way to develop WordPress using Docker containers.
|
4
4
|
|
5
5
|
## Install
|
6
6
|
|
7
|
+
```
|
8
|
+
# Using RubyGems
|
9
|
+
$ sudo gem install wp-docker
|
10
|
+
```
|
11
|
+
|
7
12
|
## Usage
|
8
13
|
|
9
|
-
WP-
|
14
|
+
WP-Docker provides a command-line interface to create and manage WordPress development environments using Docker:
|
10
15
|
|
11
16
|
```
|
17
|
+
$ wp-docker
|
18
|
+
|
19
|
+
========================================
|
20
|
+
| WordPress Docker Environment Manager |
|
21
|
+
========================================
|
12
22
|
|
13
23
|
Usage wp-docker <command> [<options>]
|
14
24
|
|
@@ -26,7 +36,6 @@ Commands:
|
|
26
36
|
help Show this help
|
27
37
|
```
|
28
38
|
|
29
|
-
|
30
39
|
## Contributing
|
31
40
|
|
32
41
|
* If you have found a bug or if you have a feature request, please report them at this repository issues section.
|
data/bin/wp-docker
CHANGED
@@ -1,14 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
##
|
4
|
-
# Test command:
|
5
|
-
# docker-compose down; rm -rf src; rm docker-compose.yml; rm Dockerfile-wp; wp-docker
|
6
|
-
##
|
7
|
-
|
8
3
|
require "docker_manager"
|
9
4
|
require "config_manager"
|
10
5
|
require "commands/_loader"
|
11
6
|
|
7
|
+
require "version"
|
8
|
+
|
12
9
|
require 'fileutils'
|
13
10
|
|
14
11
|
require "highline/import"
|
@@ -20,76 +17,61 @@ UI_ENV_SPACES = 50
|
|
20
17
|
UI_WEB_SPACES = 15
|
21
18
|
UI_DB_SPACES = 15
|
22
19
|
|
23
|
-
def main
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
end
|
56
|
-
|
57
|
-
|
58
|
-
def wp_docker_start
|
59
|
-
docker_manager = DockerManager.new
|
60
|
-
docker_manager.start ARGV[1]
|
61
|
-
end
|
62
|
-
|
63
|
-
def wp_docker_stop
|
64
|
-
docker_manager = DockerManager.new
|
65
|
-
docker_manager.stop ARGV[1]
|
66
|
-
end
|
20
|
+
def main
|
21
|
+
name = "WP-Docker #{CONFIG::VERSION}"
|
22
|
+
puts
|
23
|
+
puts "=================================="
|
24
|
+
puts "| " + fill_spaces(name, 30) + " |"
|
25
|
+
puts "=================================="
|
26
|
+
puts
|
27
|
+
|
28
|
+
case ARGV[0]
|
29
|
+
when "create"
|
30
|
+
wp_docker_create
|
31
|
+
when "cli"
|
32
|
+
wp_docker_execute_cli
|
33
|
+
when "open"
|
34
|
+
wp_docker_open_browser
|
35
|
+
when "list"
|
36
|
+
wp_docker_list
|
37
|
+
when "shell"
|
38
|
+
wp_docker_shell
|
39
|
+
when "exec"
|
40
|
+
wp_docker_exec
|
41
|
+
when "start"
|
42
|
+
wp_docker_start
|
43
|
+
when "stop"
|
44
|
+
wp_docker_stop
|
45
|
+
when "remove"
|
46
|
+
wp_docker_remove
|
47
|
+
when "logs"
|
48
|
+
wp_docker_logs
|
49
|
+
else
|
50
|
+
wp_docker_help
|
51
|
+
end
|
67
52
|
|
68
|
-
def wp_docker_remove
|
69
|
-
docker_manager = DockerManager.new
|
70
|
-
docker_manager.remove ARGV[1]
|
71
53
|
end
|
72
54
|
|
73
55
|
def fill_spaces(text, chars)
|
74
|
-
|
75
|
-
|
56
|
+
fills = chars - text.to_s.length
|
57
|
+
return str = text + (" " * fills)
|
76
58
|
end
|
77
59
|
|
78
60
|
def docker_start port
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
61
|
+
puts "Start docker compose"
|
62
|
+
system "docker-compose up --build -d"
|
63
|
+
puts
|
64
|
+
puts "Opening browser: http://localhost:#{port}"
|
65
|
+
print "wait ."
|
66
|
+
sleep 5
|
67
|
+
print "."
|
68
|
+
sleep 5
|
69
|
+
print "."
|
70
|
+
sleep 5
|
71
|
+
print "."
|
72
|
+
sleep 5
|
73
|
+
print "."
|
74
|
+
system "open http://localhost:#{port}"
|
93
75
|
|
94
76
|
end
|
95
77
|
|
data/lib/commands/_loader.rb
CHANGED
data/lib/commands/cli.rb
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
def wp_docker_execute_cli
|
2
2
|
config_manager = ConfigManager.new
|
3
|
+
unless config_manager.is_docker_compose_folder
|
4
|
+
puts "docker-compose.yml does not exists in current folder."
|
5
|
+
puts
|
6
|
+
exit
|
7
|
+
end
|
3
8
|
name = config_manager.get_wp_container_name
|
4
9
|
args = ARGV
|
5
10
|
args.slice!(0)
|
6
11
|
|
7
12
|
command="docker exec -it " + name + " wp --allow-root " + args.join(" ")
|
8
13
|
system(command)
|
14
|
+
puts
|
9
15
|
end
|
data/lib/commands/help.rb
CHANGED
@@ -7,11 +7,11 @@ Commands:
|
|
7
7
|
list Show available environments
|
8
8
|
cli <command> Execute wp-cli in current wp-docker environment
|
9
9
|
open Open browser
|
10
|
-
shell
|
10
|
+
shell [<environment>] Open shell in web container
|
11
11
|
exec <command> Execute command in current wp-docker environment
|
12
|
-
start <environment>
|
13
|
-
stop <environment>
|
14
|
-
remove <environment>
|
12
|
+
start [<environment>] Start wp-docker environment (default: current)
|
13
|
+
stop [<environment>] Stop wp-docker environment (default: current)
|
14
|
+
remove [<environment>] Remove wp-docker environment (default: current)
|
15
15
|
logs [-t] Show apache web logs
|
16
16
|
help Show this help
|
17
17
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
def wp_docker_remove
|
2
|
+
config_manager = ConfigManager.new
|
3
|
+
|
4
|
+
if ARGV.count == 2
|
5
|
+
env = ARGV[1]
|
6
|
+
else
|
7
|
+
env = config_manager.get_wp_environment_name
|
8
|
+
end
|
9
|
+
|
10
|
+
if env != nil
|
11
|
+
docker_manager = DockerManager.new
|
12
|
+
docker_manager.remove env
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
data/lib/commands/shell.rb
CHANGED
@@ -1,7 +1,16 @@
|
|
1
1
|
def wp_docker_shell
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
config_manager = ConfigManager.new
|
3
|
+
|
4
|
+
if ARGV.count == 2
|
5
|
+
container = "wpd_web_" + ARGV[1]
|
6
|
+
else
|
7
|
+
container = config_manager.get_wp_container_name
|
8
|
+
end
|
9
|
+
|
10
|
+
if container != nil
|
11
|
+
command = "docker exec -it " + container + " /bin/bash"
|
12
|
+
puts " - Executing: " + command
|
13
|
+
puts
|
6
14
|
system(command)
|
15
|
+
end
|
7
16
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
def wp_docker_start
|
2
|
+
config_manager = ConfigManager.new
|
3
|
+
|
4
|
+
if ARGV.count == 2
|
5
|
+
env = ARGV[1]
|
6
|
+
else
|
7
|
+
env = config_manager.get_wp_environment_name
|
8
|
+
end
|
9
|
+
|
10
|
+
if env != nil
|
11
|
+
docker_manager = DockerManager.new
|
12
|
+
docker_manager.start env
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
def wp_docker_stop
|
2
|
+
config_manager = ConfigManager.new
|
3
|
+
|
4
|
+
if ARGV.count == 2
|
5
|
+
env = ARGV[1]
|
6
|
+
else
|
7
|
+
env = config_manager.get_wp_environment_name
|
8
|
+
end
|
9
|
+
|
10
|
+
if env != nil
|
11
|
+
docker_manager = DockerManager.new
|
12
|
+
docker_manager.stop env
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
data/lib/config_manager.rb
CHANGED
@@ -7,6 +7,14 @@ class ConfigManager
|
|
7
7
|
return name
|
8
8
|
end
|
9
9
|
|
10
|
+
def get_wp_environment_name
|
11
|
+
file_lines = get_file_lines
|
12
|
+
|
13
|
+
container_line = file_lines.grep(/container_name: wpd_web/)
|
14
|
+
name = container_line[0].scan(/(wpd_[a-z]+)_(.+\d+)/)
|
15
|
+
return name[0][1]
|
16
|
+
end
|
17
|
+
|
10
18
|
def get_wp_container_port
|
11
19
|
file_lines = get_file_lines
|
12
20
|
|
@@ -15,18 +23,28 @@ class ConfigManager
|
|
15
23
|
return ret[0][0]
|
16
24
|
end
|
17
25
|
|
26
|
+
def is_docker_compose_directory
|
27
|
+
|
28
|
+
end
|
29
|
+
|
18
30
|
def get_file_lines
|
19
|
-
|
20
|
-
puts "docker-compose.yml does not exists"
|
31
|
+
unless self.is_docker_compose_folder
|
32
|
+
puts "docker-compose.yml does not exists in current directory. Choose one of the available environments."
|
33
|
+
puts
|
34
|
+
wp_docker_list
|
21
35
|
exit
|
22
36
|
end
|
23
37
|
|
24
38
|
file_lines = File.readlines("docker-compose.yml")
|
25
|
-
|
39
|
+
unless file_lines.grep(/## wp-docker ##/).any?
|
26
40
|
puts "Invalid docker-compose.yml"
|
27
41
|
exit
|
28
42
|
end
|
29
43
|
|
30
|
-
|
31
|
-
end
|
44
|
+
file_lines
|
45
|
+
end
|
46
|
+
|
47
|
+
def is_docker_compose_folder
|
48
|
+
File.file?("docker-compose.yml")
|
49
|
+
end
|
32
50
|
end
|
data/lib/docker_manager.rb
CHANGED
@@ -13,10 +13,19 @@ class DockerManager
|
|
13
13
|
match = Array.new
|
14
14
|
match_envs.each do |env|
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
web_port_match = match_web.select { |item| item[1] == env[0] }
|
17
|
+
db_port_match = match_db.select { |item| item[1] == env[0] }
|
18
18
|
|
19
|
-
|
19
|
+
web_port = "<stopped>"
|
20
|
+
if web_port_match.count != 0
|
21
|
+
web_port = web_port_match[0][0]
|
22
|
+
end
|
23
|
+
|
24
|
+
db_port = "<stopped>"
|
25
|
+
if db_port_match.count != 0
|
26
|
+
db_port = db_port_match[0][0]
|
27
|
+
end
|
28
|
+
match.push({"env" => env[0], "web_port" => web_port, "db_port" => db_port})
|
20
29
|
end
|
21
30
|
|
22
31
|
return match
|
data/lib/version.rb
ADDED
data/wp-docker.gemspec
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
lib = File.expand_path("../lib", __FILE__)
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
3
|
|
4
|
+
require "version"
|
5
|
+
|
4
6
|
Gem::Specification.new do |spec|
|
5
7
|
spec.name = "wp-docker"
|
6
|
-
spec.version =
|
8
|
+
spec.version = CONFIG::VERSION
|
7
9
|
spec.authors = ["Jesus Serrano"]
|
8
10
|
spec.email = ["wp-docker@onepointzero.org"]
|
9
11
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wp-docker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jesus Serrano
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08-
|
11
|
+
date: 2019-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -72,9 +72,13 @@ files:
|
|
72
72
|
- lib/commands/help.rb
|
73
73
|
- lib/commands/list.rb
|
74
74
|
- lib/commands/logs.rb
|
75
|
+
- lib/commands/remove.rb
|
75
76
|
- lib/commands/shell.rb
|
77
|
+
- lib/commands/start.rb
|
78
|
+
- lib/commands/stop.rb
|
76
79
|
- lib/config_manager.rb
|
77
80
|
- lib/docker_manager.rb
|
81
|
+
- lib/version.rb
|
78
82
|
- templates/Dockerfile-wp
|
79
83
|
- templates/docker-compose.yml.tpl
|
80
84
|
- templates/gitignore.tpl
|