grok_cli 1.2.1 → 1.3.0
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 +4 -4
- data/lib/grok_cli/docker/wordpress/down.rb +31 -0
- data/lib/grok_cli/docker/wordpress/import_database.rb +51 -0
- data/lib/grok_cli/docker/wordpress/init.rb +73 -0
- data/lib/grok_cli/docker/wordpress/up.rb +31 -0
- data/lib/grok_cli/docker.rb +1 -0
- data/lib/grok_cli/version.rb +1 -1
- data/lib/templates/wordpress/.env.erb +10 -0
- data/lib/templates/wordpress/.grok-cli.yml.erb +2 -0
- data/lib/templates/wordpress/docker-compose.yml +26 -0
- data/lib/templates/wordpress/wp-config.php.erb +31 -0
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc5b66177d79ae564395449f8c19bf677a6ef187
|
4
|
+
data.tar.gz: d7e1ac3ebc1442619971cba903b6eaa886b11cb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33faf848f535d3007484b24b16b47cccce55444b2f6d774671decdbfee433968597d827f98e439f0b828d05f12911596e6e45cb14f519163ab0090866d3c83b1
|
7
|
+
data.tar.gz: 943bacbc9e7c238795e05cb3ac22c62a62c9935f7e5a99f01113a01e2bcaa84a0d8d4db9be7fdbfc68d4440c54118107b93d9328e8abaaf485475cdcdd26ee38
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module GrokCLI::Docker::WordPress
|
2
|
+
class Down
|
3
|
+
def initialize(config = GrokCLI::Docker::Configuration.new)
|
4
|
+
@config = config
|
5
|
+
end
|
6
|
+
|
7
|
+
def execute
|
8
|
+
system <<~CMD
|
9
|
+
|
10
|
+
docker-machine create #{@config.machine_name} --driver virtualbox
|
11
|
+
|
12
|
+
eval "$(docker-machine env #{@config.machine_name})"
|
13
|
+
|
14
|
+
docker-compose down
|
15
|
+
CMD
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
module GrokCLI
|
21
|
+
command 'docker:wordpress' do |c|
|
22
|
+
|
23
|
+
c.desc 'Stop and remove all docker containers'
|
24
|
+
|
25
|
+
c.command 'setup' do |c|
|
26
|
+
c.action do
|
27
|
+
GrokCLI::Docker::WordPress::Down.new.execute
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module GrokCLI::Docker::WordPress
|
2
|
+
class ImportDatabase
|
3
|
+
def initialize(config = GrokCLI::Docker::Configuration.new)
|
4
|
+
@config = config
|
5
|
+
end
|
6
|
+
|
7
|
+
def execute(sql_dump)
|
8
|
+
system <<~CMD
|
9
|
+
|
10
|
+
docker-machine create #{@config.machine_name} --driver virtualbox
|
11
|
+
|
12
|
+
eval "$(docker-machine env #{@config.machine_name})"
|
13
|
+
|
14
|
+
docker-compose run --rm mysql mysql -h mysql -u#{username} -p#{password} #{database} < #{sql_dump}
|
15
|
+
CMD
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def username
|
21
|
+
config.fetch('MYSQL_USER')
|
22
|
+
end
|
23
|
+
|
24
|
+
def password
|
25
|
+
config.fetch('MYSQL_PASSWORD')
|
26
|
+
end
|
27
|
+
|
28
|
+
def database
|
29
|
+
config.fetch('MYSQL_DATABASE')
|
30
|
+
end
|
31
|
+
|
32
|
+
def config
|
33
|
+
Hash[*File.read('.env').split(/[=|\n]+/)]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
module GrokCLI
|
39
|
+
command 'docker:wordpress' do |c|
|
40
|
+
|
41
|
+
c.desc 'Import a database into the MySQL instance'
|
42
|
+
|
43
|
+
c.arg :sql_dump
|
44
|
+
|
45
|
+
c.command 'import_database' do |c|
|
46
|
+
c.action do |global_options, options, arguments|
|
47
|
+
GrokCLI::Docker::WordPress::ImportDatabase.new.execute(arguments[0])
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'erb'
|
2
|
+
|
3
|
+
module GrokCLI::Docker::WordPress
|
4
|
+
class Init
|
5
|
+
def execute(hostname, machine_name)
|
6
|
+
FileUtils.cp(template_path('docker-compose.yml'), '.')
|
7
|
+
puts "Created docker-compose.yml"
|
8
|
+
|
9
|
+
File.open('.grok-cli.yml', 'w') do |file|
|
10
|
+
file.write(render_grok_cli(hostname, machine_name))
|
11
|
+
puts "Created .grok-cli.yml"
|
12
|
+
end
|
13
|
+
|
14
|
+
File.open('.env', 'w') do |file|
|
15
|
+
file.write(render_env)
|
16
|
+
puts "Created .env"
|
17
|
+
end
|
18
|
+
|
19
|
+
File.open('wp-config.php', 'w') do |file|
|
20
|
+
file.write(render_wp_config)
|
21
|
+
puts "Created wp-config.php"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def template_path(path)
|
28
|
+
Pathname.new(File.dirname(__FILE__)).join('./../../../templates/wordpress').join(path)
|
29
|
+
end
|
30
|
+
|
31
|
+
def render_grok_cli(hostname, machine_name)
|
32
|
+
@hostname = hostname
|
33
|
+
@machine_name = machine_name
|
34
|
+
|
35
|
+
template = File.read(template_path('.grok-cli.yml.erb'))
|
36
|
+
|
37
|
+
ERB.new(template).result(binding)
|
38
|
+
end
|
39
|
+
|
40
|
+
def render_env
|
41
|
+
@password = SecureRandom.hex
|
42
|
+
|
43
|
+
template = File.read(template_path('.env.erb'))
|
44
|
+
|
45
|
+
ERB.new(template).result(binding)
|
46
|
+
end
|
47
|
+
|
48
|
+
def render_wp_config
|
49
|
+
@password = SecureRandom.hex
|
50
|
+
|
51
|
+
template = File.read(template_path('wp-config.php.erb'))
|
52
|
+
|
53
|
+
ERB.new(template).result(binding)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
module GrokCLI
|
60
|
+
command 'docker:wordpress' do |c|
|
61
|
+
|
62
|
+
c.desc 'Copy configuration files to a WordPress project'
|
63
|
+
|
64
|
+
c.arg :docker_machine_name
|
65
|
+
c.arg :hostname
|
66
|
+
|
67
|
+
c.command 'init' do |c|
|
68
|
+
c.action do |global_options, options, arguments|
|
69
|
+
GrokCLI::Docker::WordPress::Init.new.execute(arguments[0], arguments[1])
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module GrokCLI::Docker::WordPress
|
2
|
+
class Up
|
3
|
+
def initialize(config = GrokCLI::Docker::Configuration.new)
|
4
|
+
@config = config
|
5
|
+
end
|
6
|
+
|
7
|
+
def execute
|
8
|
+
system <<~CMD
|
9
|
+
|
10
|
+
docker-machine create #{@config.machine_name} --driver virtualbox
|
11
|
+
|
12
|
+
eval "$(docker-machine env #{@config.machine_name})"
|
13
|
+
|
14
|
+
docker-compose up
|
15
|
+
CMD
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
module GrokCLI
|
21
|
+
command 'docker:wordpress' do |c|
|
22
|
+
|
23
|
+
c.desc 'Start the container services'
|
24
|
+
|
25
|
+
c.command 'start' do |c|
|
26
|
+
c.action do
|
27
|
+
GrokCLI::Docker::WordPress::Up.new.execute
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/grok_cli/docker.rb
CHANGED
data/lib/grok_cli/version.rb
CHANGED
@@ -0,0 +1,10 @@
|
|
1
|
+
MYSQL_DATABASE=wordpress
|
2
|
+
MYSQL_PASSWORD=<%= @password %>
|
3
|
+
MYSQL_ROOT_PASSWORD=password
|
4
|
+
MYSQL_USER=wordpress
|
5
|
+
PMA_HOST=mysql
|
6
|
+
PMA_PASSWORD=<%= @password %>
|
7
|
+
PMA_USER=wordpress
|
8
|
+
WORDPRESS_DB_DATABASE=wordpress
|
9
|
+
WORDPRESS_DB_PASSWORD=<%= @password %>
|
10
|
+
WORDPRESS_DB_USER=wordpress
|
@@ -0,0 +1,26 @@
|
|
1
|
+
version: '2'
|
2
|
+
|
3
|
+
services:
|
4
|
+
web:
|
5
|
+
image: wordpress
|
6
|
+
depends_on:
|
7
|
+
- mysql
|
8
|
+
- phpmyadmin
|
9
|
+
ports:
|
10
|
+
- "80:80"
|
11
|
+
volumes:
|
12
|
+
- .:/var/www/html
|
13
|
+
env_file:
|
14
|
+
.env
|
15
|
+
phpmyadmin:
|
16
|
+
image: phpmyadmin/phpmyadmin
|
17
|
+
ports:
|
18
|
+
- "8080:80"
|
19
|
+
depends_on:
|
20
|
+
- mysql
|
21
|
+
env_file:
|
22
|
+
.env
|
23
|
+
mysql:
|
24
|
+
image: mariadb
|
25
|
+
env_file:
|
26
|
+
.env
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
define('DB_NAME', getenv('MYSQL_DATABASE'));
|
4
|
+
define('DB_USER', getenv('MYSQL_USER'));
|
5
|
+
define('DB_PASSWORD', getenv('MYSQL_PASSWORD'));
|
6
|
+
define('DB_HOST', 'mysql');
|
7
|
+
define('DB_CHARSET', 'utf8');
|
8
|
+
define('DB_COLLATE', '');
|
9
|
+
|
10
|
+
define('AUTH_KEY', '<%= SecureRandom.hex %>');
|
11
|
+
define('SECURE_AUTH_KEY', '<%= SecureRandom.hex %>');
|
12
|
+
define('LOGGED_IN_KEY', '<%= SecureRandom.hex %>');
|
13
|
+
define('NONCE_KEY', '<%= SecureRandom.hex %>');
|
14
|
+
define('AUTH_SALT', '<%= SecureRandom.hex %>');
|
15
|
+
define('SECURE_AUTH_SALT', '<%= SecureRandom.hex %>');
|
16
|
+
define('LOGGED_IN_SALT', '<%= SecureRandom.hex %>');
|
17
|
+
define('NONCE_SALT', '<%= SecureRandom.hex %>');
|
18
|
+
|
19
|
+
$table_prefix = 'wp_';
|
20
|
+
|
21
|
+
define('WP_DEBUG', false);
|
22
|
+
|
23
|
+
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
|
24
|
+
$_SERVER['HTTPS'] = 'on';
|
25
|
+
}
|
26
|
+
|
27
|
+
if ( !defined('ABSPATH') ) {
|
28
|
+
define('ABSPATH', dirname(__FILE__) . '/');
|
29
|
+
}
|
30
|
+
|
31
|
+
require_once(ABSPATH . 'wp-settings.php');
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grok_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Freeman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -123,9 +123,17 @@ files:
|
|
123
123
|
- lib/grok_cli/docker/start.rb
|
124
124
|
- lib/grok_cli/docker/stop.rb
|
125
125
|
- lib/grok_cli/docker/update_etc_hosts.rb
|
126
|
+
- lib/grok_cli/docker/wordpress/down.rb
|
127
|
+
- lib/grok_cli/docker/wordpress/import_database.rb
|
128
|
+
- lib/grok_cli/docker/wordpress/init.rb
|
129
|
+
- lib/grok_cli/docker/wordpress/up.rb
|
126
130
|
- lib/grok_cli/git.rb
|
127
131
|
- lib/grok_cli/git/log.rb
|
128
132
|
- lib/grok_cli/version.rb
|
133
|
+
- lib/templates/wordpress/.env.erb
|
134
|
+
- lib/templates/wordpress/.grok-cli.yml.erb
|
135
|
+
- lib/templates/wordpress/docker-compose.yml
|
136
|
+
- lib/templates/wordpress/wp-config.php.erb
|
129
137
|
homepage: https://github.com/GrokInteractive/grok_cli
|
130
138
|
licenses:
|
131
139
|
- MIT
|