Files
ai-app-database/.env.external-db.example
huty 3ad430e3e3 feat: 添加 Docker 容器化部署支持
支持两种部署模式,兼容新建 MySQL 和现有 MySQL:

- Dockerfile:Python 3.12-slim 两阶段构建,非 root 运行
- docker-compose.yml:全栈模式(含 MySQL 8.0 + 可选 Nginx)
- docker-compose.external-db.yml:接入现有 MySQL 模式
- docker/entrypoint.sh:自动等待 DB 就绪 → 初始化表 → 启动 Gunicorn
- docker/nginx.conf:反向代理 + 静态文件直出 + 安全响应头
- .env.docker.example / .env.external-db.example:各模式配置示例
- .gitattributes:确保 entrypoint.sh 在 Windows 上保持 LF 换行

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-23 00:38:14 +09:00

46 lines
2.5 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ═══════════════════════════════════════════════════════════════
# 模式二:使用现有 MySQL外部数据库
# 使用方式cp .env.external-db.example .env.external-db
# 编辑后执行:
# docker compose -f docker-compose.external-db.yml \
# --env-file .env.external-db up -d
# ═══════════════════════════════════════════════════════════════
# ── 应用安全 ────────────────────────────────────────────────────
SECRET_KEY=change-this-to-a-very-long-random-string-in-production
# ── 外部数据库连接(修改为实际连接信息)─────────────────────────
# 格式mysql+pymysql://用户名:密码@主机:端口/数据库名
#
# 示例 1 - 本项目现有数据库:
# DATABASE_URL=mysql+pymysql://resource_library:BWRVzzCwzuuP_1Hj@pma.hty1024.com:31000/resource_library
#
# 示例 2 - 宿主机 MySQL容器访问宿主机使用 host.docker.internal
# DATABASE_URL=mysql+pymysql://resource_library:password@host.docker.internal:3306/resource_library
#
# 示例 3 - 标准端口的云数据库:
# DATABASE_URL=mysql+pymysql://user:password@your-rds.amazonaws.com:3306/resource_library
DATABASE_URL=mysql+pymysql://resource_library:your_password@your_db_host:3306/resource_library
# 等待数据库就绪的超时时间(秒)
DB_WAIT_SECONDS=30
# ── 管理员账号(首次启动自动创建,已存在则跳过)────────────────
ADMIN_USERNAME=admin
ADMIN_PASSWORD=Admin@123456
ADMIN_EMAIL=admin@example.com
# ── 应用配置 ────────────────────────────────────────────────────
FLASK_ENV=production
APP_PORT=5000
MAX_UPLOAD_SIZE_MB=500
LOG_LEVEL=info
# ── Gunicorn ────────────────────────────────────────────────────
GUNICORN_WORKERS=4
GUNICORN_TIMEOUT=120
# ── Nginx--profile nginx 时生效)──────────────────────────────
NGINX_HTTP_PORT=80
NGINX_HTTPS_PORT=443