Skip to content

Instantly share code, notes, and snippets.

@bcantoni
Created October 25, 2019 01:28
Show Gist options
  • Save bcantoni/b31899cab5c368ca7ee856c50783e6f6 to your computer and use it in GitHub Desktop.
Save bcantoni/b31899cab5c368ca7ee856c50783e6f6 to your computer and use it in GitHub Desktop.
Docker Powered WordPress
version: '3.3'
services:
db:
container_name: db
image: mariadb:10.4.6
ports:
- "3306:3306"
volumes:
- db_data2:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
volumes:
- "./data/migrate:/docker-entrypoint-initdb.d/"
wordpress:
container_name: wordpress
depends_on:
- db
build:
context: .
dockerfile: Dockerfile
image: wp_cantoni:latest
ports:
- "8000:80"
restart: always
environment:
WP_HOST_OVERRIDE: 192.168.99.100:8000
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
WORDPRESS_CONFIG_EXTRA: |
define('CORE_UPGRADE_SKIP_NEW_BUNDLED', true);
define('AUTOMATIC_UPDATER_DISABLED', true);
volumes:
db_data2: {}
FROM wordpress:5.2.4-php7.2-apache
# replace stock plugins/themes with our own
RUN rm -rf /var/www/html/wp-content/{plugins,themes}
COPY --chown=www-data:www-data ./src /var/www/html/wp-content
.PHONY: help up down clean bash html data rsync
.DEFAULT_GOAL := help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
up: ## bring up docker nodes including building if needed
docker-compose up --build -d
down: ## bring down docker nodes
docker-compose down
clean: down ## clean up unused docker things
docker volume prune -f
bash: ## bash shell into wordpress container
docker-compose exec wordpress bash
html: ## export WP html directory from container
rm -rf html || mkdir html
docker cp wordpress:/var/www/html html
rm html/wp-config.php
rm -rf html/wp-content/plugins/hello.php html/wp-content/plugins/akismet
data: ## fetch recent live WP database for local use
./fetch-wp-data
rsync: ## rsync data up to live cantoni.org host
echo "do this"
echo "rsync -avzc html/* cantoni.org:public_html/wp/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment