Skip to content

Instantly share code, notes, and snippets.

@duaneleem
Last active January 20, 2018 06:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save duaneleem/ff47ecb145d3214dbf1d31d8637f5a3f to your computer and use it in GitHub Desktop.
Save duaneleem/ff47ecb145d3214dbf1d31d8637f5a3f to your computer and use it in GitHub Desktop.
Used to create a development (or production) environment of WordPress using the official Docker WP from the store. One huge plus to this if you decide to use it for development, check out the .htaccess file. It rewrites requests to the /wp-content/uploads folder so you don't have to add that to your dev environment :) I opened the MySQL port to …
# ================================================================================
# Redirects uploads to production.
# ================================================================================
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^wp-content/uploads/(.*)$ https://www.some-website.com/wp-content/uploads/$1 [R=301,NC,L]
</IfModule>
# ================================================================================
# Docker WordPress
# ================================================================================
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
version: '3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
ports:
- "3406:3306"
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress_user
MYSQL_PASSWORD: wordpress_password
wordpress:
depends_on:
- db
image: wordpress:4.9.1-php7.0-apache
volumes:
- "./wp-content/themes:/var/www/html/wp-content/themes"
- "./wp-content/plugins:/var/www/html/wp-content/plugins"
- "./wp-content/uploads:/var/www/html/wp-content/uploads"
- "./.htaccess:/var/www/html/.htaccess"
ports:
- "8080:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress_user
WORDPRESS_DB_PASSWORD: wordpress_password
volumes:
db_data:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment