diff --git a/.gitignore b/.gitignore index 2f57761..e336ca4 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,6 @@ /backend/package-lock.json /frontend/package-lock.json /frontend/dist -plan.md \ No newline at end of file +plan.md +info.md +docker-compose.self.yml \ No newline at end of file diff --git a/compose.env b/compose.env new file mode 100644 index 0000000..5408736 --- /dev/null +++ b/compose.env @@ -0,0 +1,12 @@ +# MySQL/MariaDB Settings +MYSQL_ROOT_PASSWORD=123456 +MYSQL_DATABASE=maildb +MYSQL_USER=root +MYSQL_PASSWORD=123456 + +# Backend Database Settings +# These should match the MySQL/MariaDB settings above +DB_HOST=mysql +DB_USER=${MYSQL_USER} +DB_PASSWORD=${MYSQL_PASSWORD} +DB_NAME=${MYSQL_DATABASE} \ No newline at end of file diff --git a/docker-compose-full.yml b/docker-compose-full.yml index f53973f..c92e8f3 100644 --- a/docker-compose-full.yml +++ b/docker-compose-full.yml @@ -1,5 +1,3 @@ -version: '3.3' - services: # 1. 后端服务 (Node.js + Express + SMTP Server) backend: diff --git a/docker-compose.yml b/docker-compose.yml index 94bc1cd..0c34731 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,19 +1,33 @@ services: + # 1. 后端服务 (Node.js + Express + SMTP Server) backend: build: ./backend - container_name: email-backend-container + container_name: email-backend restart: always - ports: - - "5182:5182" # API port - - "25:25" # SMTP port - environment: - - DB_HOST=43.143.145.172 # 替换为您的外部数据库主机名或IP - - DB_USER=root # 替换为您的数据库用户名 - - DB_PASSWORD=kyff145972 # 替换为您的数据库密码 - - DB_NAME=maildb # 替换为您的数据库名称 + env_file: + - compose.full.env + networks: + - email-network + # 可根据需要暴露端口给外部 + # ports: + # - "5182:5182" + # - "25:25" + + # 2. 数据库服务 (MySQL) + mysql: + image: mysql:8.0 + container_name: email-mysql + restart: always + env_file: + - compose.env + volumes: + - mysql-data:/var/lib/mysql networks: - email-network networks: email-network: - driver: bridge \ No newline at end of file + driver: bridge + +volumes: + mysql-data: {}