Inititial Commit

This commit is contained in:
2024-03-11 14:30:21 +07:00
parent 6541d701df
commit 7f914b179c
7 changed files with 217 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
## Caddy ##
SERVER_NAME = 10h30.net
WP_CLI_CACHE_DIR = /tmp
## Wordpress ##
WORDPRESS_DB_USER=siteuser
WORDPRESS_DB_PASSWORD=sitepassword
WORDPRESS_DB_NAME=wordpress
WORDPRESS_DB_HOST=db:3306
WORDPRESS_CONFIG_EXTRA=define('WP_REDIS_HOST','redis');
# Website Credentials
WORDPRESS_ADMIN_USER = admin
WORDPRESS_ADMIN_PASSWORD = thuanbuidepchai
WORDPRESS_ADMIN_EMAIL = admin@domain.com
# Blog Settings
WORDPRESS_TITLE = 'Blog Title Here'
WORDPRESS_PERMALINK_STRUCTURE = /%postname%/
WORDPRESS_THEME_TO_INSTALL = "kadence"
WORDPRESS_PLUGINS_TO_INSTALL = "redis-cache cache-enabler seo-by-rank-math"
## MYSQL ##
MYSQL_USER=siteuser
MYSQL_PASSWORD=sitepassword
MYSQL_DATABASE=wordpress
MYSQL_ROOT_PASSWORD=rootpassword
MYSQL_RANDOM_ROOT_PASSWORD=1
MARIADB_RANDOM_ROOT_PASSWORD=1
+45
View File
@@ -0,0 +1,45 @@
(cache_enabler) {
@cache_ena {
not header_regexp Cookie "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in"
not path_regexp "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(index)?.xml|[a-z0-9-]+-sitemap([0-9]+)?.xml)"
not method POST
not expression {query} != ''
}
route @cache_ena {
try_files /wp-content/cache/cache-enabler/{host}{uri}/https-index.html /wp-content/cache/cache-enabler/{host}{uri}/index.html {path} {path}/index.php?{query}
}
}
(wordpress_security) {
@forbidden {
not path /wp-includes/ms-files.php
path /wp-admin/includes/*.php
path /wp-includes/*.php
path /wp-config.php
path /wp-content/uploads/*.php
path /.user.ini
path /wp-content/debug.log
}
respond @forbidden "Access denied" 403
}
{$SERVER_NAME} {
root * /var/www/html
encode zstd gzip
# Serve WordPress PHP files through php-fpm:
php_fastcgi wordpress:9000
# Enable the static file server:
file_server {
precompressed gzip
}
header / {
X-Frame-Options "SAMEORIGIN"
X-Content-Type-Options "nosniff"
}
#import cache_enabler
#import wordpress_security
}
+60
View File
@@ -0,0 +1,60 @@
version: "3.9"
services:
caddy:
image: caddy:2.7.6-alpine
container_name: caddy
env_file: .env
ports:
- 80:80
- 443:443
- 443:443/udp
volumes:
- ./caddy/caddy_data:/data
- ./caddy/caddy_config:/config
- ./caddy/Caddyfile:/etc/caddy/Caddyfile
- ./wordpress/html:/var/www/html
wordpress:
image: wordpress:fpm-alpine
container_name: wordpress
restart: always
depends_on:
- db
- redis
volumes:
- ./wordpress/html:/var/www/html
- ./wordpress/custom.ini:/usr/local/etc/php/conf.d/custom.ini
env_file: .env
db:
image: mariadb:10.11.6-jammy
restart: always
volumes:
- ./wordpress/mysql:/var/lib/mysql
env_file: .env
wpcli:
depends_on:
- db
- wordpress
image: wordpress:cli
entrypoint: wp
command: "--info"
env_file: .env
volumes:
- ./wordpress/html:/var/www/html
redis:
image: redis:6.2.14
restart: always
#elastic:
# image: elasticsearch:7.17.13
# restart: always
# environment:
# discovery.type: single-node
# xpack.security.enabled: false
# ports:
# - 9200:9200
# volumes:
# - ./elastic:/usr/share/elasticsearch/data
+5
View File
@@ -0,0 +1,5 @@
memory_limit=2048M
max_execution_time=300
php_enable_xdebug=false
debug=false
upload_max_filesize=16M
Executable
+73
View File
@@ -0,0 +1,73 @@
SERVER_NAME=$(sed -e 's#.*=\(\)#\1#' <<< "$(awk '/SERVER_NAME/{print}' .env)" | xargs)
WORDPRESS_TITLE=$(sed -e 's#.*=\(\)#\1#' <<< "$(awk '/WORDPRESS_TITLE/{print}' .env)" | xargs)
WORDPRESS_USER=$(sed -e 's#.*=\(\)#\1#' <<< "$(awk '/WORDPRESS_ADMIN_USER/{print}' .env)" | xargs)
WORDPRESS_EMAIL=$(sed -e 's#.*=\(\)#\1#' <<< "$(awk '/WORDPRESS_ADMIN_EMAIL/{print}' .env)" | xargs)
WORDPRESS_PASSWORD=$(sed -e 's#.*=\(\)#\1#' <<< "$(awk '/WORDPRESS_ADMIN_PASSWORD/{print}' .env)" | xargs)
WORDPRESS_PLUGINS_TO_INSTALL=$(sed -e 's#.*=\(\)#\1#' <<< "$(awk '/WORDPRESS_PLUGINS_TO_INSTALL/{print}' .env)" | xargs)
WORDPRESS_THEME_TO_INSTALL=$(sed -e 's#.*=\(\)#\1#' <<< "$(awk '/WORDPRESS_THEME_TO_INSTALL/{print}' .env)" | xargs)
echo "Hello"
echo $SERVER_NAME
echo $WORDPRESS_TITLE
## Install Wodpress
docker compose run wpcli core install \
--url=${SERVER_NAME} \
--title="${WORDPRESS_TITLE}" \
--admin_user=${WORDPRESS_USER} \
--admin_email=${WORDPRESS_EMAIL} \
--admin_password=${WORDPRESS_PASSWORD} \
--skip-email
## Configure Permalinks
docker compose run wpcli rewrite structure '/%postname%/'
## Install Plugins
docker compose run wpcli plugin install ${WORDPRESS_PLUGINS_TO_INSTALL} --activate
## Enable Redis Cache Object
docker compose run wpcli redis enable
## Enable and config Cache Enabler
docker compose run wpcli option update cache_enabler '{
"version": "1.8.0",
"use_trailing_slashes": 1,
"permalink_structure": "has_trailing_slash",
"cache_expires": 1,
"cache_expiry_time": 8,
"clear_site_cache_on_saved_post": 0,
"clear_site_cache_on_saved_comment": 0,
"clear_site_cache_on_saved_term": 0,
"clear_site_cache_on_saved_user": 0,
"clear_site_cache_on_changed_plugin": 0,
"convert_image_urls_to_webp": 0,
"mobile_cache": 0,
"compress_cache": 1,
"minify_html": 1,
"minify_inline_css_js": 1,
"excluded_post_ids": "",
"excluded_page_paths": "",
"excluded_query_strings": "",
"excluded_cookies": ""
}' --format=json
# Theme installation
docker compose run wpcli theme install "${WORDPRESS_THEME_TO_INSTALL}" --activate
echo -e "\nREPORT\n"
# List users
echo "== User List =="
docker compose run wpcli user list
echo ""
# Show installed plugin
echo "== Theme List =="
docker compose run wpcli theme list
echo ""
# Show installed plugin
echo "== Plugin List =="
docker compose run wpcli plugin list
echo ""
Executable
+1
View File
@@ -0,0 +1 @@
docker compose up -d
+3
View File
@@ -0,0 +1,3 @@
docker compose down
rm -rf wordpress/html
rm -rf wordpress/mysql