-
-
Save kiddtang/0cf9f8bd9e6dda41fb084d9ebcf7c521 to your computer and use it in GitHub Desktop.
Host WordPress on your Win 11 / 10 with Free Docker Desktop
This file contains 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=your_root_password | |
MYSQL_USER=your_wordpress_database_user | |
MYSQL_PASSWORD=your_wordpress_database_password |
This file contains 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' | |
services: | |
db: | |
image: mysql:8.0 | |
container_name: wp_db | |
restart: unless-stopped | |
env_file: .env | |
environment: | |
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} | |
MYSQL_DATABASE: wordpress | |
volumes: | |
- database:/var/lib/mysql | |
command: '--default-authentication-plugin=mysql_native_password' | |
networks: | |
- app-network | |
wordpress: | |
build: | |
context: ./.docker/wordpress | |
dockerfile: Dockerfile | |
depends_on: | |
- db | |
image: wordpress/myproj | |
container_name: wordpress | |
restart: unless-stopped | |
env_file: .env | |
environment: | |
WORDPRESS_DB_HOST: db:3306 | |
WORDPRESS_DB_USER: ${MYSQL_USER} | |
WORDPRESS_DB_PASSWORD: ${MYSQL_PASSWORD} | |
WORDPRESS_DB_NAME: wordpress | |
WORDPRESS_TABLE_PREFIX: my_wp_ | |
WORDPRESS_CONFIG_EXTRA: | | |
define( 'FS_METHOD', 'direct' ); | |
volumes: | |
- ./wordpress:/var/www/html | |
- ./.docker/wordpress/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini | |
networks: | |
- app-network | |
webserver: | |
build: | |
context: ./.docker/nginx | |
dockerfile: Dockerfile | |
depends_on: | |
- wordpress | |
- phpmyadmin | |
image: nginx/ssl | |
container_name: webserver | |
restart: unless-stopped | |
ports: | |
- "80:80" | |
- "${WP_PORT:-443}:443" | |
- "${MYADMIN_PORT:-8080}:8080" | |
volumes: | |
- ./wordpress:/var/www/html/wordpress | |
- phpmyadmin:/var/www/html/phpmyadmin | |
- ./nginx-conf:/etc/nginx/conf.d | |
networks: | |
app-network: | |
aliases: | |
- localhost | |
phpmyadmin: | |
depends_on: | |
- db | |
image: phpmyadmin/phpmyadmin:fpm-alpine | |
container_name: phpmyadmin | |
restart: always | |
env_file: .env | |
environment: | |
PMA_HOST: db | |
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} | |
volumes: | |
- phpmyadmin:/var/www/html | |
networks: | |
- app-network | |
volumes: | |
phpmyadmin: | |
driver: local | |
database: | |
driver: local | |
networks: | |
app-network: | |
driver: bridge |
This file contains 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
FROM nginx:stable-alpine | |
RUN apk --update --no-cache add openssl | |
RUN mkdir -p /etc/nginx/certs/ /etc/nginx/certs/private/ | |
RUN openssl req -x509 -nodes -days 365 -subj "/C=CA/ST=QC/O=Tplus, Inc./CN=localhost" \ | |
-addext "subjectAltName=DNS:localhost" -newkey rsa:2048 \ | |
-keyout /etc/nginx/certs/private/self-signed.key \ | |
-out /etc/nginx/certs/self-signed.crt; |
This file contains 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
FROM wordpress:5-fpm-alpine | |
RUN apk --no-cache add shadow && usermod -u 1000 www-data |
This file contains 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
server { | |
listen 80; | |
listen [::]:80; | |
server_name _; | |
location / { | |
rewrite ^ https://$host$request_uri? permanent; | |
} | |
} | |
server { | |
listen 443 ssl http2; | |
listen [::]:443 ssl http2; | |
server_name _; | |
index index.php index.html index.htm; | |
root /var/www/html/wordpress; | |
include conf.d/security.conf; | |
client_max_body_size 512M; | |
location / { | |
try_files $uri $uri/ /index.php$is_args$args; | |
} | |
location ~ \.php$ { | |
try_files $uri =404; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_pass wordpress:9000; | |
fastcgi_index index.php; | |
include fastcgi_params; | |
fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name; | |
fastcgi_param PATH_INFO $fastcgi_path_info; | |
fastcgi_read_timeout 600; | |
} | |
location ~ /\.ht { | |
deny all; | |
} | |
location = /favicon.ico { | |
log_not_found off; access_log off; | |
} | |
location = /robots.txt { | |
log_not_found off; access_log off; allow all; | |
} | |
location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ { | |
expires max; | |
log_not_found off; | |
} | |
} | |
server { | |
listen 8080 ssl http2; | |
listen [::]:8080 ssl http2; | |
server_name _; | |
index index.php index.html index.htm; | |
root /var/www/html/phpmyadmin; | |
include conf.d/security.conf; | |
client_max_body_size 512M; | |
location / { | |
try_files $uri $uri/ /index.php$is_args$args; | |
} | |
location ~ \.php$ { | |
try_files $uri =404; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_pass phpmyadmin:9000; | |
fastcgi_index index.php; | |
include fastcgi_params; | |
fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name; | |
fastcgi_param PATH_INFO $fastcgi_path_info; | |
fastcgi_read_timeout 600; | |
} | |
location ~ /\.ht { | |
deny all; | |
} | |
location = /favicon.ico { | |
log_not_found off; access_log off; | |
} | |
location = /robots.txt { | |
log_not_found off; access_log off; allow all; | |
} | |
location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ { | |
expires max; | |
log_not_found off; | |
} | |
} |
This file contains 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
server_tokens off; | |
ssl_certificate /etc/nginx/certs/self-signed.crt; | |
ssl_certificate_key /etc/nginx/certs/private/self-signed.key; | |
ssl_protocols TLSv1.2 TLSv1.3; | |
ssl_prefer_server_ciphers off; | |
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384; | |
ssl_ecdh_curve secp384r1; | |
ssl_session_timeout 10m; | |
ssl_session_cache shared:SSL:10m; | |
ssl_session_tickets off; | |
add_header X-Frame-Options "SAMEORIGIN" always; | |
add_header X-Content-Type-Options "nosniff" always; | |
add_header X-XSS-Protection "1; mode=block" always; | |
add_header Referrer-Policy "no-referrer-when-downgrade" always; | |
add_header Content-Security-Policy "default-src * data: 'unsafe-eval' 'unsafe-inline'" always; |
This file contains 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
file_uploads = On | |
memory_limit = 500M | |
upload_max_filesize = 500M | |
post_max_size = 500M | |
max_execution_time = 600 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment