Created
March 14, 2022 04:54
-
-
Save wastemobile/037eb459b7bd51962f01ad9135316756 to your computer and use it in GitHub Desktop.
WordPress and Caddy 2 with Docker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
[email protected] | |
} | |
www.site1.com { | |
redir https://site1.com{uri} | |
} | |
site1.com { | |
root * /usr/share/caddy/wordpress-site1 | |
log | |
@canonicalPath { | |
file { | |
try_files {path}/index.php | |
} | |
not { | |
path */ | |
} | |
} | |
@phpFiles { | |
path *.php | |
} | |
route { | |
redir @canonicalPath {path}/ 308 | |
try_files {path} {path}/index.php index.php | |
reverse_proxy @phpFiles { | |
to wordpress-site1:9000 | |
transport fastcgi { | |
split .php | |
root /var/www/html | |
} | |
} | |
respond /uploads/*.php 404 | |
file_server | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.7' | |
services: | |
caddy: | |
image: caddy:alpine | |
restart: always | |
container_name: caddy2 | |
ports: | |
- "80:80" | |
- "443:443" | |
volumes: | |
- /etc/timezone:/etc/timezone:ro | |
- /etc/localtime:/etc/localtime:ro | |
- $PWD/wordpress-site1-volume:/usr/share/caddy/wordpress-site1 | |
- $PWD/Caddyfile:/etc/caddy/Caddyfile | |
- $PWD/caddy_data:/data | |
- $PWD/caddy_config:/config | |
networks: | |
- yournet | |
mariadb: | |
image: mariadb:latest | |
container_name: mariadb | |
networks: | |
- yournet | |
volumes: | |
- $PWD/data/mariadb:/var/lib/mysql | |
- $PWD/conf/mariadb:/docker-entrypoint-initdb.d | |
restart: always | |
ports: | |
- 3306:3306 | |
env_file: | |
- $PWD/conf/mariadb.env | |
healthcheck: | |
test: pidof mysqld || exit 1 | |
interval: 120s | |
timeout: 10s | |
retries: 3 | |
wordpress-site1: | |
depends_on: | |
- mariadb | |
- caddy | |
image: wordpress:php7.4-fpm-alpine | |
container_name: wordpress-site1 | |
restart: always | |
networks: | |
- yournet | |
env_file: | |
- $PWD/conf/wordpress-site1.env | |
volumes: | |
- $PWD/wordpress-site1-volume:/var/www/html | |
- $PWD/conf/php.ini:/usr/local/etc/php/conf.d/custom.ini | |
healthcheck: | |
test: pidof php-fpm || exit 1 | |
interval: 10s | |
timeout: 10s | |
retries: 3 | |
adminer: | |
image: adminer | |
container_name: adminer | |
restart: always | |
depends_on: | |
- mariadb | |
networks: | |
- yoyonet | |
ports: | |
- 8081:8080 | |
environment: | |
- "MYSQL_ROOT_PASSWORD=mariadb" | |
- "TZ=Asia/Taipei" | |
healthcheck: | |
test: pidof php || exit 1 | |
interval: 120s | |
timeout: 10s | |
retries: 3 | |
networks: | |
yournet: | |
ipam: | |
config: | |
- subnet: 172.22.0.0/24 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MYSQL_ROOT_PASSWORD=<a-root-password> | |
TZ=Asia/Taipei |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
memory_limit = 32M | |
upload_max_filesize = 24M | |
post_max_size = 32M |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WORDPRESS_DB_HOST=mariadb:3306 | |
WORDPRESS_DB_TYPE=mysql | |
WORDPRESS_DB_PASSWORD=<a-wordpress-password> | |
WORDPRESS_DB_USER=wordpress | |
# 記得資料庫名稱需使用下底線(_)區隔 | |
WORDPRESS_DB_NAME=wordpress_site1 | |
WORDPRESS_FS_METHOD=direct | |
TZ=Asia/Taipei |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment