services: # Database Service (MySQL) db: image: mysql:5.7 # Using MySQL 5.7 for broad compatibility with WP 5.8 volumes: - ./database:/var/lib/mysql # Persist database data in a named volume environment: MYSQL_ROOT_PASSWORD: 'hackmelocal' MYSQL_DATABASE: 'wordpress' MYSQL_USER: 'wordpress' MYSQL_PASSWORD: 'hackmelocal' restart: unless-stopped # WordPress Service wordpress: # Build the image from the Dockerfile in the current directory (.) build: context: . dockerfile: Dockerfile # This service depends on the 'db' service to be running first depends_on: - db # Mount the entire repository into the container's web root # This allows you to edit files in Codespaces and see changes live volumes: - ./app:/var/www/html ports: - "8080:80" # Map port 8080 on the host to port 80 in the container environment: WORDPRESS_DB_HOST: 'db:3306' # Use the service name 'db' as the hostname WORDPRESS_DB_USER: 'wordpress' WORDPRESS_DB_PASSWORD: 'hackmelocal' WORDPRESS_DB_NAME: 'wordpress' WORDPRESS_DEBUG: 1 # Enable debug mode for development restart: unless-stopped # Named volume for persisting database data across container restarts volumes: db_data: