wp-docker 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +53 -0
- data/LICENSE +21 -0
- data/README.md +33 -0
- data/bin/wp-docker +97 -0
- data/lib/commands/_loader.rb +8 -0
- data/lib/commands/browser.rb +7 -0
- data/lib/commands/cli.rb +9 -0
- data/lib/commands/create.rb +127 -0
- data/lib/commands/exec.rb +9 -0
- data/lib/commands/help.rb +19 -0
- data/lib/commands/list.rb +11 -0
- data/lib/commands/logs.rb +17 -0
- data/lib/commands/shell.rb +7 -0
- data/lib/config_manager.rb +32 -0
- data/lib/docker_manager.rb +89 -0
- data/templates/Dockerfile-wp +32 -0
- data/templates/docker-compose.yml.tpl +39 -0
- data/templates/gitignore.tpl +25 -0
- data/wp-docker.gemspec +29 -0
- metadata +106 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: eff499c069bd5495eb0643be4f76fa8164c39f56
|
|
4
|
+
data.tar.gz: 794abbd90b8a0a17777463ffcb4ce9b86be26660
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 9405c72167887ffe47f00afddd94844a034e1ac0238d53d925e6a706ff108f3f413597d2cfaa8a9ac9e76acf9a6e3a9dde1def35d5fd04c698a685e3de0b664c
|
|
7
|
+
data.tar.gz: f10e698257e2e5283607afc27d4c0fa99164145257ffa02fe7b0f1da638186d50bf93e73fa6dd812615885102d7cb8a445fd083a72e19ccecd7b904f61260b99
|
data/.gitignore
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
*.gem
|
|
2
|
+
*.rbc
|
|
3
|
+
/.config
|
|
4
|
+
/coverage/
|
|
5
|
+
/InstalledFiles
|
|
6
|
+
/pkg/
|
|
7
|
+
/spec/reports/
|
|
8
|
+
/spec/examples.txt
|
|
9
|
+
/test/tmp/
|
|
10
|
+
/test/version_tmp/
|
|
11
|
+
/tmp/
|
|
12
|
+
|
|
13
|
+
# Used by dotenv library to load environment variables.
|
|
14
|
+
# .env
|
|
15
|
+
|
|
16
|
+
## Specific to RubyMotion:
|
|
17
|
+
.dat*
|
|
18
|
+
.repl_history
|
|
19
|
+
build/
|
|
20
|
+
*.bridgesupport
|
|
21
|
+
build-iPhoneOS/
|
|
22
|
+
build-iPhoneSimulator/
|
|
23
|
+
|
|
24
|
+
## Specific to RubyMotion (use of CocoaPods):
|
|
25
|
+
#
|
|
26
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
|
27
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
|
28
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
|
29
|
+
#
|
|
30
|
+
# vendor/Pods/
|
|
31
|
+
|
|
32
|
+
## Documentation cache and generated files:
|
|
33
|
+
/.yardoc/
|
|
34
|
+
/_yardoc/
|
|
35
|
+
/doc/
|
|
36
|
+
/rdoc/
|
|
37
|
+
|
|
38
|
+
## Environment normalization:
|
|
39
|
+
/.bundle/
|
|
40
|
+
/vendor/bundle
|
|
41
|
+
/lib/bundler/man/
|
|
42
|
+
|
|
43
|
+
# for a library or gem, you might want to ignore these files since the code is
|
|
44
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
45
|
+
# Gemfile.lock
|
|
46
|
+
# .ruby-version
|
|
47
|
+
# .ruby-gemset
|
|
48
|
+
|
|
49
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
|
50
|
+
.rvmrc
|
|
51
|
+
|
|
52
|
+
# IntelliJ
|
|
53
|
+
.idea
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 Jesús Serrano
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# WP-DOCKER
|
|
2
|
+
|
|
3
|
+
The easiest to for WordPress using Docker containers
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
WP-DOCKER provides a command-line interface to create and manage WordPress development environments using Docker:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Usage wp-docker <command> [<options>]
|
|
14
|
+
|
|
15
|
+
Commands:
|
|
16
|
+
create Create new wp-docker environment
|
|
17
|
+
list Show available environments
|
|
18
|
+
cli <command> Execute wp-cli command
|
|
19
|
+
open Open browser
|
|
20
|
+
shell Open shell in web container
|
|
21
|
+
exec <command> Execute command inside container
|
|
22
|
+
start <environment> Start wp-docker environment
|
|
23
|
+
stop <environment> Stop wp-docker environment
|
|
24
|
+
remove <environment> Remove wp-docker environment
|
|
25
|
+
logs [-t] Show apache web logs
|
|
26
|
+
help Show this help
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## Contributing
|
|
31
|
+
|
|
32
|
+
* If you have found a bug or if you have a feature request, please report them at this repository issues section.
|
|
33
|
+
* Pull requests must be made against develop branch.
|
data/bin/wp-docker
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
##
|
|
4
|
+
# Test command:
|
|
5
|
+
# docker-compose down; rm -rf src; rm docker-compose.yml; rm Dockerfile-wp; wp-docker
|
|
6
|
+
##
|
|
7
|
+
|
|
8
|
+
require "docker_manager"
|
|
9
|
+
require "config_manager"
|
|
10
|
+
require "commands/_loader"
|
|
11
|
+
|
|
12
|
+
require 'fileutils'
|
|
13
|
+
|
|
14
|
+
require "highline/import"
|
|
15
|
+
|
|
16
|
+
DEFAULT_WEB_PORT = 8000
|
|
17
|
+
DEFAULT_DB_PORT = 3306
|
|
18
|
+
|
|
19
|
+
UI_ENV_SPACES = 50
|
|
20
|
+
UI_WEB_SPACES = 15
|
|
21
|
+
UI_DB_SPACES = 15
|
|
22
|
+
|
|
23
|
+
def main
|
|
24
|
+
puts
|
|
25
|
+
puts "========================================"
|
|
26
|
+
puts "| WordPress Docker Environment Manager |"
|
|
27
|
+
puts "========================================"
|
|
28
|
+
puts
|
|
29
|
+
|
|
30
|
+
case ARGV[0]
|
|
31
|
+
when "create"
|
|
32
|
+
wp_docker_create
|
|
33
|
+
when "cli"
|
|
34
|
+
wp_docker_execute_cli
|
|
35
|
+
when "open"
|
|
36
|
+
wp_docker_open_browser
|
|
37
|
+
when "list"
|
|
38
|
+
wp_docker_list
|
|
39
|
+
when "shell"
|
|
40
|
+
wp_docker_shell
|
|
41
|
+
when "exec"
|
|
42
|
+
wp_docker_exec
|
|
43
|
+
when "start"
|
|
44
|
+
wp_docker_start
|
|
45
|
+
when "stop"
|
|
46
|
+
wp_docker_stop
|
|
47
|
+
when "remove"
|
|
48
|
+
wp_docker_remove
|
|
49
|
+
when "logs"
|
|
50
|
+
wp_docker_logs
|
|
51
|
+
else
|
|
52
|
+
wp_docker_help
|
|
53
|
+
end
|
|
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
|
|
67
|
+
|
|
68
|
+
def wp_docker_remove
|
|
69
|
+
docker_manager = DockerManager.new
|
|
70
|
+
docker_manager.remove ARGV[1]
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def fill_spaces(text, chars)
|
|
74
|
+
fills = chars - text.to_s.length
|
|
75
|
+
return str = text + (" " * fills)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def docker_start port
|
|
79
|
+
puts "Start docker compose"
|
|
80
|
+
system "docker-compose up --build -d"
|
|
81
|
+
puts
|
|
82
|
+
puts "Opening browser: http://localhost:#{port}"
|
|
83
|
+
print "wait ."
|
|
84
|
+
sleep 5
|
|
85
|
+
print "."
|
|
86
|
+
sleep 5
|
|
87
|
+
print "."
|
|
88
|
+
sleep 5
|
|
89
|
+
print "."
|
|
90
|
+
sleep 5
|
|
91
|
+
print "."
|
|
92
|
+
system "open http://localhost:#{port}"
|
|
93
|
+
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
main
|
|
97
|
+
|
data/lib/commands/cli.rb
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
def wp_docker_create
|
|
2
|
+
check_docker_exist
|
|
3
|
+
docker_manager = DockerManager.new
|
|
4
|
+
id = docker_manager.get_new_wpd_id
|
|
5
|
+
|
|
6
|
+
puts "New Instance Id: #{id}"
|
|
7
|
+
|
|
8
|
+
name = get_proyect_name
|
|
9
|
+
table_prefix = get_table_prefix name
|
|
10
|
+
|
|
11
|
+
web_port = 18000 + id
|
|
12
|
+
db_port = 13300 + id
|
|
13
|
+
|
|
14
|
+
if !auto_ports? web_port, db_port
|
|
15
|
+
web_port = get_port DEFAULT_WEB_PORT, "Enter Web Port"
|
|
16
|
+
db_port = get_port DEFAULT_DB_PORT, "Enter Database Port"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
create_file id, name, table_prefix, web_port, db_port
|
|
20
|
+
dockerfile_wp = File.join(File.dirname(File.realpath(__FILE__)), '../../templates/Dockerfile-wp')
|
|
21
|
+
FileUtils.copy dockerfile_wp, "./"
|
|
22
|
+
|
|
23
|
+
Dir.mkdir './src'
|
|
24
|
+
gitignore = File.join(File.dirname(File.realpath(__FILE__)), '../../templates/gitignore.tpl')
|
|
25
|
+
FileUtils.copy gitignore, "./src/.gitignore"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
start_docker = ""
|
|
29
|
+
while start_docker != "y" && start_docker != "n"
|
|
30
|
+
start_docker = ask "Start? (y/n)"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
if start_docker == "y"
|
|
34
|
+
docker_start web_port
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def auto_ports? default_web_port, default_db_port
|
|
39
|
+
puts "Auto-assigned ports"
|
|
40
|
+
puts "Web: #{default_web_port}"
|
|
41
|
+
puts "Database: #{default_db_port}"
|
|
42
|
+
puts
|
|
43
|
+
|
|
44
|
+
response = ""
|
|
45
|
+
while response != "y" && response != "n"
|
|
46
|
+
response = ask "Use auto-assigned ports? (y/n)"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
return response == "y"
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def get_proyect_name
|
|
53
|
+
default = Dir.pwd.split('/').last.tr('^A-Za-z0-9', '').downcase
|
|
54
|
+
name = ask "Enter container name (#{default}): "
|
|
55
|
+
error_message = 'Invalid name. Only letters and numbers. Must start with letter'
|
|
56
|
+
|
|
57
|
+
if name == ""
|
|
58
|
+
return default
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
if !name.match(/^[[:alpha:]][[:alnum:]]+$/)
|
|
62
|
+
puts error_message
|
|
63
|
+
exit
|
|
64
|
+
end
|
|
65
|
+
return name
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def get_table_prefix name
|
|
69
|
+
prefix = ask "Enter mysql table prefix ('#{name}' for 'wp_#{name}_'): "
|
|
70
|
+
if prefix == ""
|
|
71
|
+
return name
|
|
72
|
+
end
|
|
73
|
+
error_message = 'Invalid name. Only letters and numbers. Must start with letter'
|
|
74
|
+
if !name.match(/^[[:alpha:]][[:alnum:]]+$/)
|
|
75
|
+
puts error_message
|
|
76
|
+
exit
|
|
77
|
+
end
|
|
78
|
+
return prefix
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def get_port default_port, message
|
|
82
|
+
port = ask "#{message} (#{default_port}): "
|
|
83
|
+
if port == ""
|
|
84
|
+
return "#{default_port}"
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
i_port = port.to_i
|
|
88
|
+
if i_port < 8000
|
|
89
|
+
puts "Error: port must be a number higher than 8000: Actually #{port}"
|
|
90
|
+
exit
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
if i_port > 65535
|
|
94
|
+
puts "Error: port must be a number lower than 65535: Actually #{port}"
|
|
95
|
+
exit
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
return port
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def check_docker_exist
|
|
102
|
+
if File.file?("docker-compose.yml")
|
|
103
|
+
puts "Error: docker-compose.yml exists"
|
|
104
|
+
exit
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def create_file id, name, table_prefix, web_port, db_port
|
|
110
|
+
template = File.join(File.dirname(File.realpath(__FILE__)), '../../templates/docker-compose.yml.tpl')
|
|
111
|
+
|
|
112
|
+
file = File.open(template, "r")
|
|
113
|
+
data = file.read
|
|
114
|
+
file.close
|
|
115
|
+
|
|
116
|
+
data = data.gsub! '{id}', id.to_s
|
|
117
|
+
data = data.gsub! '{name}', name
|
|
118
|
+
data = data.gsub! '{web_port}', web_port.to_s
|
|
119
|
+
data = data.gsub! '{db_port}', db_port.to_s
|
|
120
|
+
data = data.gsub! '{table_prefix}', table_prefix
|
|
121
|
+
|
|
122
|
+
out_file = File.new("docker-compose.yml", "w")
|
|
123
|
+
out_file.puts(data)
|
|
124
|
+
out_file.close
|
|
125
|
+
|
|
126
|
+
# puts data
|
|
127
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
def wp_docker_help
|
|
2
|
+
puts """
|
|
3
|
+
Usage wp-docker <command> [<options>]
|
|
4
|
+
|
|
5
|
+
Commands:
|
|
6
|
+
create Create new wp-docker environment
|
|
7
|
+
list Show available environments
|
|
8
|
+
cli <command> Execute wp-cli in current wp-docker environment
|
|
9
|
+
open Open browser
|
|
10
|
+
shell Open shell in web container
|
|
11
|
+
exec <command> Execute command in current wp-docker environment
|
|
12
|
+
start <environment> Start wp-docker environment
|
|
13
|
+
stop <environment> Stop wp-docker environment
|
|
14
|
+
remove <environment> Remove wp-docker environment
|
|
15
|
+
logs [-t] Show apache web logs
|
|
16
|
+
help Show this help
|
|
17
|
+
|
|
18
|
+
"""
|
|
19
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
def wp_docker_list
|
|
2
|
+
docker_manager = DockerManager.new
|
|
3
|
+
|
|
4
|
+
environments = docker_manager.get_environments
|
|
5
|
+
puts fill_spaces("Environment", UI_ENV_SPACES) + fill_spaces("Web Port", UI_WEB_SPACES) + fill_spaces("DB Port", UI_DB_SPACES)
|
|
6
|
+
puts ("-" * (UI_ENV_SPACES + UI_WEB_SPACES + UI_DB_SPACES))
|
|
7
|
+
environments.each do |env|
|
|
8
|
+
puts fill_spaces(env["env"], UI_ENV_SPACES) + fill_spaces(env["web_port"], UI_WEB_SPACES) + fill_spaces(env["db_port"], UI_DB_SPACES)
|
|
9
|
+
end
|
|
10
|
+
puts
|
|
11
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
def wp_docker_logs
|
|
2
|
+
config_manager = ConfigManager.new
|
|
3
|
+
name = config_manager.get_wp_container_name
|
|
4
|
+
|
|
5
|
+
tail_option = ""
|
|
6
|
+
if ARGV.count == 2
|
|
7
|
+
if ARGV[1] == "-t"
|
|
8
|
+
tail_option = " -f"
|
|
9
|
+
else
|
|
10
|
+
wp_docker_help
|
|
11
|
+
exit
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
command="docker logs " + name + tail_option
|
|
16
|
+
system(command)
|
|
17
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
class ConfigManager
|
|
2
|
+
def get_wp_container_name
|
|
3
|
+
file_lines = get_file_lines
|
|
4
|
+
|
|
5
|
+
container_line = file_lines.grep(/container_name: wpd_web/)
|
|
6
|
+
name = container_line[0].scan(/wpd_.+_\d+/)[0]
|
|
7
|
+
return name
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def get_wp_container_port
|
|
11
|
+
file_lines = get_file_lines
|
|
12
|
+
|
|
13
|
+
container_line = file_lines.grep(/:80"/)
|
|
14
|
+
ret = container_line[0].scan(/(\d+):(\d+)"/)
|
|
15
|
+
return ret[0][0]
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def get_file_lines
|
|
19
|
+
if !File.file?("docker-compose.yml")
|
|
20
|
+
puts "docker-compose.yml does not exists"
|
|
21
|
+
exit
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
file_lines = File.readlines("docker-compose.yml")
|
|
25
|
+
if !file_lines.grep(/## wp-docker ##/).any?
|
|
26
|
+
puts "Invalid docker-compose.yml"
|
|
27
|
+
exit
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
return file_lines
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
require 'open3'
|
|
2
|
+
|
|
3
|
+
class DockerManager
|
|
4
|
+
|
|
5
|
+
def get_environments
|
|
6
|
+
command = "docker ps --all"
|
|
7
|
+
stdout, stderr, status = Open3.capture3(command)
|
|
8
|
+
|
|
9
|
+
match_envs = stdout.scan(/wpd_web_(.+_\d+)/)
|
|
10
|
+
match_web = stdout.scan(/.*0\.0\.0\.0:(\d+)->80\/tcp.*wpd_web_(.+_\d+)/)
|
|
11
|
+
match_db = stdout.scan(/.*0\.0\.0\.0:(\d+)->3306\/tcp.*wpd_db_(.+_\d+)/)
|
|
12
|
+
|
|
13
|
+
match = Array.new
|
|
14
|
+
match_envs.each do |env|
|
|
15
|
+
|
|
16
|
+
web_port = match_web.select { |item| item[1] == env[0] }
|
|
17
|
+
db_port = match_db.select { |item| item[1] == env[0] }
|
|
18
|
+
|
|
19
|
+
match.push({"env" => env[0], "web_port" => web_port[0][0], "db_port" => db_port[0][0]})
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
return match
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def get_new_wpd_id
|
|
26
|
+
command = "docker ps --all"
|
|
27
|
+
stdout, stderr, status = Open3.capture3(command)
|
|
28
|
+
|
|
29
|
+
match = stdout.scan(/wpd_.+_(\d+)/)
|
|
30
|
+
current_ids = match.uniq
|
|
31
|
+
|
|
32
|
+
if current_ids.count > 89
|
|
33
|
+
puts "No more available ids"
|
|
34
|
+
exit
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
new_id = nil
|
|
38
|
+
while new_id == nil
|
|
39
|
+
rand_id = rand(10..99)
|
|
40
|
+
if !match.include? rand_id
|
|
41
|
+
new_id = rand_id
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
return new_id
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def start environment
|
|
49
|
+
web = "wpd_web_" + environment
|
|
50
|
+
db = "wpd_db_" + environment
|
|
51
|
+
|
|
52
|
+
puts "Start: " + db
|
|
53
|
+
command="docker start " + db
|
|
54
|
+
system(command)
|
|
55
|
+
|
|
56
|
+
puts "Start: " + web
|
|
57
|
+
command="docker start " + web
|
|
58
|
+
system(command)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def stop environment
|
|
62
|
+
web = "wpd_web_" + environment
|
|
63
|
+
db = "wpd_db_" + environment
|
|
64
|
+
|
|
65
|
+
puts "Stop: " + web
|
|
66
|
+
command="docker stop " + web
|
|
67
|
+
system(command)
|
|
68
|
+
|
|
69
|
+
puts "Stop: " + db
|
|
70
|
+
command="docker stop " + db
|
|
71
|
+
system(command)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def remove environment
|
|
75
|
+
|
|
76
|
+
self.stop environment
|
|
77
|
+
|
|
78
|
+
web = "wpd_web_" + environment
|
|
79
|
+
db = "wpd_db_" + environment
|
|
80
|
+
|
|
81
|
+
puts "Remove: " + web
|
|
82
|
+
command="docker rm " + web
|
|
83
|
+
system(command)
|
|
84
|
+
|
|
85
|
+
puts "Remove: " + db
|
|
86
|
+
command="docker rm " + db
|
|
87
|
+
system(command)
|
|
88
|
+
end
|
|
89
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
FROM wordpress:latest
|
|
2
|
+
|
|
3
|
+
RUN apt-get update
|
|
4
|
+
RUN apt-get install -y less
|
|
5
|
+
RUN apt-get install -y wget
|
|
6
|
+
RUN apt-get install -y gettext
|
|
7
|
+
|
|
8
|
+
WORKDIR /tmp
|
|
9
|
+
|
|
10
|
+
# WP-CLI
|
|
11
|
+
RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
|
|
12
|
+
RUN ls -l
|
|
13
|
+
RUN chmod +x wp-cli.phar
|
|
14
|
+
RUN mv wp-cli.phar /usr/local/bin/wp
|
|
15
|
+
|
|
16
|
+
# COMPOSER
|
|
17
|
+
RUN EXPECTED_SIGNATURE="$(wget -q -O - https://composer.github.io/installer.sig)"
|
|
18
|
+
RUN echo EXPECTED_SIGNATURE
|
|
19
|
+
RUN echo $EXPECTED_SIGNATURE
|
|
20
|
+
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
|
|
21
|
+
RUN ACTUAL_SIGNATURE="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
|
|
22
|
+
RUN if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]; then echo "Installer corrupt"; rm composer-setup.php; else echo "Installer verified"; fi
|
|
23
|
+
RUN php composer-setup.php
|
|
24
|
+
RUN php -r "unlink('composer-setup.php');"
|
|
25
|
+
RUN mv composer.phar /usr/local/bin/composer
|
|
26
|
+
|
|
27
|
+
#PHPUNIT
|
|
28
|
+
RUN wget https://phar.phpunit.de/phpunit-8.2.phar
|
|
29
|
+
RUN mv phpunit-8.2.phar /usr/local/bin/phpunit
|
|
30
|
+
RUN chmod +x /usr/local/bin/phpunit
|
|
31
|
+
|
|
32
|
+
WORKDIR /var/www/html
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
## wp-docker ##
|
|
2
|
+
## id: {id} ##
|
|
3
|
+
|
|
4
|
+
version: '3.3'
|
|
5
|
+
|
|
6
|
+
services:
|
|
7
|
+
db:
|
|
8
|
+
container_name: wpd_db_{name}_{id}
|
|
9
|
+
image: mysql:5.7
|
|
10
|
+
volumes:
|
|
11
|
+
- db_{id}_data:/var/lib/mysql
|
|
12
|
+
restart: always
|
|
13
|
+
ports:
|
|
14
|
+
- "{db_port}:3306"
|
|
15
|
+
environment:
|
|
16
|
+
MYSQL_ROOT_PASSWORD: somewordpress
|
|
17
|
+
MYSQL_DATABASE: wordpress
|
|
18
|
+
MYSQL_USER: wordpress
|
|
19
|
+
MYSQL_PASSWORD: wordpress
|
|
20
|
+
|
|
21
|
+
wordpress:
|
|
22
|
+
container_name: wpd_web_{name}_{id}
|
|
23
|
+
build:
|
|
24
|
+
context: .
|
|
25
|
+
dockerfile: Dockerfile-wp
|
|
26
|
+
depends_on:
|
|
27
|
+
- db
|
|
28
|
+
volumes:
|
|
29
|
+
- ./src/:/var/www/html
|
|
30
|
+
ports:
|
|
31
|
+
- "{web_port}:80"
|
|
32
|
+
restart: always
|
|
33
|
+
environment:
|
|
34
|
+
WORDPRESS_DB_HOST: db:3306
|
|
35
|
+
WORDPRESS_DB_USER: wordpress
|
|
36
|
+
WORDPRESS_DB_PASSWORD: wordpress
|
|
37
|
+
WORDPRESS_TABLE_PREFIX: wp_{table_prefix}_
|
|
38
|
+
volumes:
|
|
39
|
+
db_{id}_data:
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# ignore everything in the root except the "wp-content" directory.
|
|
2
|
+
!wp-content/
|
|
3
|
+
|
|
4
|
+
# ignore everything in the "wp-content" directory, except:
|
|
5
|
+
# "mu-plugins", "plugins", "themes" directory
|
|
6
|
+
wp-content/*
|
|
7
|
+
!wp-content/mu-plugins/
|
|
8
|
+
!wp-content/plugins/
|
|
9
|
+
!wp-content/themes/
|
|
10
|
+
|
|
11
|
+
# ignore these plugins
|
|
12
|
+
wp-content/plugins/hello.php
|
|
13
|
+
|
|
14
|
+
# ignore specific themes
|
|
15
|
+
wp-content/themes/twenty*/
|
|
16
|
+
|
|
17
|
+
# ignore node dependency directories
|
|
18
|
+
node_modules/
|
|
19
|
+
|
|
20
|
+
# ignore log files and databases
|
|
21
|
+
*.log
|
|
22
|
+
*.sql
|
|
23
|
+
*.sqlite
|
|
24
|
+
|
|
25
|
+
.idea/*
|
data/wp-docker.gemspec
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
|
+
|
|
4
|
+
Gem::Specification.new do |spec|
|
|
5
|
+
spec.name = "wp-docker"
|
|
6
|
+
spec.version = "0.0.1"
|
|
7
|
+
spec.authors = ["Jesus Serrano"]
|
|
8
|
+
spec.email = ["wp-docker@onepointzero.org"]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
"The easiest way to automate beta deployments and releases for your iOS and Android apps"
|
|
12
|
+
spec.summary = "The easiest to for WordPress using Docker containers"
|
|
13
|
+
spec.homepage = "https://github.com/Tyrbok/wp-docker"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
19
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
21
|
+
end
|
|
22
|
+
spec.bindir = "bin"
|
|
23
|
+
spec.executables = "wp-docker"
|
|
24
|
+
spec.require_paths = ["lib"]
|
|
25
|
+
|
|
26
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
28
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
29
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: wp-docker
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Jesus Serrano
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2019-08-21 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '2.0'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '2.0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.0'
|
|
55
|
+
description:
|
|
56
|
+
email:
|
|
57
|
+
- wp-docker@onepointzero.org
|
|
58
|
+
executables:
|
|
59
|
+
- wp-docker
|
|
60
|
+
extensions: []
|
|
61
|
+
extra_rdoc_files: []
|
|
62
|
+
files:
|
|
63
|
+
- ".gitignore"
|
|
64
|
+
- LICENSE
|
|
65
|
+
- README.md
|
|
66
|
+
- bin/wp-docker
|
|
67
|
+
- lib/commands/_loader.rb
|
|
68
|
+
- lib/commands/browser.rb
|
|
69
|
+
- lib/commands/cli.rb
|
|
70
|
+
- lib/commands/create.rb
|
|
71
|
+
- lib/commands/exec.rb
|
|
72
|
+
- lib/commands/help.rb
|
|
73
|
+
- lib/commands/list.rb
|
|
74
|
+
- lib/commands/logs.rb
|
|
75
|
+
- lib/commands/shell.rb
|
|
76
|
+
- lib/config_manager.rb
|
|
77
|
+
- lib/docker_manager.rb
|
|
78
|
+
- templates/Dockerfile-wp
|
|
79
|
+
- templates/docker-compose.yml.tpl
|
|
80
|
+
- templates/gitignore.tpl
|
|
81
|
+
- wp-docker.gemspec
|
|
82
|
+
homepage: https://github.com/Tyrbok/wp-docker
|
|
83
|
+
licenses:
|
|
84
|
+
- MIT
|
|
85
|
+
metadata: {}
|
|
86
|
+
post_install_message:
|
|
87
|
+
rdoc_options: []
|
|
88
|
+
require_paths:
|
|
89
|
+
- lib
|
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
91
|
+
requirements:
|
|
92
|
+
- - ">="
|
|
93
|
+
- !ruby/object:Gem::Version
|
|
94
|
+
version: '0'
|
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
|
+
requirements:
|
|
97
|
+
- - ">="
|
|
98
|
+
- !ruby/object:Gem::Version
|
|
99
|
+
version: '0'
|
|
100
|
+
requirements: []
|
|
101
|
+
rubyforge_project:
|
|
102
|
+
rubygems_version: 2.6.12
|
|
103
|
+
signing_key:
|
|
104
|
+
specification_version: 4
|
|
105
|
+
summary: The easiest to for WordPress using Docker containers
|
|
106
|
+
test_files: []
|