wslave 0.0.15 → 0.2.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 +5 -5
- data/base/.gitignore +5 -0
- data/base/Rakefile +22 -6
- data/base/config/deploy-tools/gen-nginx-vhost.rb +11 -0
- data/base/config/deploy-tools/nginx.vhost.erb +51 -0
- data/base/config/deploy.rb +1 -1
- data/base/config/deploy/production.rb +135 -7
- data/base/config/deploy/staging.rb +135 -8
- data/base/docker-compose.yml +14 -9
- data/base/{Dockerfile → docker/apache/Dockerfile} +2 -4
- data/base/docker/nginx/Dockerfile +24 -0
- data/base/docker/nginx/nginx.vhost +48 -0
- data/base/docker/nginx/supervisord.conf +23 -0
- data/base/public/.htaccess +11 -0
- data/bin/wslave +76 -22
- data/lib/wslave_docker.rb +34 -3
- data/lib/wslave_new.rb +48 -9
- data/lib/wslave_sage.rb +70 -3
- data/lib/wslave_tools.rb +0 -1
- data/lib/wslave_update.rb +2 -2
- data/templates/config/definitions.yml +6 -1
- data/wslave.gemspec +9 -6
- metadata +78 -9
data/base/docker-compose.yml
CHANGED
@@ -1,28 +1,33 @@
|
|
1
|
-
version: '
|
1
|
+
version: '3'
|
2
2
|
|
3
3
|
services:
|
4
4
|
db:
|
5
|
-
image:
|
5
|
+
image: mariadb:10.5.4-focal
|
6
6
|
volumes:
|
7
7
|
- "./db/dev:/db"
|
8
8
|
- "./db/active:/docker-entrypoint-initdb.d"
|
9
|
-
restart: always
|
10
9
|
environment:
|
11
10
|
MYSQL_ROOT_PASSWORD: wordpress
|
12
11
|
MYSQL_DATABASE: wordpress
|
13
|
-
|
14
12
|
web:
|
15
13
|
depends_on:
|
16
14
|
- db
|
17
|
-
build:
|
15
|
+
build: ./docker/apache/
|
18
16
|
volumes:
|
19
17
|
- "./public:/var/www/html"
|
20
18
|
ports:
|
21
19
|
- "8000:80"
|
22
|
-
restart: always
|
23
20
|
environment:
|
24
21
|
WORDPRESS_DB_HOST: db:3306
|
25
22
|
WORDPRESS_DB_PASSWORD: wordpress
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
nweb:
|
24
|
+
depends_on:
|
25
|
+
- db
|
26
|
+
build: ./docker/nginx/
|
27
|
+
volumes:
|
28
|
+
- "./public:/var/www/html"
|
29
|
+
ports:
|
30
|
+
- "8001:80"
|
31
|
+
environment:
|
32
|
+
WORDPRESS_DB_HOST: db:3306
|
33
|
+
WORDPRESS_DB_PASSWORD: wordpress
|
@@ -1,13 +1,11 @@
|
|
1
|
-
FROM php:
|
1
|
+
FROM php:7.4-apache
|
2
2
|
|
3
3
|
RUN a2enmod rewrite
|
4
4
|
RUN service apache2 restart
|
5
5
|
RUN apt-get update \
|
6
|
-
&& apt-get install -y
|
7
|
-
&& docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \
|
6
|
+
&& apt-get install -y libpng-dev libjpeg-dev mariadb-client mariadb-common libonig-dev \
|
8
7
|
&& docker-php-ext-install gd \
|
9
8
|
&& docker-php-ext-install mbstring \
|
10
|
-
&& docker-php-ext-install mysql \
|
11
9
|
&& docker-php-ext-install mysqli \
|
12
10
|
&& docker-php-ext-install pdo \
|
13
11
|
&& docker-php-ext-install pdo_mysql \
|
@@ -0,0 +1,24 @@
|
|
1
|
+
FROM ubuntu:20.04
|
2
|
+
|
3
|
+
COPY nginx.vhost /etc/nginx/sites-enabled/default
|
4
|
+
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
5
|
+
|
6
|
+
RUN apt-get update
|
7
|
+
RUN DEBIAN_FRONTEND="noninteractive" apt-get -y install tzdata
|
8
|
+
RUN apt-get install -y nginx php-fpm php-mysql \
|
9
|
+
libpng-dev libjpeg-dev \
|
10
|
+
mariadb-client mariadb-common \
|
11
|
+
supervisor curl
|
12
|
+
RUN apt-get clean
|
13
|
+
RUN adduser www-data root
|
14
|
+
RUN mkdir /db \
|
15
|
+
&& chmod 777 /db
|
16
|
+
|
17
|
+
RUN ln -sf /dev/stdout /var/log/nginx/access.log \
|
18
|
+
&& ln -sf /dev/stderr /var/log/nginx/error.log
|
19
|
+
|
20
|
+
EXPOSE 80
|
21
|
+
|
22
|
+
STOPSIGNAL SIGTERM
|
23
|
+
|
24
|
+
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
|
@@ -0,0 +1,48 @@
|
|
1
|
+
server {
|
2
|
+
listen 80;
|
3
|
+
listen [::]:80;
|
4
|
+
|
5
|
+
server_name testing;
|
6
|
+
|
7
|
+
root /var/www/html;
|
8
|
+
|
9
|
+
index index.php;
|
10
|
+
|
11
|
+
location / {
|
12
|
+
rewrite ^/(wp-(admin|includes).*) /wordpress/$1 last;
|
13
|
+
|
14
|
+
rewrite ^/$ /wordpress/index.php last;
|
15
|
+
|
16
|
+
location ~ \.php {
|
17
|
+
if ($request_uri !~* "/wp-config.php") {
|
18
|
+
rewrite ^/wp-(.*)\.php$ /wordpress/wp-$1.php last;
|
19
|
+
}
|
20
|
+
rewrite ^/index\.php$ /wordpress/index.php last;
|
21
|
+
rewrite ^/wp-login\.php$ /hello.php last;
|
22
|
+
include snippets/fastcgi-php.conf;
|
23
|
+
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
location ~ /\. {
|
28
|
+
deny all;
|
29
|
+
access_log off;
|
30
|
+
log_not_found off;
|
31
|
+
}
|
32
|
+
|
33
|
+
location ~- \.(blade\.php)$ {
|
34
|
+
deny all;
|
35
|
+
}
|
36
|
+
|
37
|
+
location ~- composer\.(json|lock)$ {
|
38
|
+
deny all;
|
39
|
+
}
|
40
|
+
|
41
|
+
location ~- package(-lock)?\.json$ {
|
42
|
+
deny all;
|
43
|
+
}
|
44
|
+
|
45
|
+
location ~- yarn\.lock$ {
|
46
|
+
deny all;
|
47
|
+
}
|
48
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
[supervisord]
|
2
|
+
nodaemon=true
|
3
|
+
logfile=/dev/null
|
4
|
+
logfile_maxbytes=0
|
5
|
+
pidfile=/run/supervisord.pid
|
6
|
+
|
7
|
+
[program:php-fpm]
|
8
|
+
command=php-fpm7.2 -F
|
9
|
+
stdout_logfile=/dev/stdout
|
10
|
+
stdout_logfile_maxbytes=0
|
11
|
+
stderr_logfile=/dev/stderr
|
12
|
+
stderr_logfile_maxbytes=0
|
13
|
+
autorestart=false
|
14
|
+
startretries=0
|
15
|
+
|
16
|
+
[program:nginx]
|
17
|
+
command=nginx -g 'daemon off;'
|
18
|
+
stdout_logfile=/dev/stdout
|
19
|
+
stdout_logfile_maxbytes=0
|
20
|
+
stderr_logfile=/dev/stderr
|
21
|
+
stderr_logfile_maxbytes=0
|
22
|
+
autorestart=false
|
23
|
+
startretries=0
|
data/base/public/.htaccess
CHANGED
@@ -14,3 +14,14 @@
|
|
14
14
|
# BEGIN WordPress
|
15
15
|
# END WordPress
|
16
16
|
</IfModule>
|
17
|
+
<FilesMatch ".+\.(blade\.php)$">
|
18
|
+
<IfModule mod_authz_core.c>
|
19
|
+
# Apache 2.4
|
20
|
+
Require all denied
|
21
|
+
</IfModule>
|
22
|
+
<IfModule !mod_authz_core.c>
|
23
|
+
# Apache 2.2
|
24
|
+
Order deny,allow
|
25
|
+
Deny from all
|
26
|
+
</IfModule>
|
27
|
+
</FilesMatch>
|
data/bin/wslave
CHANGED
@@ -4,13 +4,20 @@ require 'fileutils'
|
|
4
4
|
|
5
5
|
class WSlaveCLI < Thor
|
6
6
|
|
7
|
+
def self.exit_on_failure?
|
8
|
+
true
|
9
|
+
end
|
10
|
+
|
7
11
|
desc 'new [APP_PATH]', "Generate a new app at APP_PATH"
|
8
12
|
long_desc "Creates a new application in the current directory or in the specificed path."
|
9
|
-
|
13
|
+
option :version, default: '',
|
14
|
+
desc: 'Specify the version, EG: "--version 5.3". To specify edge/development master use "--version edge".'
|
15
|
+
option :wspath, default: '',
|
16
|
+
desc: 'specify the path to the wslave distribution, EG: "--wspath ../wslave".'
|
10
17
|
def new(path = './')
|
11
18
|
require_relative '../lib/wslave_new'
|
12
19
|
real_path = File.expand_path(path)
|
13
|
-
WSlaveNew.new(real_path, options['version'])
|
20
|
+
WSlaveNew.new(real_path, options['version'], options['wspath'])
|
14
21
|
end
|
15
22
|
|
16
23
|
desc 'update', "Updates toolchain"
|
@@ -20,35 +27,55 @@ class WSlaveCLI < Thor
|
|
20
27
|
WSlaveUpdate.new()
|
21
28
|
end
|
22
29
|
|
23
|
-
desc '
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
30
|
+
desc 'server COMMAND [options]', "Control the development server container. " \
|
31
|
+
"Commands include: start stop log console"
|
32
|
+
long_desc <<-LONGDESC
|
33
|
+
Start, stop, view logs for, or connect to a console in a development server container.
|
34
|
+
\x5
|
35
|
+
\x5 COMMANDs:
|
36
|
+
\x5 start Starts a development server container. *Will restart the container if already running.
|
37
|
+
\x5 stop Stops a running development container.
|
38
|
+
\x5 log Connects to the container logs and follows them.
|
39
|
+
\x5 console Gives a terminal connection to a bash console on the web container.
|
40
|
+
\x5\x5
|
41
|
+
Examples:
|
42
|
+
\x5 Start dev container servers
|
43
|
+
\x5 > wslave server start
|
44
|
+
\x5 Start or restart dev container servers after resetting all volumes (reinit)
|
45
|
+
\x5 > wslave server start -v
|
46
|
+
\x5 Force stop all dev container servers
|
47
|
+
\x5 > wslave server stop -f
|
48
|
+
\x5 Show logs
|
49
|
+
\x5 > wslave server logs
|
50
|
+
|
51
|
+
|
52
|
+
\x5 * If you do not specify a COMMAND the default is to start a server.
|
53
|
+
\x5 * If a server is alredy running this command will restart the server.
|
54
|
+
LONGDESC
|
55
|
+
method_option :v, type: :boolean, default: false, description: 'remove volume data'
|
56
|
+
method_option :f, type: :boolean, default: false, description: 'force close other servers first'
|
57
|
+
def server(command = 'start')
|
58
|
+
puts 'Starting server...'
|
59
|
+
require_relative '../lib/wslave_docker'
|
60
|
+
WSlaveDocker.new().server(command.to_sym, options['f'], options['v'])
|
35
61
|
end
|
36
62
|
|
37
|
-
desc '
|
38
|
-
method_option :
|
39
|
-
|
63
|
+
desc 'start [options]', "Starts the development server (short for 'server start')"
|
64
|
+
method_option :v, type: :boolean, default: false, description: 'remove volume data'
|
65
|
+
method_option :f, type: :boolean, default: false, description: 'force close other servers first'
|
66
|
+
def start()
|
40
67
|
puts 'Starting server...'
|
41
68
|
require_relative '../lib/wslave_docker'
|
42
|
-
WSlaveDocker.new().server(options['f'])
|
69
|
+
WSlaveDocker.new().server(:start, options['f'], options['v'])
|
43
70
|
end
|
44
71
|
|
45
|
-
desc 'stop [options]', "Stops the development server"
|
46
|
-
method_option :v, default: false, description: 'remove volume data'
|
47
|
-
method_option :f, default: false, description: 'force close other servers first'
|
72
|
+
desc 'stop [options]', "Stops the development server (short for 'server stop')"
|
73
|
+
method_option :v, type: :boolean, default: false, description: 'remove volume data'
|
74
|
+
method_option :f, type: :boolean, default: false, description: 'force close other servers first'
|
48
75
|
def stop()
|
49
76
|
puts 'Stopping server...'
|
50
77
|
require_relative '../lib/wslave_docker'
|
51
|
-
WSlaveDocker.new().stop
|
78
|
+
WSlaveDocker.new().server(:stop, options['f'], options['v'])
|
52
79
|
end
|
53
80
|
|
54
81
|
desc 'sync', "Synchronizes submodules and file permissions"
|
@@ -64,6 +91,33 @@ class WSlaveCLI < Thor
|
|
64
91
|
spec = Gem::Specification::load("#{__dir__}/../wslave.gemspec")
|
65
92
|
puts spec.version
|
66
93
|
end
|
94
|
+
|
95
|
+
desc 'sage COMMAND', "Generate a theme with NAME"
|
96
|
+
long_desc "Generates a theme base with sage in the themes directory with the given " \
|
97
|
+
"NAME. A random name will be generated if you do not specify a NAME."
|
98
|
+
def sage(command = '', arg = '')
|
99
|
+
case command
|
100
|
+
when 'create'
|
101
|
+
require_relative '../lib/wslave_sage'
|
102
|
+
puts "Generating sage theme base for #{arg}"
|
103
|
+
WSlaveSage.new().create(arg)
|
104
|
+
when 'update'
|
105
|
+
require_relative '../lib/wslave_sage'
|
106
|
+
WSlaveSage.new().update()
|
107
|
+
when 'dev'
|
108
|
+
require_relative '../lib/wslave_sage'
|
109
|
+
WSlaveSage.new().dev()
|
110
|
+
when 'build'
|
111
|
+
require_relative '../lib/wslave_sage'
|
112
|
+
WSlaveSage.new().build()
|
113
|
+
when 'production'
|
114
|
+
require_relative '../lib/wslave_sage'
|
115
|
+
WSlaveSage.new().production()
|
116
|
+
else
|
117
|
+
puts "sage command \"#{command}\" not found."
|
118
|
+
puts "sage commands available: create update dev build production"
|
119
|
+
end
|
120
|
+
end
|
67
121
|
end
|
68
122
|
|
69
123
|
WSlaveCLI.start(ARGV)
|
data/lib/wslave_docker.rb
CHANGED
@@ -6,23 +6,54 @@ class WSlaveDocker
|
|
6
6
|
puts 'Initializing WSlave Docker Control'
|
7
7
|
end
|
8
8
|
|
9
|
-
def server(force)
|
9
|
+
def server(command = :start, force = false, volume = false)
|
10
|
+
case (command)
|
11
|
+
when :start
|
12
|
+
start(force, volume)
|
13
|
+
when :stop
|
14
|
+
stop(force, volume)
|
15
|
+
when :log
|
16
|
+
log()
|
17
|
+
when :console
|
18
|
+
console()
|
19
|
+
else
|
20
|
+
puts "server subcommand \"#{command.to_s}\" not found."
|
21
|
+
puts "Available commands: start stop log console"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def start(force = false, volume = false)
|
10
26
|
return unless _check()
|
11
27
|
_force_down() if force
|
28
|
+
`docker-compose down#{volume ? ' -v' : ''}` # Shutdown existing instances
|
12
29
|
_unfuck_dot_htaccess()
|
13
30
|
WSlaveTools.set_dev_perms
|
14
31
|
`docker-compose up -d`
|
15
32
|
end
|
16
33
|
|
17
|
-
def stop(force, volume)
|
34
|
+
def stop(force = false, volume = false)
|
18
35
|
return unless _check()
|
19
36
|
_force_down() if force
|
20
37
|
`docker-compose down#{volume ? ' -v' : ''}`
|
21
38
|
end
|
22
39
|
|
40
|
+
def log()
|
41
|
+
return unless _check()
|
42
|
+
begin
|
43
|
+
system("docker-compose logs -f")
|
44
|
+
rescue Exception => e
|
45
|
+
puts "\n\nEnding log trace. NOTE: Server containers are still running!\n\n"
|
46
|
+
return
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def console()
|
51
|
+
return unless _check()
|
52
|
+
system("docker-compose exec web /bin/bash")
|
53
|
+
end
|
54
|
+
|
23
55
|
def _check()
|
24
56
|
return true if (File.exist?("./config/.wslave") &&
|
25
|
-
File.exist?("Dockerfile") &&
|
26
57
|
File.exist?("docker-compose.yml"))
|
27
58
|
puts "This does not appear to be the root of a WSlave managed app."
|
28
59
|
false
|
data/lib/wslave_new.rb
CHANGED
@@ -1,43 +1,82 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
require 'rubygems'
|
3
|
+
require 'pathname'
|
4
|
+
require 'git'
|
5
|
+
|
3
6
|
require_relative 'wslave_tools'
|
4
7
|
|
5
8
|
class WSlaveNew
|
6
|
-
def initialize(path, version)
|
9
|
+
def initialize(path, version = '', wspath = '')
|
7
10
|
puts '⚙ Initializing Toolchain・・・'
|
8
11
|
|
9
|
-
|
10
|
-
|
12
|
+
if (wspath != '')
|
13
|
+
manual_path = true
|
14
|
+
if ((Pathname.new(wspath)).absolute?)
|
15
|
+
base_path = File.expand_path "#{wspath}/base/"
|
16
|
+
template_path = File.expand_path "#{wspath}/templates/"
|
17
|
+
else
|
18
|
+
base_path = File.expand_path "#{path}/#{wspath}/base/"
|
19
|
+
template_path = File.expand_path "#{path}/#{wspath}/templates/"
|
20
|
+
end
|
21
|
+
else
|
22
|
+
manual_path = false
|
23
|
+
wspath = "#{__dir__}/.."
|
24
|
+
base_path = File.expand_path "#{wspath}/base/"
|
25
|
+
template_path = File.expand_path "#{wspath}/templates/"
|
26
|
+
end
|
11
27
|
|
12
28
|
FileUtils.mkdir_p path
|
13
29
|
|
14
30
|
Dir.chdir path
|
15
|
-
|
31
|
+
|
16
32
|
puts " > Setting up WordPress WSlave setup in: #{path}"
|
17
33
|
FileUtils.cp_r Dir.glob("#{base_path}/*"), path
|
18
34
|
FileUtils.cp_r Dir.glob("#{template_path}/*"), path
|
35
|
+
add_path_to_Gemspec(wspath, path) if manual_path
|
19
36
|
|
20
|
-
spec = Gem::Specification::load("#{
|
37
|
+
spec = Gem::Specification::load("#{wspath}/wslave.gemspec")
|
21
38
|
File.open("#{path}/config/.wslave", 'w') {|f| f.write(spec.version)}
|
22
39
|
|
23
40
|
`cd #{path} && git init && git add --all && git commit -am "initial commit by wslave"`
|
24
41
|
|
25
42
|
`cd #{path} && git submodule add git://github.com/WordPress/WordPress.git public/wordpress`
|
26
|
-
`cd #{path}/public/wordpress && git checkout #{version}-branch` if version != ''
|
27
43
|
`cd #{path} && git submodule update --init --recursive public/wordpress`
|
44
|
+
if (version == 'edge' || version == 'master')
|
45
|
+
`cd #{path}/public/wordpress && git checkout master`
|
46
|
+
elsif version != ''
|
47
|
+
`cd #{path}/public/wordpress && git checkout #{version}`
|
48
|
+
else
|
49
|
+
`cd #{path}/public/wordpress && git checkout #{get_stable_branch_version("#{path}/public/wordpress")}-branch`
|
50
|
+
end
|
28
51
|
|
29
52
|
puts " > Preparing detached content directory"
|
30
53
|
FileUtils.cp_r("#{path}/public/wordpress/wp-content", "#{path}/public/wp-content")
|
31
|
-
FileUtils.mkdir("#{path}/public/wp-content/uploads")
|
54
|
+
FileUtils.mkdir("#{path}/public/wp-content/uploads") unless Dir.exist?("#{path}/public/wp-content/uploads")
|
32
55
|
FileUtils.touch("#{path}/public/wp-content/uploads/.gitkeep")
|
33
|
-
FileUtils.mkdir("#{path}/public/wp-content/upgrade")
|
56
|
+
FileUtils.mkdir("#{path}/public/wp-content/upgrade") unless Dir.exist?("#{path}/public/wp-content/upgrade")
|
34
57
|
FileUtils.touch("#{path}/public/wp-content/upgrade/.gitkeep")
|
35
58
|
Dir.chdir path
|
36
59
|
|
37
60
|
puts " > Setting permissions"
|
38
61
|
WSlaveTools.set_dev_perms
|
39
|
-
|
62
|
+
|
40
63
|
`cd #{path} && git add --all && git commit -am "Add and initialize WordPress#{version}"`
|
41
64
|
puts " > Done!"
|
42
65
|
end
|
66
|
+
|
67
|
+
def add_path_to_Gemspec(wspath, path)
|
68
|
+
gemtext = File.read("#{path}/Gemfile")
|
69
|
+
gemtext.gsub!("gem 'wslave'", "gem 'wslave', path: '#{wspath}'")
|
70
|
+
File.open("#{path}/Gemfile", "w") {|gemfile| gemfile.puts gemtext}
|
71
|
+
end
|
72
|
+
|
73
|
+
def get_stable_branch_version(path)
|
74
|
+
latest = '5.4' # This is just a fallback (latest at time of update)
|
75
|
+
# TODO Implementation requires this issue be resolved: https://github.com/ruby-git/ruby-git/issues/424
|
76
|
+
#g = Git.open(path)
|
77
|
+
#g.brances.remote.each do |branch|
|
78
|
+
#end
|
79
|
+
|
80
|
+
latest
|
81
|
+
end
|
43
82
|
end
|