diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index be03ffc..29881e6 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -12,12 +12,6 @@ jobs: if: github.event_name == 'pull_request' runs-on: aliyun steps: - - name: Setup Dependencies - run: | - sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories - apk add --no-cache nodejs docker docker-cli-compose - dockerd & - - name: Checkout uses: "http://8.161.227.145:3000/huanghaosheng/checkout@releases/v4" @@ -36,12 +30,6 @@ jobs: if: github.event_name == 'push' runs-on: aliyun steps: - - name: Setup Dependencies - run: | - sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories - apk add --no-cache nodejs docker docker-cli-compose - dockerd & - - name: Checkout uses: "http://8.161.227.145:3000/huanghaosheng/checkout@releases/v4" @@ -50,16 +38,3 @@ jobs: chmod +x deploy.sh ./deploy.sh build ./deploy.sh restart - - - name: Health Check - run: | - for i in $(seq 1 10); do - if curl -sf http://localhost/api/health > /dev/null 2>&1; then - echo "服务启动成功" - exit 0 - fi - echo "等待服务启动... ($i/10)" - sleep 3 - done - echo "服务启动超时" - exit 1 diff --git a/backend/.dockerignore b/backend/.dockerignore new file mode 100644 index 0000000..3e17d9d --- /dev/null +++ b/backend/.dockerignore @@ -0,0 +1,9 @@ +bin +tmp +.git +.gitignore +*.md +.env* +.vscode +.idea +vendor diff --git a/backend/go.mod b/backend/go.mod index 31577ab..8e60b15 100644 --- a/backend/go.mod +++ b/backend/go.mod @@ -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 diff --git a/backend/go.sum b/backend/go.sum index 17b84e6..01eeeb8 100644 --- a/backend/go.sum +++ b/backend/go.sum @@ -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= diff --git a/backend/internal/config/config.go b/backend/internal/config/config.go index aff3a8e..e0937a8 100644 --- a/backend/internal/config/config.go +++ b/backend/internal/config/config.go @@ -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(".", "_")) diff --git a/deploy.sh b/deploy.sh index ebf1858..f8421f6 100755 --- a/deploy.sh +++ b/deploy.sh @@ -5,29 +5,10 @@ PROJECT_DIR="$(cd "$(dirname "$0")" && pwd)" cd "$PROJECT_DIR" # 颜色输出 -RED='\033[0;31m' GREEN='\033[0;32m' -YELLOW='\033[1;33m' NC='\033[0m' 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 镜像..." @@ -36,7 +17,6 @@ cmd_build() { } cmd_up() { - ensure_env info "启动服务..." docker compose up -d info "服务已启动" diff --git a/docker-compose.yml b/docker-compose.yml index d331f9d..7eda523 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,8 +17,6 @@ services: context: ./backend dockerfile: Dockerfile container_name: camtalk-backend - env_file: - - .env environment: - APP_ENV=production networks: diff --git a/frontend/.dockerignore b/frontend/.dockerignore new file mode 100644 index 0000000..629cce9 --- /dev/null +++ b/frontend/.dockerignore @@ -0,0 +1,8 @@ +node_modules +dist +.git +.gitignore +*.md +.env* +.vscode +.idea