version: '3.8' services: mysql: image: mysql:8.0 container_name: smart_mysql restart: unless-stopped # 환경 변수 environment: MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-1q2w3e4r} MYSQL_DATABASE: ${MYSQL_DATABASE:-smarteyessen_db} # 선택적: 추가 사용자 생성 # MYSQL_USER: smarteye_user # MYSQL_PASSWORD: smarteye_pass # 포트 매핑 ports: - "${MYSQL_PORT:-3308}:3306" # MySQL 서버 설정 (UTF-8 강제) command: - --character-set-server=utf8mb4 - --collation-server=utf8mb4_unicode_ci - --default-authentication-plugin=mysql_native_password - --max-connections=200 - --sql-mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION # 데이터 지속성 (Named Volume 사용) volumes: - smart_mysql_data:/var/lib/mysql # 초기화 스크립트 (컨테이너 최초 실행 시 자동 실행) - ./scripts/init_db_complete.sql:/docker-entrypoint-initdb.d/01_init.sql:ro # 헬스체크 healthcheck: test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p1q2w3e4r"] interval: 10s timeout: 5s retries: 5 # 네트워크 networks: - smarteye_network # Named Volume 정의 volumes: smart_mysql_data: name: smart_mysql_data driver: local # 네트워크 정의 networks: smarteye_network: name: smarteye_network driver: bridge