fix: 修复并优化部署流程 #74

Merged
huanghaosheng merged 4 commits from fix/workflow-fix into develop 2026-06-14 14:56:52 +08:00
5 changed files with 0 additions and 28 deletions
Showing only changes of commit 4ef1e9f08b - Show all commits

View File

@@ -27,7 +27,6 @@ require (
github.com/go-playground/validator/v10 v10.20.0 // indirect
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/joho/godotenv v1.5.1 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.10 // indirect
github.com/leodido/go-urn v1.4.0 // indirect

View File

@@ -44,8 +44,6 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=

View File

@@ -5,7 +5,6 @@ import (
"os"
"strings"
"github.com/joho/godotenv"
"github.com/spf13/viper"
)
@@ -161,12 +160,6 @@ func Load() (*Config, error) {
_ = v.MergeInConfig()
}
// 加载 .env 文件(不覆盖已有环境变量)
// 按优先级尝试:当前目录、上级目录(兼容从 backend/ 或项目根目录启动)
_ = godotenv.Load()
_ = godotenv.Load("../.env")
_ = godotenv.Load("../../.env") // 兼容从 backend/cmd/server/ 启动
// 环境变量覆盖
v.SetEnvPrefix("CAMTALK")
v.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))

View File

@@ -14,21 +14,6 @@ info() { echo -e "${GREEN}[INFO]${NC} $*"; }
warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }
error() { echo -e "${RED}[ERROR]${NC} $*" >&2; }
# 确保 .env 存在
ensure_env() {
if [ ! -f .env ]; then
if [ -f .env.example ]; then
warn ".env 文件不存在,从 .env.example 复制模板"
cp .env.example .env
warn "请编辑 .env 填入实际的 API Key然后重新运行"
exit 1
else
error ".env.example 也不存在,请手动创建 .env"
exit 1
fi
fi
}
cmd_build() {
info "构建 Docker 镜像..."
docker compose build
@@ -36,7 +21,6 @@ cmd_build() {
}
cmd_up() {
ensure_env
info "启动服务..."
docker compose up -d
info "服务已启动"

View File

@@ -17,8 +17,6 @@ services:
context: ./backend
dockerfile: Dockerfile
container_name: camtalk-backend
env_file:
- .env
environment:
- APP_ENV=production
networks: