Files
server-core/serverrun/docker-compose.yml
T

111 lines
3.1 KiB
YAML
Raw 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.
# ============================================================
# 云超服 / YunOPC-Hub —— 三服务业务编排(主编排)
# opc-server (:8090,对外) ← 主 API / admin / website 后端 / 桌面更新源
# opc-im (:8101,内部) ← 即时通讯,由 opc-server 转发对外
# opc-compute (:3000,内部) ← 算力中转/计量,由 opc-server 代理
#
# 本文件只编排三个业务服务;基础设施(MySQL/Redis/EMQX)见
# mysql/、redis/、mqtt/ 子目录,先启动基础设施再加入同一外部网络。
#
# 前置:docker network create opc-network(基础设施与业务共用)
#
# 镜像在各自项目内构建(标准命名):
# server-core → opc-server:latest im-service → opc-im:latest compute → opc-compute:latest
#
# 用法(在本目录执行):
# cp .env.example .env # 填入 MySQL/Redis/MQTT/JWT 等实际值
# docker compose up -d --build # 首次构建并启动业务三服务
# docker compose logs -f # 查看日志
# ============================================================
services:
# ---------- 核心服务端(唯一对外) ----------
opc-server:
build:
context: ..
dockerfile: Dockerfile
image: opc-server:latest
container_name: opc-server
restart: unless-stopped
# 仅对外暴露 8090
ports:
- "8090:8090"
# 环境变量(三个容器共享本目录 .env;各服务只读取自己需要的变量)
env_file:
- .env
# 显式固定启动端口:env_file 会注入全部变量(含 compute 段的 PORT=3000),
# 显式覆盖避免误用;镜像入口已硬编码 8090,此处为兜底防御
environment:
PORT: "8090"
# 数据目录在项目 serverdataseed/、prompts/ 模板与运行时数据均落宿主机,便于修改即时生效)
volumes:
- ../serverdata:/app/serverdata
- ../uploads:/app/uploads
# 先于 im / compute 之后启动(服务名互访;应用侧有连接重试)
depends_on:
- opc-im
- opc-compute
deploy:
resources:
limits:
memory: 4G
networks:
- opc-network
# ---------- 即时通讯(容器内 :8101,不对外) ----------
opc-im:
build:
context: ../../im-service
dockerfile: Dockerfile
image: opc-im:latest
container_name: opc-im
restart: unless-stopped
env_file:
- .env
volumes:
- ../../im-service/serverdata:/app/serverdata
deploy:
resources:
limits:
memory: 1G
networks:
- opc-network
# ---------- 算力微服务(容器内 :3000,不对外) ----------
opc-compute:
build:
context: ../../compute
dockerfile: Dockerfile
image: opc-compute:latest
container_name: opc-compute
restart: unless-stopped
env_file:
- .env
volumes:
- ../../compute/serverdata:/app/serverdata
deploy:
resources:
limits:
memory: 1G
networks:
- opc-network
networks:
opc-network:
name: opc-network
external: true