You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
2.2 KiB

# version: '3.8'
# services:
# python:
# build:
# context: ./
# dockerfile: ./Dockerfile
# restart: always
# environment:
# - DATABASE_URL=postgresql://postgres:postgres@db:5432/mini12306_python
# - REDIS_URL=redis
# - SERVER_LIB_URL=http://py12306.learnerhub.net
# ports:
# - "3002:3002"
# depends_on:
# - db
# - redis
# volumes:
# - /var/log/mini12306_python:/app/logs
#
# redis:
# image: redis:alpine
# container_name: 12306_redis
# volumes:
# - redis_data:/data
#
# db:
# image: postgres:15
# container_name: 12306_postgres
# restart: always
# environment:
# POSTGRES_USER: postgres
# POSTGRES_PASSWORD: postgres
# POSTGRES_DB: mini12306_python
# volumes:
# - postgres_data:/var/lib/postgresql/data
#
#
# volumes:
# postgres_data:
# redis_data:
version: '3.8'
services:
python:
build:
context: ./
dockerfile: ./Dockerfile
restart: always
environment:
- DATABASE_URL=mysql+pymysql://root:123456@db:3306/mini12306_python # 修改数据库连接字符串
- REDIS_URL=redis
- SERVER_LIB_URL=http://py12306.learnerhub.net
ports:
- "3002:3002"
depends_on:
- db # 服务名保持不变,但已指向新的 MySQL 服务
- redis
volumes:
- /var/log/mini12306_python:/app/logs
redis:
image: redis:alpine
container_name: 12306_redis
volumes:
- redis_data:/data
db: # 修改后的 MySQL 服务
image: mysql:8.0 # 使用官方 MySQL 镜像
container_name: 12306_mysql # 修改容器名称
restart: always
environment:
MYSQL_ROOT_PASSWORD: 123456 # MySQL 根密码(建议修改)
MYSQL_DATABASE: mini12306_python # 自动创建的数据库
MYSQL_USER: app_user # 可选:创建专用用户
MYSQL_PASSWORD: user123 # 可选用户密码
volumes:
- mysql_data:/var/lib/mysql # MySQL 数据存储路径
# 建议添加的健康检查
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
interval: 5s
timeout: 5s
retries: 5
volumes:
mysql_data: # 修改卷名称
redis_data: