From 4024f91cafb8b452dfef83729ccc268693ad3293 Mon Sep 17 00:00:00 2001 From: siujamo Date: Thu, 30 Jul 2026 14:22:59 +0800 Subject: [PATCH] feat(mysql): add MySQL 8 Alpine compose file - Add docker-compose.yaml with MYSQL_ROOT_PASSWORD, MYSQL_DATABASE, MYSQL_USER, and MYSQL_PASSWORD environment variables - Add .env.example with documented defaults --- compose/mysql/.env.example | 16 ++++++++++++++ compose/mysql/docker-compose.yaml | 36 +++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 compose/mysql/.env.example create mode 100644 compose/mysql/docker-compose.yaml diff --git a/compose/mysql/.env.example b/compose/mysql/.env.example new file mode 100644 index 0000000..0813b48 --- /dev/null +++ b/compose/mysql/.env.example @@ -0,0 +1,16 @@ +# MySQL (Alpine) — environment variables +# Copy this file to .env and adjust values for your environment. + +# Root password. +# The default is for local development only — always change for production. +MYSQL_ROOT_PASSWORD=mysql + +# Database created automatically on first start (default: mysql). +MYSQL_DATABASE=mysql + +# Additional user created automatically on first start (default: root). +MYSQL_USER=root + +# Password for the additional user. +# The default is for local development only — always change for production. +MYSQL_PASSWORD=mysql diff --git a/compose/mysql/docker-compose.yaml b/compose/mysql/docker-compose.yaml new file mode 100644 index 0000000..1359054 --- /dev/null +++ b/compose/mysql/docker-compose.yaml @@ -0,0 +1,36 @@ +# Docker Compose file for MySQL (Alpine) +# +# Usage: +# docker compose up -d +# +# Environment variables (see .env.example for details): +# MYSQL_ROOT_PASSWORD - Root password (default: mysql) +# MYSQL_DATABASE - Database created on first start (default: mysql) +# MYSQL_USER - Additional user created on first start (default: root) +# MYSQL_PASSWORD - Password for the additional user (default: mysql) + +services: + mysql: + # For available image tags, see https://hub.docker.com/_/mysql + image: mysql:8-alpine + container_name: mysql + environment: + # Root password. + # Default value is for local development only — change for production. + - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-mysql} + # Database created automatically on first start. + - MYSQL_DATABASE=${MYSQL_DATABASE:-mysql} + # Additional user created automatically on first start. + - MYSQL_USER=${MYSQL_USER:-root} + # Password for the additional user. + # Default value is for local development only — change for production. + - MYSQL_PASSWORD=${MYSQL_PASSWORD:-mysql} + ports: + # Map host port 3306 to container port 3306 (MySQL default). + - "3306:3306" + volumes: + # Persist data beyond container lifetime. + - mysql_data:/var/lib/mysql + +volumes: + mysql_data: