Files
junhong_cmp_fiber/docker/entrypoint-api.sh
break cb26217205 让七月迭代具备可直接部署的配置基线
补齐三套环境配置、测试环境部署门禁与 system_config 初始化,并按当前无企微应用的约束将企微凭据改为明文存储。

Constraint: 当前测试环境尚无企微应用及历史企微密文数据

Rejected: 使用启动环境变量加密企微凭据 | 用户明确要求直接明文保存并移除加密密钥

Confidence: high

Scope-risk: moderate

Directive: 企微真实闭环完成前保持两个旧审批入口开关为 true

Tested: gofmt;git diff --check;bash -n;docker compose config;Gitea workflow YAML 解析;OpenAPI 重新生成

Not-tested: go test;常规 go build;LSP;实际数据库迁移;真实测试环境部署;企微真实联调
2026-07-25 18:18:45 +08:00

40 lines
1.2 KiB
Bash
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.
#!/bin/bash
set -e
echo "========================================="
echo "君鸿卡管系统 API 服务启动中..."
echo "========================================="
# 构建数据库连接 URL从环境变量读取
# 环境变量由 docker-compose 传入,格式为 JUNHONG_DATABASE_*
DB_HOST="${JUNHONG_DATABASE_HOST:-localhost}"
DB_PORT="${JUNHONG_DATABASE_PORT:-5432}"
DB_USER="${JUNHONG_DATABASE_USER:-postgres}"
DB_PASSWORD="${JUNHONG_DATABASE_PASSWORD:-}"
DB_NAME="${JUNHONG_DATABASE_DBNAME:-junhong_cmp}"
DB_SSLMODE="${JUNHONG_DATABASE_SSLMODE:-disable}"
DB_URL="postgresql://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}?sslmode=${DB_SSLMODE}"
echo "检查数据库连接..."
for i in {1..30}; do
if migrate -path /app/migrations -database "$DB_URL" version > /dev/null 2>&1; then
echo "数据库连接成功"
break
fi
echo "等待数据库就绪... ($i/30)"
sleep 1
done
echo "执行数据库迁移..."
if migrate -path /app/migrations -database "$DB_URL" up; then
echo "数据库迁移完成"
else
echo "错误: 数据库迁移失败,拒绝使用旧结构启动 API"
exit 1
fi
echo "启动 API 服务..."
echo "========================================="
exec /app/api