wslave 0.2.2
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/base/.gitignore +5 -0
- data/base/Capfile +24 -0
- data/base/Gemfile +3 -0
- data/base/Rakefile +81 -0
- data/base/config/deploy-tools/gen-nginx-vhost.rb +11 -0
- data/base/config/deploy-tools/gen-salts.rb +21 -0
- data/base/config/deploy-tools/gen-wp-config.rb +18 -0
- data/base/config/deploy-tools/nginx.vhost.erb +51 -0
- data/base/config/deploy-tools/wp-config.php.erb +97 -0
- data/base/config/deploy-tools/wp-config.php.local +96 -0
- data/base/config/deploy.rb +17 -0
- data/base/config/deploy/.production.rb.swp +0 -0
- data/base/config/deploy/.staging.rb.swp +0 -0
- data/base/config/deploy/production.rb +288 -0
- data/base/config/deploy/staging.rb +288 -0
- data/base/docker-compose.yml +33 -0
- data/base/docker/apache/Dockerfile +16 -0
- 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 +27 -0
- data/base/public/wp-config.php +96 -0
- data/bin/wslave +123 -0
- data/lib/wslave_docker.rb +75 -0
- data/lib/wslave_new.rb +82 -0
- data/lib/wslave_sage.rb +76 -0
- data/lib/wslave_tools.rb +80 -0
- data/lib/wslave_update.rb +38 -0
- data/templates/config/database.yml +16 -0
- data/templates/config/definitions.yml +22 -0
- data/wslave.gemspec +32 -0
- metadata +211 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
version: '3'
|
2
|
+
|
3
|
+
services:
|
4
|
+
db:
|
5
|
+
image: mariadb:10.5.4-focal
|
6
|
+
volumes:
|
7
|
+
- "./db/dev:/db"
|
8
|
+
- "./db/active:/docker-entrypoint-initdb.d"
|
9
|
+
environment:
|
10
|
+
MYSQL_ROOT_PASSWORD: wordpress
|
11
|
+
MYSQL_DATABASE: wordpress
|
12
|
+
web:
|
13
|
+
depends_on:
|
14
|
+
- db
|
15
|
+
build: ./docker/apache/
|
16
|
+
volumes:
|
17
|
+
- "./public:/var/www/html"
|
18
|
+
ports:
|
19
|
+
- "8000:80"
|
20
|
+
environment:
|
21
|
+
WORDPRESS_DB_HOST: db:3306
|
22
|
+
WORDPRESS_DB_PASSWORD: wordpress
|
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
|
@@ -0,0 +1,16 @@
|
|
1
|
+
FROM php:7.4-apache
|
2
|
+
|
3
|
+
RUN a2enmod rewrite
|
4
|
+
RUN service apache2 restart
|
5
|
+
RUN apt-get update \
|
6
|
+
&& apt-get install -y libpng-dev libjpeg-dev mariadb-client mariadb-common libonig-dev \
|
7
|
+
&& docker-php-ext-install gd \
|
8
|
+
&& docker-php-ext-install mbstring \
|
9
|
+
&& docker-php-ext-install mysqli \
|
10
|
+
&& docker-php-ext-install pdo \
|
11
|
+
&& docker-php-ext-install pdo_mysql \
|
12
|
+
&& docker-php-ext-install opcache \
|
13
|
+
&& apt-get clean
|
14
|
+
RUN adduser www-data root
|
15
|
+
RUN mkdir /db \
|
16
|
+
&& chmod 777 /db
|
@@ -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
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<IfModule mod_rewrite.c>
|
2
|
+
RewriteEngine On
|
3
|
+
RewriteBase /
|
4
|
+
|
5
|
+
RewriteRule ^$ wordpress/index.php [L]
|
6
|
+
|
7
|
+
# Skip real files and directories
|
8
|
+
RewriteCond %{REQUEST_FILENAME} !-f
|
9
|
+
RewriteCond %{REQUEST_FILENAME} !-d
|
10
|
+
|
11
|
+
# Otherwise send it to WordPress
|
12
|
+
RewriteRule .* wordpress/index.php [L]
|
13
|
+
|
14
|
+
# BEGIN WordPress
|
15
|
+
# END WordPress
|
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>
|
@@ -0,0 +1,96 @@
|
|
1
|
+
<?php
|
2
|
+
/**
|
3
|
+
* The base configuration for WordPress
|
4
|
+
*
|
5
|
+
* The wp-config.php creation script uses this file during the
|
6
|
+
* installation. You don't have to use the web site, you can
|
7
|
+
* copy this file to "wp-config.php" and fill in the values.
|
8
|
+
*
|
9
|
+
* This file contains the following configurations:
|
10
|
+
*
|
11
|
+
* * MySQL settings
|
12
|
+
* * Secret keys
|
13
|
+
* * Database table prefix
|
14
|
+
* * ABSPATH
|
15
|
+
*
|
16
|
+
* @link https://codex.wordpress.org/Editing_wp-config.php
|
17
|
+
*
|
18
|
+
* @package WordPress
|
19
|
+
*/
|
20
|
+
|
21
|
+
// ** MySQL settings - You can get this info from your web host ** //
|
22
|
+
/** The name of the database for WordPress */
|
23
|
+
define('DB_NAME', 'wordpress');
|
24
|
+
|
25
|
+
/** MySQL database username */
|
26
|
+
define('DB_USER', 'root');
|
27
|
+
|
28
|
+
/** MySQL database password */
|
29
|
+
define('DB_PASSWORD', 'wordpress');
|
30
|
+
|
31
|
+
/** MySQL hostname */
|
32
|
+
define('DB_HOST', 'db');
|
33
|
+
|
34
|
+
/** Database Charset to use in creating database tables. */
|
35
|
+
define('DB_CHARSET', 'utf8');
|
36
|
+
|
37
|
+
/** The Database Collate type. Don't change this if in doubt. */
|
38
|
+
define('DB_COLLATE', '');
|
39
|
+
|
40
|
+
/**#@+
|
41
|
+
* Authentication Unique Keys and Salts.
|
42
|
+
*
|
43
|
+
* Change these to different unique phrases!
|
44
|
+
* You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
|
45
|
+
* You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
|
46
|
+
*
|
47
|
+
* @since 2.6.0
|
48
|
+
*/
|
49
|
+
define('AUTH_KEY', 'put your unique phrase here');
|
50
|
+
define('SECURE_AUTH_KEY', 'put your unique phrase here');
|
51
|
+
define('LOGGED_IN_KEY', 'put your unique phrase here');
|
52
|
+
define('NONCE_KEY', 'put your unique phrase here');
|
53
|
+
define('AUTH_SALT', 'put your unique phrase here');
|
54
|
+
define('SECURE_AUTH_SALT', 'put your unique phrase here');
|
55
|
+
define('LOGGED_IN_SALT', 'put your unique phrase here');
|
56
|
+
define('NONCE_SALT', 'put your unique phrase here');
|
57
|
+
|
58
|
+
/**#@-*/
|
59
|
+
|
60
|
+
/**
|
61
|
+
* WordPress Database Table prefix.
|
62
|
+
*
|
63
|
+
* You can have multiple installations in one database if you give each
|
64
|
+
* a unique prefix. Only numbers, letters, and underscores please!
|
65
|
+
*/
|
66
|
+
$table_prefix = 'wp_';
|
67
|
+
|
68
|
+
/**
|
69
|
+
* For developers: WordPress debugging mode.
|
70
|
+
*
|
71
|
+
* Change this to true to enable the display of notices during development.
|
72
|
+
* It is strongly recommended that plugin and theme developers use WP_DEBUG
|
73
|
+
* in their development environments.
|
74
|
+
*
|
75
|
+
* For information on other constants that can be used for debugging,
|
76
|
+
* visit the Codex.
|
77
|
+
*
|
78
|
+
* @link https://codex.wordpress.org/Debugging_in_WordPress
|
79
|
+
*/
|
80
|
+
define('WP_DEBUG', false);
|
81
|
+
|
82
|
+
/* That's all, stop editing! Happy blogging. */
|
83
|
+
|
84
|
+
/** Absolute path to the WordPress directory. */
|
85
|
+
if ( !defined('ABSPATH') )
|
86
|
+
define('ABSPATH', dirname(__FILE__) . '/wordpress/');
|
87
|
+
|
88
|
+
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST']);
|
89
|
+
define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/wordpress');
|
90
|
+
define('WP_CONTENT_DIR', realpath(ABSPATH . '../wp-content/'));
|
91
|
+
define('WP_CONTENT_URL', WP_HOME . '/wp-content');
|
92
|
+
//define('WP_TEMP_DIR', realpath(ABSPATH . '../../tmp/'));
|
93
|
+
define('FS_METHOD', 'direct');
|
94
|
+
|
95
|
+
/** Sets up WordPress vars and included files. */
|
96
|
+
require_once(ABSPATH . 'wp-settings.php');
|
data/bin/wslave
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'thor'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
class WSlaveCLI < Thor
|
6
|
+
|
7
|
+
def self.exit_on_failure?
|
8
|
+
true
|
9
|
+
end
|
10
|
+
|
11
|
+
desc 'new [APP_PATH]', "Generate a new app at APP_PATH"
|
12
|
+
long_desc "Creates a new application in the current directory or in the specificed path."
|
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".'
|
17
|
+
def new(path = './')
|
18
|
+
require_relative '../lib/wslave_new'
|
19
|
+
real_path = File.expand_path(path)
|
20
|
+
WSlaveNew.new(real_path, options['version'], options['wspath'])
|
21
|
+
end
|
22
|
+
|
23
|
+
desc 'update', "Updates toolchain"
|
24
|
+
long_desc "Updates toolchain. Will not overwrite existing configuration files."
|
25
|
+
def update()
|
26
|
+
require_relative '../lib/wslave_update'
|
27
|
+
WSlaveUpdate.new()
|
28
|
+
end
|
29
|
+
|
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'])
|
61
|
+
end
|
62
|
+
|
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()
|
67
|
+
puts 'Starting server...'
|
68
|
+
require_relative '../lib/wslave_docker'
|
69
|
+
WSlaveDocker.new().server(:start, options['f'], options['v'])
|
70
|
+
end
|
71
|
+
|
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'
|
75
|
+
def stop()
|
76
|
+
puts 'Stopping server...'
|
77
|
+
require_relative '../lib/wslave_docker'
|
78
|
+
WSlaveDocker.new().server(:stop, options['f'], options['v'])
|
79
|
+
end
|
80
|
+
|
81
|
+
desc 'sync', "Synchronizes submodules and file permissions"
|
82
|
+
def sync()
|
83
|
+
require_relative '../lib/wslave_tools'
|
84
|
+
puts 'Synchronizing...'
|
85
|
+
WSlaveTools.sync()
|
86
|
+
end
|
87
|
+
|
88
|
+
desc 'version', "Prints the version of the installed WSlave"
|
89
|
+
def version()
|
90
|
+
require 'rubygems'
|
91
|
+
spec = Gem::Specification::load("#{__dir__}/../wslave.gemspec")
|
92
|
+
puts spec.version
|
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
|
121
|
+
end
|
122
|
+
|
123
|
+
WSlaveCLI.start(ARGV)
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require_relative 'wslave_tools'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
class WSlaveDocker
|
5
|
+
def initialize
|
6
|
+
puts 'Initializing WSlave Docker Control'
|
7
|
+
end
|
8
|
+
|
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)
|
26
|
+
return unless _check()
|
27
|
+
_force_down() if force
|
28
|
+
`docker-compose down#{volume ? ' -v' : ''}` # Shutdown existing instances
|
29
|
+
_unfuck_dot_htaccess()
|
30
|
+
WSlaveTools.set_dev_perms
|
31
|
+
`docker-compose up -d`
|
32
|
+
end
|
33
|
+
|
34
|
+
def stop(force = false, volume = false)
|
35
|
+
return unless _check()
|
36
|
+
_force_down() if force
|
37
|
+
`docker-compose down#{volume ? ' -v' : ''}`
|
38
|
+
end
|
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
|
+
|
55
|
+
def _check()
|
56
|
+
return true if (File.exist?("./config/.wslave") &&
|
57
|
+
File.exist?("docker-compose.yml"))
|
58
|
+
puts "This does not appear to be the root of a WSlave managed app."
|
59
|
+
false
|
60
|
+
end
|
61
|
+
|
62
|
+
def _force_down()
|
63
|
+
`docker-compose down --remove-orphans`
|
64
|
+
end
|
65
|
+
|
66
|
+
# Sometimes the docker container or a windows fs will screw up or delete .htaccess
|
67
|
+
def _unfuck_dot_htaccess()
|
68
|
+
begin
|
69
|
+
FileUtils.cp_r("#{__dir__}/../base/public/.htaccess", "./public/.htaccess")
|
70
|
+
# FileUtils.chmod(0444, "./public/.htaccess")
|
71
|
+
rescue => e
|
72
|
+
# noop
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|