From a206493f3b3460e21353cea5477eebbcc10c0301 Mon Sep 17 00:00:00 2001 From: _Tradam Date: Tue, 9 Sep 2025 16:18:52 +0900 Subject: init --- .gitignore | 3 +++ docker-compose.yml | 37 +++++++++++++++++++++++++++++++++++++ nginx.dockerfile | 4 ++++ nginx/default.conf | 41 +++++++++++++++++++++++++++++++++++++++++ php.dockerfile | 7 +++++++ readme.mdown | 25 +++++++++++++++++++++++++ 6 files changed, 117 insertions(+) create mode 100644 .gitignore create mode 100644 docker-compose.yml create mode 100644 nginx.dockerfile create mode 100755 nginx/default.conf create mode 100644 php.dockerfile create mode 100644 readme.mdown diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4831310 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +nginx/certs/ + +wordpress/ diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..e758950 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,37 @@ + +services: + nginx: + build: + context: . + dockerfile: nginx.dockerfile + depends_on: + - php + - mysql + ports: + - 80:80 + - 443:443 + volumes: + - ./wordpress:/var/www/html + + mysql: + image: mysql:latest + environment: + MYSQL_DATABASE: wp + MYSQL_USER: wp + MYSQL_PASSWORD: secret + MYSQL_ROOT_PASSWORD: secret + + php: + build: + context: . + dockerfile: php.dockerfile + volumes: + - ./wordpress:/var/www/html + + wp: + build: + context: . + dockerfile: php.dockerfile + volumes: + - ./wordpress:/var/www/html + entrypoint: ['wp', '--allow-root'] diff --git a/nginx.dockerfile b/nginx.dockerfile new file mode 100644 index 0000000..eab38f0 --- /dev/null +++ b/nginx.dockerfile @@ -0,0 +1,4 @@ +FROM nginx:stable-alpine + +ADD ./nginx/default.conf /etc/nginx/conf.d/default.conf +ADD ./nginx/certs /etc/nginx/certs/self-signed diff --git a/nginx/default.conf b/nginx/default.conf new file mode 100755 index 0000000..dd7534a --- /dev/null +++ b/nginx/default.conf @@ -0,0 +1,41 @@ +upstream php { + # Remove the unix socket line - it won't work between containers + server php:9000; +} + +server { + listen 80; + server_name 100.75.105.112; + root /var/www/html; + index index.php index.html; # Add this line + + location / { + try_files $uri $uri/ /index.php?$args; + } + + location ~ \.php$ { + include fastcgi.conf; + fastcgi_intercept_errors on; + fastcgi_pass php; + } +} + +server { + listen 443 ssl; + server_name ${NGINX_SERVER_NAME}; + root /var/www/html; + index index.php index.html; # Add this line + + location / { + try_files $uri $uri/ /index.php?$args; + } + + location ~ \.php$ { + include fastcgi.conf; + fastcgi_intercept_errors on; + fastcgi_pass php; + } + + ssl_certificate /etc/nginx/certs/self-signed/cert.pem; + ssl_certificate_key /etc/nginx/certs/self-signed/cert-key.pem; +} diff --git a/php.dockerfile b/php.dockerfile new file mode 100644 index 0000000..2a7db45 --- /dev/null +++ b/php.dockerfile @@ -0,0 +1,7 @@ +FROM php:8.4-fpm-alpine + +RUN docker-php-ext-install mysqli pdo pdo_mysql && docker-php-ext-enable pdo_mysql + +RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar + +RUN chmod +x wp-cli.phar && mv wp-cli.phar /usr/local/bin/wp diff --git a/readme.mdown b/readme.mdown new file mode 100644 index 0000000..387e992 --- /dev/null +++ b/readme.mdown @@ -0,0 +1,25 @@ +# WordPress Docker Developer Environment + +This is an easy to start environment designed for developing for WordPress. It spins up PHP, MySQL, and Nginx in an automated way. + +## Usage + +### Quickstart + +1. Download [WordPress](https://wordpress.org/latest.zip) and extract it into the top level of this Git repository. Name the directory wordpress. + +2. Run `docker-compose up -d --build` to build and start the server in the background. This runs WordPress on port 80 and 443. + +### Close + +- Run `docker-compose down` +- To do a reset: `docker-compose down --volumes` + +### wp-cli + +- To use wp-cli: `docker-compose run --rm wp user list` + +### HTTPS + - Create certs using [mkcert](https://github.com/FiloSottile/mkcert) and place them into the nginx/certs directory and name the files `cert.pem` and `cert-key.pem` + + -- cgit v1.2.3