From 5494a0c480508c8433840d90cdba67dd121e02d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=96=8C?= <259278618@qq.com> Date: Mon, 8 Jun 2026 13:44:54 +0800 Subject: [PATCH 1/2] =?UTF-8?q?ci/cd=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 44 ++++++++++++++++++++++++++++++++++++++++++++ config.yml | 10 +++++----- 2 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4b1cb3a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,44 @@ +# 多阶段构建 - 第一阶段:编译(使用已安装的镜像) +FROM golang:alpine AS builder + +RUN apk add --no-cache git ca-certificates tzdata + +ENV GO111MODULE=on +ENV GOPROXY=https://goproxy.cn,direct +ENV CGO_ENABLED=0 +ENV GOTOOLCHAIN=auto +ENV GOPRIVATE=gitea.com/red-future/common + +# 配置git使用私有Gitea仓库(带Token认证) +RUN git config --global url."http://x-token-auth:619679cd366aefea3a50f0622d842a41f2209e08595767bba49c3836ef57d415@116.204.74.41:3000/red-future/common.git".insteadOf "https://gitea.com/red-future/common.git" && \ + git config --global credential.helper store + +WORKDIR /build + +# 复制父目录的 common 模块(因为 go.mod 中使用了本地 replace) +#COPY ../common /build/common +COPY . . + +RUN go mod download && go mod tidy + +RUN go build -ldflags="-s -w" -o main ./main.go + +# 第二阶段:运行 +FROM alpine:3.19 + +ENV TIME_ZONE=Asia/Shanghai +RUN apk add --no-cache ca-certificates tzdata && \ + ln -sf /usr/share/zoneinfo/$TIME_ZONE /etc/localtime + +WORKDIR /app + +# 复制编译好的二进制文件 +COPY --from=builder /build/main . +COPY --from=builder /build/config.yml ./ + +# 创建日志目录 +RUN mkdir -p /logs /app/resource/log/run /app/resource/log/server + +EXPOSE 3009 + +CMD ["./main"] diff --git a/config.yml b/config.yml index a00b2ed..fc222fa 100644 --- a/config.yml +++ b/config.yml @@ -7,7 +7,7 @@ server: database: default: - type: "pgsql" - host: "116.204.74.41" + host: "192.168.0.169" port: "15432" user: "postgres" pass: "Bjang09@686^*^" @@ -28,7 +28,7 @@ database: timeMaintainDisabled: false # (可选)是否完全关闭时间更新特性,为true时CreatedAt/UpdatedAt/DeletedAt都将失效 model_gateway: - type: "pgsql" - host: "116.204.74.41" + host: "192.168.0.169" port: "15432" user: "postgres" pass: "Bjang09@686^*^" @@ -50,14 +50,14 @@ database: redis: default: - address: 192.168.3.30:6379 + address: 192.168.0.169:6379 db: 0 consul: - address: 192.168.3.30:8500 + address: 116.204.74.41:8500 jaeger: - addr: 192.168.3.30:4318 + addr: 192.168.0.169:4318 task: waitTimeoutSeconds: 600 # /composeMessages 同步等待最终结果的最长时间(秒) From aa7804656f323bd6092c238ebf747e0a8c95aa90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=96=8C?= <259278618@qq.com> Date: Mon, 8 Jun 2026 15:37:12 +0800 Subject: [PATCH 2/2] =?UTF-8?q?ci/cd=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config.yml b/config.yml index fc222fa..5ca72ba 100644 --- a/config.yml +++ b/config.yml @@ -7,7 +7,7 @@ server: database: default: - type: "pgsql" - host: "192.168.0.169" + host: "116.204.74.41" port: "15432" user: "postgres" pass: "Bjang09@686^*^" @@ -28,7 +28,7 @@ database: timeMaintainDisabled: false # (可选)是否完全关闭时间更新特性,为true时CreatedAt/UpdatedAt/DeletedAt都将失效 model_gateway: - type: "pgsql" - host: "192.168.0.169" + host: "116.204.74.41" port: "15432" user: "postgres" pass: "Bjang09@686^*^" @@ -50,14 +50,14 @@ database: redis: default: - address: 192.168.0.169:6379 + address: 116.204.74.41:6379 db: 0 consul: address: 116.204.74.41:8500 jaeger: - addr: 192.168.0.169:4318 + addr: 116.204.74.41:4318 task: waitTimeoutSeconds: 600 # /composeMessages 同步等待最终结果的最长时间(秒)