This is an automated email from the ASF dual-hosted git repository.

shown pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hertzbeat-collector-go.git


The following commit(s) were added to refs/heads/main by this push:
     new 6f38aaa  chore(core): update Dockerfile for multi-stage build and 
clean up README (#8)
6f38aaa is described below

commit 6f38aaacc18ae9eea2e800f3cf015d2a0fb0c1c3
Author: aias00 <[email protected]>
AuthorDate: Sat Sep 6 22:55:42 2025 +0800

    chore(core): update Dockerfile for multi-stage build and clean up README 
(#8)
---
 .gitignore                                 |  1 -
 Dockerfile                                 | 37 +++++++++++++++++++++++++++++-
 README.md                                  |  2 --
 Dockerfile => etc/hertzbeat-collector.yaml |  9 +++++++-
 4 files changed, 44 insertions(+), 5 deletions(-)

diff --git a/.gitignore b/.gitignore
index f11a8e8..2600dc2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -40,7 +40,6 @@ security/cmd/node_agent/na/pkey
 vendor
 # Contains the built artifacts
 out/
-etc/
 var/
 # Go compiled tests
 *.test
diff --git a/Dockerfile b/Dockerfile
index ef9b9ed..b0bd65c 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -15,4 +15,39 @@
 # specific language governing permissions and limitations
 # under the License.
 
-From golang:1.24-alpine
+
+# syntax=docker/dockerfile:1
+
+# Build stage
+FROM golang:1.24-alpine AS builder
+
+WORKDIR /app
+
+# 安装 git 以支持 go mod 下载私有依赖(如有需要)
+RUN apk add --no-cache git
+
+# 复制 go.mod 和 go.sum 并下载依赖
+COPY go.mod go.sum ./
+RUN go mod download
+
+# 复制源代码
+COPY . .
+
+# 构建二进制文件
+RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o collector ./cmd/main.go
+
+# Production stage
+FROM alpine:3.19
+
+WORKDIR /app
+
+# 拷贝构建产物
+COPY --from=builder /app/collector /app/collector
+
+# 如有配置文件等需要一并拷贝
+# COPY --from=builder /app/etc /app/etc
+
+# 暴露端口(如有需要)
+# EXPOSE 1158
+
+ENTRYPOINT ["./collector"]
diff --git a/README.md b/README.md
index 9422898..1b46e6a 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,3 @@
-go mod tidy
-
 # HertzBeat Collector Go
 
 [![License](https://img.shields.io/badge/license-Apache%202-blue)](LICENSE)
diff --git a/Dockerfile b/etc/hertzbeat-collector.yaml
similarity index 87%
copy from Dockerfile
copy to etc/hertzbeat-collector.yaml
index ef9b9ed..3cae1f6 100644
--- a/Dockerfile
+++ b/etc/hertzbeat-collector.yaml
@@ -15,4 +15,11 @@
 # specific language governing permissions and limitations
 # under the License.
 
-From golang:1.24-alpine
+collector:
+  info:
+    name: hertzbeat-collector-go
+    ip: 127.0.0.1
+    port: 8080
+
+  log:
+    level: debug


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to