unis-oa/docker-compose.yml

75 lines
3.6 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# =============================================================================
# UnisOA 单机部署(docker compose)
# -----------------------------------------------------------------------------
# 先把生产配置放到 ./deploy/config/ 里:
# config.prod.toml 照 backend/config.prod.toml.example 填(库、密钥、Hub、MinIO)
# config.toml 可以不写;要写就只写 [env] name = "prod" 这种覆盖项
# 然后:
# docker compose up -d --build
# docker compose logs -f | head # 看 config: 环境=prod 那行
# docker compose exec unisoa-api python scripts/what_config.py # 自查读的哪几份
#
# 档位开关在这里(OA_ENV);不想用变量就删掉那行,改挂载目录里的 [env] name。
# 配置目录只读挂载:容器改不了宿主上的密钥文件。
# =============================================================================
services:
unisoa-api:
build:
context: .
# 国内网络走镜像源快很多;境外构建把这两行删掉即可(默认是 npmjs / pypi 官方源)
args:
NPM_REGISTRY: https://registry.npmmirror.com
PIP_INDEX_URL: https://pypi.tuna.tsinghua.edu.cn/simple
image: unisoa:latest
container_name: unisoa-api
environment:
OA_ENV: prod # 用哪一档;对应 /etc/unisoa/config.prod.toml
TZ: Asia/Shanghai # 定时同步与审批超时都按这个时区算
# OA_DB_PASSWORD: "" # 不想把口令写进配置文件就在这里注入(最高优先级)
# OA_JWT_SECRET: ""
# 免登两件套也可以走这里(环境变量压过配置文件与界面),密钥就不落在宿主文件上:
# 三项(站点地址 + 应用编码 + 免登应用密钥)任一途径凑齐免登才开,缺一项回调一律
# 302 回落地页报 SSO_DISABLED;凑齐没有看 GET /api/v1/hub/status 的 sso.missing
# OA_HUB_APP_CODE: "oa"
# OA_HUB_INTEGRATION_KEY: ""
volumes:
- ./deploy/config:/etc/unisoa:ro # 配置目录(密钥只在这儿)
- unisoa-storage:/app/backend/storage # 网盘文件与 MinIO 故障兜底的落盘处
ports:
- "8000:8000"
restart: unless-stopped
healthcheck:
test:
- CMD
- python
- -c
- "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/api/v1/settings/public', timeout=4)"
interval: 30s
timeout: 5s
retries: 3
start_period: 90s
# -----------------------------------------------------------------------------
# 可选:共享缓存与限流(Redis)。单副本用不着,留着注释就是默认不启用的意思——
# 后端读的是 config.prod.toml 的 [redis],地址留空时这一层整个不参与,
# 缓存退回各进程自己那份、限流退回查库计数(见 docs/redis-integration.md)。
# 要打开:去掉下面这段注释,再把 /etc/unisoa/config.prod.toml 的
# [redis] host 写成 redis(compose 里的服务名)、key_prefix 按环境分开,
# 口令走 OA_REDIS_PASSWORD 注进来;起服务后看 GET /api/v1/system/redis 的 active。
# -----------------------------------------------------------------------------
# redis:
# image: redis:7-alpine
# container_name: unisoa-redis
# # 要口令就在后面追加 --requirepass <口令>,并与配置文件里的 [redis] password 对上
# command: ["redis-server", "--appendonly", "yes"]
# ports:
# - "127.0.0.1:6379:6379"
# volumes:
# - unisoa-redis:/data
# restart: unless-stopped
volumes:
unisoa-storage:
# unisoa-redis: