57 lines
1.3 KiB
YAML
57 lines
1.3 KiB
YAML
version: '3.8'
|
||
|
||
services:
|
||
app:
|
||
build:
|
||
context: ..
|
||
dockerfile: docker/Dockerfile
|
||
restart: always
|
||
ports:
|
||
- "50400:50400"
|
||
depends_on:
|
||
- db
|
||
environment:
|
||
# 应用配置
|
||
- FLASK_CONFIG=production
|
||
- SECRET_KEY=change-me-in-production
|
||
|
||
# 数据库配置 - 两种选择之一:
|
||
|
||
# 选项1:使用Docker内置MySQL(取消下面的注释启用)
|
||
# - MYSQL_HOST=db
|
||
# - MYSQL_USER=taibai
|
||
# - MYSQL_PASSWORD=taibaishopping
|
||
# - MYSQL_DB=shopping_db
|
||
# - MYSQL_PORT=3306
|
||
|
||
# 选项2:使用现有外部数据库(默认)
|
||
# 保持上面的选项1注释即可使用配置文件中的默认设置
|
||
volumes:
|
||
- ../logs:/app/logs
|
||
- ../app/static/uploads:/app/app/static/uploads
|
||
networks:
|
||
- app-network
|
||
|
||
db:
|
||
image: mysql:8.0
|
||
restart: always
|
||
environment:
|
||
- MYSQL_DATABASE=online_shopping
|
||
- MYSQL_USER=taibai
|
||
- MYSQL_PASSWORD=taibaishopping
|
||
- MYSQL_ROOT_PASSWORD=root_password_here
|
||
volumes:
|
||
- mysql-data:/var/lib/mysql
|
||
ports:
|
||
- "3366:3306" # 使用3366避免与主机MySQL端口冲突
|
||
networks:
|
||
- app-network
|
||
command: --default-authentication-plugin=mysql_native_password
|
||
|
||
networks:
|
||
app-network:
|
||
driver: bridge
|
||
|
||
volumes:
|
||
mysql-data:
|