Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
39dc7800d9
|
12
.env.local
Normal file
12
.env.local
Normal file
@@ -0,0 +1,12 @@
|
||||
WORDPRESS_NETWORK_URL=cmbabaseball.localhost
|
||||
|
||||
WORDPRESS_CONFIG_EXTRA="
|
||||
define('WP_ALLOW_MULTISITE', true );
|
||||
define('MULTISITE', true );
|
||||
define('SUBDOMAIN_INSTALL', false );
|
||||
define('DOMAIN_CURRENT_SITE', '${WORDPRESS_NETWORK_URL}' );
|
||||
define('PATH_CURRENT_SITE', '/' );
|
||||
define('SITE_ID_CURRENT_SITE', 1 );
|
||||
define('BLOG_ID_CURRENT_SITE', 1 );
|
||||
define('FORCE_SSL_LOGIN', true );
|
||||
"
|
||||
42
README.md
42
README.md
@@ -1,43 +1,3 @@
|
||||
# Selig
|
||||
|
||||
Selig is a Docker project to set-up two Wordpress servers, one for a league, one for a team. It uses Caddy for the webserver and a single MariaDB instance for the server.
|
||||
|
||||
Each Wordpress instance setups their own database within the MariaDB instance.
|
||||
|
||||
## Setup
|
||||
### Environment Files
|
||||
There are two environment files, one at the project root and one under each WordPress folder ([cmbabaseball](./cmbabaseball/.env), [chihounds](./chihounds/.env)).
|
||||
|
||||
### Init
|
||||
Each WordPress site has an `wp-install.sh` script ([cmbabaseball](./cmbabaseball/wp-install), [chihounds](./chihounds/wp-install)). It creates the database and install Wordpress using the common `wp-admin` user info provided in the project root via a ephemeral wp-cli container. (Theoretically, this probably can be changed by overwriting the environment variables in the website-specific env file, but I didn't test that and I don't know what the order would have to be). It also preinstalls a list of plugins as defined in the site's .env.
|
||||
|
||||
Currently, the scripts are exactly the same, so they are symbolic links to the shared directory.
|
||||
|
||||
```sh
|
||||
./cmbabaseball/init-wordpress
|
||||
./chihounds/init-wordpress
|
||||
```
|
||||
|
||||
OR
|
||||
|
||||
```sh
|
||||
./*/init-wordpress
|
||||
```
|
||||
|
||||
### Import
|
||||
Since I was starting from a couple of existing sites, each WordPress site has an `import-wordpress.sh` ([cmbabaseball](./cmbabaseball/import-wordpress.sh), [chihounds](./chihounds/import-wordpress.sh)). These have been packaged as a `import.sql` DB export and a `import-uploads.tgz` archive of the uploads folder.
|
||||
|
||||
```sh
|
||||
./cmbabaseball/wp-import.sh
|
||||
./chihounds/wp-import.sh
|
||||
```
|
||||
OR
|
||||
```sh
|
||||
./*cmbabaseball*/wp-import.sh
|
||||
```
|
||||
|
||||
### Tying it together
|
||||
To put it together succintly, you can run the following to do all the init scripts, then the import scripts.
|
||||
```sh
|
||||
/*/wp-install.sh && ./*/wp-import.sh
|
||||
```
|
||||
Selig is a Docker project to set-up two Wordpress servers, one for a league, one for a team using Wordpress multisite. It uses Caddy for the webserver and a single MariaDB instance for the server.
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
cmbabaseball.localhost {
|
||||
root * /var/www/cmbabaseball
|
||||
php_fastcgi cmbabaseball:9000 {
|
||||
root /var/www/html
|
||||
}
|
||||
file_server
|
||||
}
|
||||
|
||||
chihounds.localhost {
|
||||
root * /var/www/chihounds
|
||||
php_fastcgi chihounds:9000 {
|
||||
root /var/www/html
|
||||
}
|
||||
file_server
|
||||
}
|
||||
18
caddy/Caddyfile.localhost
Normal file
18
caddy/Caddyfile.localhost
Normal file
@@ -0,0 +1,18 @@
|
||||
cmbabaseball.localhost {
|
||||
root * /var/www/html
|
||||
@wp path_regexp wp ^/([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*)
|
||||
handle @wp {
|
||||
rewrite * {http.regexp.wp.2}
|
||||
}
|
||||
|
||||
|
||||
php_fastcgi wordpress:9000
|
||||
file_server
|
||||
}
|
||||
|
||||
chihounds.localhost {
|
||||
root * /var/www/html
|
||||
|
||||
php_fastcgi wordpress:9000
|
||||
file_server
|
||||
}
|
||||
18
caddy/Caddyfile.production
Normal file
18
caddy/Caddyfile.production
Normal file
@@ -0,0 +1,18 @@
|
||||
cmbabaseball.correa.co {
|
||||
root * /var/www/html
|
||||
@wp path_regexp wp ^/([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*)
|
||||
handle @wp {
|
||||
rewrite * {http.regexp.wp.2}
|
||||
}
|
||||
|
||||
|
||||
php_fastcgi wordpress:9000
|
||||
file_server
|
||||
}
|
||||
|
||||
chihounds.correa.co {
|
||||
root * /var/www/html
|
||||
|
||||
php_fastcgi wordpress:9000
|
||||
file_server
|
||||
}
|
||||
@@ -1,8 +1,2 @@
|
||||
WORDPRESS_TITLE=
|
||||
WORDPRESS_SITEURL=
|
||||
WORDPRESS_HOME=
|
||||
|
||||
WORDPRESS_DB_NAME=
|
||||
|
||||
WP_THEMES=
|
||||
WP_PLUGINS=
|
||||
WORDPRESS_SITE_2_SLUG=
|
||||
WORDPRESS_SITE_2_TITLE=
|
||||
348444
chihounds/data/chicagohounds.WordPress.2023-12-12.xml
Normal file
348444
chihounds/data/chicagohounds.WordPress.2023-12-12.xml
Normal file
File diff suppressed because one or more lines are too long
@@ -1,4 +0,0 @@
|
||||
cd "$(dirname "$0")"
|
||||
PROJECT_NAME=selig
|
||||
CONTAINER_NAME=chihounds
|
||||
docker run --rm --user 33:33 --volume ${PROJECT_NAME}_${CONTAINER_NAME}-wpdata:/var/www/html --volume ./data:/data --env-file ../.env --env-file .env --network ${PROJECT_NAME}_network "$@"
|
||||
@@ -1 +0,0 @@
|
||||
../shared/wp-cli.sh
|
||||
18
chihounds/wp-create-site.sh
Executable file
18
chihounds/wp-create-site.sh
Executable file
@@ -0,0 +1,18 @@
|
||||
if [ "$#" -lt 1 ]; then
|
||||
echo "Error: COMPOSE_FILE argument is missing."
|
||||
echo "Usage: $0 COMPOSE_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
COMPOSE_FILE="$1"
|
||||
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
|
||||
ENV_FILE=$SCRIPTPATH/.env
|
||||
|
||||
# this env file is not being read and i don't know why.
|
||||
# it's actually being loaded from compose.yml
|
||||
|
||||
docker compose -f $COMPOSE_FILE --env-file $ENV_FILE run --rm -it wp-cli sh -c '\
|
||||
wp site create \
|
||||
--title="$WORDPRESS_SITE_2_TITLE" \
|
||||
--slug="$WORDPRESS_SITE_2_SLUG" \
|
||||
--skip-email'
|
||||
@@ -1 +0,0 @@
|
||||
../shared/wp-import.sh
|
||||
@@ -1 +0,0 @@
|
||||
../shared/wp-install.sh
|
||||
@@ -1,8 +0,0 @@
|
||||
WORDPRESS_TITLE=
|
||||
WORDPRESS_SITEURL=
|
||||
WORDPRESS_HOME=
|
||||
|
||||
WORDPRESS_DB_NAME=
|
||||
|
||||
WP_THEMES=
|
||||
WP_PLUGINS=
|
||||
@@ -1,4 +0,0 @@
|
||||
cd "$(dirname "$0")"
|
||||
PROJECT_NAME=selig
|
||||
CONTAINER_NAME=cmbabaseball
|
||||
docker run --rm --user 33:33 --volume ${PROJECT_NAME}_${CONTAINER_NAME}-wpdata:/var/www/html --volume ./data:/data --env-file ../.env --env-file .env --network ${PROJECT_NAME}_network "$@"
|
||||
@@ -1 +0,0 @@
|
||||
../shared/wp-cli.sh
|
||||
@@ -1 +0,0 @@
|
||||
../shared/wp-import.sh
|
||||
@@ -1 +0,0 @@
|
||||
../shared/wp-install.sh
|
||||
77
compose.local.yml
Normal file
77
compose.local.yml
Normal file
@@ -0,0 +1,77 @@
|
||||
services:
|
||||
wp-cli:
|
||||
image: wordpress:cli
|
||||
user: 33:33
|
||||
env_file:
|
||||
- .env
|
||||
- .env.local
|
||||
- ./network/.env
|
||||
- ./chihounds/.env
|
||||
depends_on:
|
||||
- database
|
||||
volumes:
|
||||
- wpdata:/var/www/html
|
||||
profiles:
|
||||
- cli
|
||||
networks:
|
||||
- network
|
||||
wordpress:
|
||||
depends_on:
|
||||
- database
|
||||
image: wordpress:fpm
|
||||
env_file:
|
||||
- .env
|
||||
- .env.local
|
||||
- ./network/.env
|
||||
environment:
|
||||
WORDPRESS_DEBUG: 1
|
||||
volumes:
|
||||
- wpdata:/var/www/html
|
||||
- ./wordpress/php.ini:/usr/local/etc/php/conf.d/wordpress.ini
|
||||
networks:
|
||||
- network
|
||||
database:
|
||||
image: mariadb
|
||||
env_file:
|
||||
- .env
|
||||
volumes:
|
||||
- db-data:/var/lib/mysql
|
||||
networks:
|
||||
- network
|
||||
phpmyadmin:
|
||||
depends_on:
|
||||
- database
|
||||
image: phpmyadmin
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
UPLOAD_LIMIT: 128M
|
||||
PMA_HOST: database
|
||||
PMA_PORT: 3306
|
||||
ports:
|
||||
- "8080:80"
|
||||
networks:
|
||||
- network
|
||||
profiles:
|
||||
- debug
|
||||
caddy:
|
||||
image: caddy:alpine
|
||||
ports:
|
||||
- 80:80
|
||||
- 443:443
|
||||
volumes:
|
||||
- caddy-data:/data
|
||||
- caddy-config:/config
|
||||
- ./caddy/Caddyfile.localhost:/etc/caddy/Caddyfile
|
||||
- wpdata:/var/www/html
|
||||
networks:
|
||||
- network
|
||||
command: ["caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile", "--watch"]
|
||||
|
||||
volumes:
|
||||
db-data:
|
||||
wpdata:
|
||||
caddy-data:
|
||||
caddy-config:
|
||||
networks:
|
||||
network:
|
||||
76
compose.production.yml
Normal file
76
compose.production.yml
Normal file
@@ -0,0 +1,76 @@
|
||||
services:
|
||||
wp-cli:
|
||||
image: wordpress:cli
|
||||
user: 33:33
|
||||
env_file:
|
||||
- .env
|
||||
- .env.local
|
||||
- ./network/.env
|
||||
- ./chihounds/.env
|
||||
depends_on:
|
||||
- database
|
||||
volumes:
|
||||
- wpdata:/var/www/html
|
||||
profiles:
|
||||
- cli
|
||||
networks:
|
||||
- network
|
||||
wordpress:
|
||||
depends_on:
|
||||
- database
|
||||
image: wordpress:fpm
|
||||
env_file:
|
||||
- .env
|
||||
- .env.local
|
||||
- ./network/.env
|
||||
environment:
|
||||
WORDPRESS_DEBUG: 1
|
||||
volumes:
|
||||
- wpdata:/var/www/html
|
||||
- ./wordpress/php.ini:/usr/local/etc/php/conf.d/wordpress.ini
|
||||
networks:
|
||||
- network
|
||||
database:
|
||||
image: mariadb
|
||||
env_file:
|
||||
- .env
|
||||
volumes:
|
||||
- db-data:/var/lib/mysql
|
||||
networks:
|
||||
- network
|
||||
phpmyadmin:
|
||||
depends_on:
|
||||
- database
|
||||
image: phpmyadmin
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
UPLOAD_LIMIT: 128M
|
||||
PMA_HOST: database
|
||||
PMA_PORT: 3306
|
||||
ports:
|
||||
- "8080:80"
|
||||
networks:
|
||||
- network
|
||||
profiles:
|
||||
- debug
|
||||
caddy:
|
||||
image: caddy:alpine
|
||||
ports:
|
||||
- 80:80
|
||||
- 443:443
|
||||
volumes:
|
||||
- caddy-data:/data
|
||||
- caddy-config:/config
|
||||
- ./caddy/Caddyfile.production:/etc/caddy/Caddyfile
|
||||
- wpdata:/var/www/html
|
||||
networks:
|
||||
- network
|
||||
|
||||
volumes:
|
||||
db-data:
|
||||
wpdata:
|
||||
caddy-data:
|
||||
caddy-config:
|
||||
networks:
|
||||
network:
|
||||
77
compose.yml
77
compose.yml
@@ -1,77 +0,0 @@
|
||||
name: ${PROJECT_NAME}
|
||||
services:
|
||||
wordpress-chihounds:
|
||||
container_name: chihounds
|
||||
depends_on:
|
||||
- database
|
||||
image: wordpress:fpm
|
||||
env_file:
|
||||
- .env
|
||||
- chihounds/.env
|
||||
environment:
|
||||
WORDPRESS_DEBUG: 0
|
||||
volumes:
|
||||
- chihounds-wpdata:/var/www/html
|
||||
- ./shared/php.ini:/usr/local/etc/php/conf.d/wordpress.ini
|
||||
networks:
|
||||
- network
|
||||
wordpress-cmbabaseball:
|
||||
container_name: cmbabaseball
|
||||
depends_on:
|
||||
- database
|
||||
image: wordpress:fpm
|
||||
env_file:
|
||||
- .env
|
||||
- cmbabaseball/.env
|
||||
environment:
|
||||
WORDPRESS_DEBUG: 0
|
||||
volumes:
|
||||
- cmbabaseball-wpdata:/var/www/html
|
||||
- ./shared/php.ini:/usr/local/etc/php/conf.d/wordpress.ini
|
||||
networks:
|
||||
- network
|
||||
database:
|
||||
container_name: database
|
||||
hostname: ${WORDPRESS_DB_HOST}
|
||||
image: mariadb
|
||||
env_file:
|
||||
- .env
|
||||
volumes:
|
||||
- db-data:/var/lib/mysql
|
||||
networks:
|
||||
- network
|
||||
phpmyadmin:
|
||||
container_name: phpmyadmin
|
||||
image: phpmyadmin
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
|
||||
UPLOAD_LIMIT: 128M
|
||||
ports:
|
||||
- "8080:80"
|
||||
networks:
|
||||
- network
|
||||
profiles:
|
||||
- DEV
|
||||
caddy:
|
||||
image: caddy:alpine
|
||||
container_name: webserver
|
||||
ports:
|
||||
- 80:80
|
||||
- 443:443
|
||||
volumes:
|
||||
- caddy-data:/data
|
||||
- caddy-config:/config
|
||||
- ./caddy/Caddyfile:/etc/caddy/Caddyfile
|
||||
- chihounds-wpdata:/var/www/chihounds
|
||||
- cmbabaseball-wpdata:/var/www/cmbabaseball
|
||||
networks:
|
||||
- network
|
||||
|
||||
volumes:
|
||||
db-data:
|
||||
chihounds-wpdata:
|
||||
cmbabaseball-wpdata:
|
||||
caddy-data:
|
||||
caddy-config:
|
||||
networks:
|
||||
network:
|
||||
4
network/.env.sample
Normal file
4
network/.env.sample
Normal file
@@ -0,0 +1,4 @@
|
||||
WORDPRESS_NETWORK_TITLE=
|
||||
WORDPRESS_ADMIN_USER=
|
||||
WORDPRESS_ADMIN_EMAIL=
|
||||
WORDPRESS_ADMIN_PASSWORD=
|
||||
21
network/wp-multisite-install.sh
Executable file
21
network/wp-multisite-install.sh
Executable file
@@ -0,0 +1,21 @@
|
||||
if [ "$#" -lt 1 ]; then
|
||||
echo "Error: COMPOSE_FILE argument is missing."
|
||||
echo "Usage: $0 COMPOSE_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
COMPOSE_FILE="$1"
|
||||
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
|
||||
ENV_FILE=$SCRIPTPATH/.env
|
||||
|
||||
# this env file is not being read and i don't know why.
|
||||
# it's actually being loaded from compose.yml
|
||||
|
||||
docker compose -f $COMPOSE_FILE --env-file "${ENV_FILE}" run --rm -it wp-cli sh -c \
|
||||
'wp core multisite-install \
|
||||
--title="${WORDPRESS_NETWORK_TITLE}" \
|
||||
--url="${WORDPRESS_NETWORK_URL}" \
|
||||
--admin_user="$WORDPRESS_ADMIN_USER" \
|
||||
--admin_email="$WORDPRESS_ADMIN_EMAIL" \
|
||||
--admin_password="$WORDPRESS_ADMIN_PASSWORD" \
|
||||
--skip-config --skip-email' \
|
||||
17
network/wp-plugin-install.sh
Executable file
17
network/wp-plugin-install.sh
Executable file
@@ -0,0 +1,17 @@
|
||||
WP_PLUGINS="sportspress sportspress-for-baseball wordpress-importer"
|
||||
WP_PLUGINS+=" akismet jetpack pretty-link printful-shipping-for-woocommerce seriously-simple-podcasting woocommerce woocommerce-services"
|
||||
if [ "$#" -lt 1 ]; then
|
||||
echo "Error: COMPOSE_FILE argument is missing."
|
||||
echo "Usage: $0 COMPOSE_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
COMPOSE_FILE="$1"
|
||||
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
|
||||
ENV_FILE=$SCRIPTPATH/.env
|
||||
|
||||
# this env file is not being read and i don't know why.
|
||||
# it's actually being loaded from compose.yml
|
||||
|
||||
docker compose -f $COMPOSE_FILE run --env WP_PLUGINS="$WP_PLUGINS" --rm -it wp-cli sh -c \
|
||||
'wp plugin install $WP_PLUGINS --activate --force'
|
||||
16
network/wp-theme-install.sh
Executable file
16
network/wp-theme-install.sh
Executable file
@@ -0,0 +1,16 @@
|
||||
WP_THEMES="rookie"
|
||||
if [ "$#" -lt 1 ]; then
|
||||
echo "Error: COMPOSE_FILE argument is missing."
|
||||
echo "Usage: $0 COMPOSE_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
COMPOSE_FILE="$1"
|
||||
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
|
||||
ENV_FILE=$SCRIPTPATH/.env
|
||||
|
||||
# this env file is not being read and i don't know why.
|
||||
# it's actually being loaded from compose.yml
|
||||
|
||||
docker compose -f $COMPOSE_FILE run --env WP_THEMES="$WP_THEMES" --rm -it wp-cli sh -c \
|
||||
'wp theme install $WP_THEMES'
|
||||
@@ -1,2 +0,0 @@
|
||||
cd "$(dirname "$0")"
|
||||
./docker-run.sh wordpress:cli "$@"
|
||||
@@ -1,28 +0,0 @@
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
./wp-cli.sh sh -c '
|
||||
|
||||
if [ -f /data/import.sql ]; then
|
||||
echo "Importing Database..."
|
||||
wp db import /data/import.sql
|
||||
echo "Replacing default site url ($(wp option get siteurl)->$WORDPRESS_SITEURL)"
|
||||
wp search-replace "$(wp option get siteurl)" "$WORDPRESS_SITEURL" --format=count
|
||||
echo "Re-adding the admin user"
|
||||
wp user create $WORDPRESS_ADMIN_USER $WORDPRESS_ADMIN_EMAIL --user_pass=$WORDPRESS_ADMIN_PASSWORD --role=administrator --porcelain
|
||||
echo "Done."
|
||||
fi && \
|
||||
if [ -f /data/import-uploads.tgz ]; then
|
||||
echo "Importing Uploads..."
|
||||
tar -xz --overwrite -f /data/import-uploads.tgz -C /var/www/html/wp-content/uploads .
|
||||
echo "Done."
|
||||
fi && \
|
||||
if [ -n "$(ls -A /data/import-plugins 2>/dev/null)" ]; then
|
||||
echo "Importing Plugins..."
|
||||
for I in /data/import-plugins/*.zip; do
|
||||
[ -f "$I" ] || continue
|
||||
echo "$I"
|
||||
wp plugin install "$I" --activate
|
||||
done
|
||||
echo "Done."
|
||||
fi
|
||||
'
|
||||
@@ -1,7 +0,0 @@
|
||||
cd "$(dirname "$0")"
|
||||
./wp-cli.sh sh -c '
|
||||
wp db create || true && \
|
||||
wp core install --title="$WORDPRESS_TITLE" --url="$WORDPRESS_SITEURL" --admin_user=$WORDPRESS_ADMIN_USER --admin_email=$WORDPRESS_ADMIN_EMAIL --admin_password=$WORDPRESS_ADMIN_PASSWORD && \
|
||||
wp theme install $WP_THEMES --activate --force; \
|
||||
wp plugin install $WP_PLUGINS --activate --force
|
||||
'
|
||||
Reference in New Issue
Block a user