Skip to content

Instantly share code, notes, and snippets.

@texeltexel2009
Last active April 23, 2018 11:26
Show Gist options
  • Save texeltexel2009/890a896fc6546edd3d6b482730d56a50 to your computer and use it in GitHub Desktop.
Save texeltexel2009/890a896fc6546edd3d6b482730d56a50 to your computer and use it in GitHub Desktop.
Docker Compose - Wordpress Existing Basic with .ENV file
version: "3"
volumes:
wp-db-data:
services:
wp-db:
image: mysql:5.7
container_name: ww-mysql
# Load environment variables
env_file: .env
volumes:
# Data persistence
- wp-db-data:/var/lib/mysql
ports:
# For external access
- 3306:3306
environment:
# Load DB data from env file
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
MYSQL_DATABASE: ${DB_NAME}
MYSQL_USER: ${DB_USER}
MYSQL_PASSWORD: ${DB_PASSWORD}
# More upload size and avoiding common MySQL issues
command: --max_allowed_packet=8M --sql_mode=""
wp-app:
# Load latest wordpress image
image: wordpress:latest
container_name: ww-app
# Load environment variables
env_file: .env
volumes:
# Mount current existing Wordpress site in public folder
- .:/var/www/html
depends_on:
# Connect with DB container
- wp-db
ports:
# Expose port
- "80:80"
restart: always
environment:
# DB connection info from environment variables
WORDPRESS_DB_HOST: wp-db:3306
WORDPRESS_DB_NAME: ${DB_NAME}
WORDPRESS_DB_USER: ${DB_USER}
WORDPRESS_DB_PASSWORD: ${DB_PASSWORD}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment