Created
June 13, 2020 01:02
-
-
Save jakecobley/2842a1799a849ad96d2fa9577d7387e6 to your computer and use it in GitHub Desktop.
WordPress development environment using Docker & Docker Compose.
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
################################################################################ | |
# Docker | |
################################################################################ | |
.dockerignore | |
docker-compose* | |
Dockerfile* | |
################################################################################ | |
# Git | |
################################################################################ | |
.git | |
.gitattributes | |
.gitignore | |
.keep | |
################################################################################ | |
# EditorConfig | |
################################################################################ | |
.editorconfig | |
################################################################################ | |
# Miscellaneous | |
################################################################################ | |
CHANGELOG.md | |
README.md |
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
################################################################################ | |
# Database (MYSQL): Wordpress | |
################################################################################ | |
MYSQL_ROOT_PASSWORD=password | |
DATABASE_NAME=wordpress | |
DATABASE_USER=wordpress | |
DATABASE_PASSWORD=password |
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: | |
database: | |
container_name: database | |
image: mysql:5.7 | |
volumes: | |
- ./database:/docker-entrypoint-initdb.d | |
- "database_data:/var/lib/mysql" | |
ports: | |
- "3306:3306" | |
environment: | |
MYSQL_ROOT_PASSWORD: "${MYSQL_ROOT_PASSWORD}" | |
MYSQL_DATABASE: "${DATABASE_NAME}" | |
MYSQL_USER: "${DATABASE_USER}" | |
MYSQL_PASSWORD: "${DATABASE_PASSWORD}" | |
wordpress: | |
container_name: wordpress | |
depends_on: | |
- database | |
image: wordpress:latest | |
ports: | |
- "80:80" | |
environment: | |
WORDPRESS_DB_HOST: database:3306 | |
WORDPRESS_DB_NAME: "${DATABASE_NAME}" | |
WORDPRESS_DB_USER: "${DATABASE_USER}" | |
WORDPRESS_DB_PASSWORD: "${DATABASE_PASSWORD}" | |
volumes: | |
- ./wordpress:/var/www/html | |
volumes: | |
database_data: |
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
#!/bin/bash | |
DATETIME=$(date +"%Y-%m-%dT%T") | |
MYSQL_ROOT_PASSWORD=$(grep MYSQL_ROOT_PASSWORD .env | cut -d '=' -f 2-) | |
DATABASE_NAME=$(grep DATABASE_NAME .env | cut -d '=' -f 2-) | |
docker exec database /usr/bin/mysqldump -u root --password=$MYSQL_ROOT_PASSWORD $DATABASE_NAME > ./database/$DATABASE_NAME-$DATETIME.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment