feat: Implement containerized deployment with frontend/backend separation

This commit is contained in:
super committed 2026-03-03 10:22:15 +08:00
1 parent 2b8a0010ef
commit f18b6ce2df
5 files changed
+103 -136

No files matched your search

+39 -21
View File
@@ -1,31 +1,49 @@
version: '3.8'
services:
backend:
build: ./backend
# ==============================================================================
# hxops-backend: Flask 后端服务 (端口: 5000)
# ==============================================================================
hxops-backend:
build:
context: ./backend
dockerfile: Dockerfile
container_name: hxops-backend
restart: always
environment:
# 数据库连接 (指向宿主机或其他容器,请根据实际环境修改)
- DATABASE_URL=postgresql://postgres:difyai123456@192.168.100.230:5432/hxops_prod
# Flask 配置
- FLASK_APP=run.py
- FLASK_ENV=production
# 注意:在宿主机上通过 host.docker.internal 访问宿主机服务(仅限 Docker Desktop for Mac/Windows)
# Linux 服务器上通常用 172.17.0.1 或宿主机 IP
# 这里预填服务器 IP
- DATABASE_URL=postgresql://postgres:difyai123456@192.168.100.230:5432/hxops_prod
- REDIS_URL=redis://:difyai123456@192.168.100.230:6379/0
- DIFY_API_BASE=http://192.168.100.230:8882/v1
# 请在 .env 文件中配置 DIFY_API_KEY
volumes:
- ./backend:/app
expose:
- "8000"
# 允许容器访问宿主机服务 (如数据库)
extra_hosts:
- "host.docker.internal:host-gateway"
# 如果需要在宿主机调试,可暴露端口;生产环境建议只在网络内暴露
ports:
- "5000:5000"
networks:
- ai-platform
frontend:
build: ./frontend
# ==============================================================================
# hxops-frontend: Vue 前端静态资源 + Nginx 反向代理 (端口: 80)
# ==============================================================================
hxops-frontend:
build:
context: ./frontend
dockerfile: Dockerfile
container_name: hxops-frontend
restart: always
ports:
- "8881:80"
depends_on:
- backend
- hxops-backend
# 前端容器暴露 80 端口,映射到宿主机 8888 (或其他端口供 nginx-gateway 访问)
ports:
- "8888:80"
networks:
- ai-platform
# ==============================================================================
# 网络配置
# ==============================================================================
networks:
ai-platform:
name: ai-platform
driver: bridge