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 9c22245  feat: adjust docker deploy (#34)
9c22245 is described below

commit 9c222457493e3e5df16b51d45a49ce6b927295c9
Author: shown <[email protected]>
AuthorDate: Fri Dec 12 22:48:49 2025 +0800

    feat: adjust docker deploy (#34)
---
 Dockerfile                                         |  63 ----
 Makefile                                           |   1 +
 examples/Dockerfile                                |  79 -----
 examples/README.md                                 | 357 ---------------------
 examples/docker-compose.yml                        |  58 ----
 examples/main.go                                   | 102 ------
 .../docker/docker-compose/docker-compose.yml       |   5 +-
 .../docker/hcg/Dockerfile                          |  30 +-
 tools/make/image.mk                                |  58 ++++
 9 files changed, 77 insertions(+), 676 deletions(-)

diff --git a/Dockerfile b/Dockerfile
deleted file mode 100644
index eb17107..0000000
--- a/Dockerfile
+++ /dev/null
@@ -1,63 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-FROM golang:1.25-alpine3.22 AS golang-builder
-
-ARG GOPROXY
-# ENV GOPROXY ${GOPROXY:-direct}
-# ENV GOPROXY=https://proxy.golang.com.cn,direct
-
-ENV GOPATH /go
-ENV GOROOT /usr/local/go
-ENV PACKAGE hertzbeat.apache.org/hertzbeat-collector-go
-ENV BUILD_DIR /app
-
-COPY . ${BUILD_DIR}
-WORKDIR ${BUILD_DIR}
-RUN apk --no-cache add build-base git bash golangci-lint
-
-RUN make init && \
-    make fmt && \
-    make go-lint &&\
-    make build
-
-RUN chmod +x bin/collector
-
-FROM alpine
-
-ARG TIMEZONE
-ENV TIMEZONE=${TIMEZONE:-"Asia/Shanghai"}
-
-RUN apk update \
-    && apk --no-cache add \
-        bash \
-        ca-certificates \
-        curl \
-        dumb-init \
-        gettext \
-        openssh \
-        sqlite \
-        gnupg \
-        tzdata \
-    && ln -sf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime \
-    && echo "${TIMEZONE}" > /etc/timezone
-
-COPY --from=golang-builder /app/bin/collector /usr/local/bin/collector
-COPY --from=golang-builder /app/etc/hertzbeat-collector.yml 
/etc/hertzbeat-collector.yml
-
-EXPOSE 8090
-ENTRYPOINT ["collector", "server", "--config", "/etc/hertzbeat-collector.yml"]
diff --git a/Makefile b/Makefile
index cd02530..ef34a46 100644
--- a/Makefile
+++ b/Makefile
@@ -21,6 +21,7 @@ _run:
                -f tools/make/golang.mk \
                -f tools/make/linter.mk \
                -f tools/make/tools.mk \
+               -f tools/make/image.mk \
                $(MAKECMDGOALS)
 
 .PHONY: _run
diff --git a/examples/Dockerfile b/examples/Dockerfile
deleted file mode 100644
index 6686dd0..0000000
--- a/examples/Dockerfile
+++ /dev/null
@@ -1,79 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# Multi-stage build for Go application
-FROM golang:1.23-alpine AS builder
-
-# Set working directory
-WORKDIR /app
-
-# Install build dependencies
-RUN apk add --no-cache git
-
-# Copy source code
-COPY . .
-
-# Download dependencies
-RUN go mod download
-
-# Build the application
-RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o 
hertzbeat-collector-go ./examples/main.go
-
-# Final stage
-FROM alpine:latest
-
-# Install ca-certificates for HTTPS
-RUN apk --no-cache add ca-certificates
-
-# Create non-root user
-RUN addgroup -g 1000 appgroup && adduser -u 1000 -G appgroup -s /bin/sh -D 
appuser
-
-# Set working directory
-WORKDIR /app
-
-# Copy binary from builder
-COPY --from=builder /app/hertzbeat-collector-go .
-
-# Copy configuration file
-COPY --from=builder /app/etc/hertzbeat-collector.yaml ./etc/
-
-# Change ownership
-RUN chown -R appuser:appgroup /app
-
-# Switch to non-root user
-USER appuser
-
-# Expose port (if needed for metrics or health checks)
-EXPOSE 8080
-
-# Health check
-HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
-    CMD pgrep hertzbeat-collector-go || exit 1
-
-# Default environment variables
-ENV IDENTITY=hertzbeat-collector-go
-ENV MODE=public
-ENV MANAGER_HOST=127.0.0.1
-ENV MANAGER_PORT=1158
-ENV MANAGER_PROTOCOL=netty
-ENV COLLECTOR_NAME=hertzbeat-collector-go
-ENV COLLECTOR_IP=0.0.0.0
-ENV COLLECTOR_PORT=8080
-ENV LOG_LEVEL=info
-
-# Run the application
-CMD ["./hertzbeat-collector-go"]
diff --git a/examples/README.md b/examples/README.md
deleted file mode 100644
index f5713c7..0000000
--- a/examples/README.md
+++ /dev/null
@@ -1,357 +0,0 @@
-# HertzBeat Collector Go - Examples
-
-这个目录包含了HertzBeat Collector Go的使用示例。
-
-## 快速开始
-
-### 1. 直接运行
-
-```bash
-# 设置环境变量
-export IDENTITY=hertzbeat-collector-go
-export MODE=public
-export MANAGER_HOST=127.0.0.1
-export MANAGER_PORT=1158
-export MANAGER_PROTOCOL=netty
-
-# 运行collector
-go run examples/main.go
-```
-
-### 2. 使用Docker
-
-```bash
-# 构建Docker镜像
-docker build -t hertzbeat-collector-go:latest examples/
-
-# 运行容器
-docker run -d \
-  -e IDENTITY=hertzbeat-collector-go \
-  -e MODE=public \
-  -e MANAGER_HOST=host.docker.internal \
-  -e MANAGER_PORT=1158 \
-  -e MANAGER_PROTOCOL=netty \
-  --name hertzbeat-collector-go \
-  hertzbeat-collector-go:latest
-```
-
-### 3. 使用Docker Compose
-
-```bash
-# 启动服务
-docker-compose -f examples/docker-compose.yml up -d
-
-# 查看日志
-docker-compose -f examples/docker-compose.yml logs -f
-```
-
-## 环境变量配置
-
-| 变量名 | 描述 | 默认值 | 必需 |
-|--------|------|--------|------|
-| `IDENTITY` | 采集器标识符 | - | 是 |
-| `MODE` | 运行模式 (public/private) | public | 否 |
-| `MANAGER_HOST` | 管理服务器主机 | 127.0.0.1 | 否 |
-| `MANAGER_PORT` | 管理服务器端口 | 1158 | 否 |
-| `MANAGER_PROTOCOL` | 通信协议 (netty/grpc) | netty | 否 |
-| `MANAGER_TIMEOUT` | 连接超时时间(毫秒) | 5000 | 否 |
-| `MANAGER_HEARTBEAT_INTERVAL` | 心跳间隔(秒) | 10 | 否 |
-
-## 配置文件
-
-可以使用 `examples/hertzbeat-collector.yaml` 文件进行配置,或使用环境变量覆盖配置。
-
-## 功能特性
-
-- ✅ 支持Netty和gRPC双协议
-- ✅ 自动重连机制
-- ✅ 心跳检测
-- ✅ 优雅关闭
-- ✅ 完整的错误处理
-- ✅ Docker容器化支持
-- ✅ 环境变量配置
-- ✅ 信号处理
-
-## 支持的消息类型
-
-- `HEARTBEAT` - 心跳消息
-- `GO_ONLINE` - 上线消息
-- `GO_OFFLINE` - 下线消息
-- `GO_CLOSE` - 关闭消息
-- `ISSUE_CYCLIC_TASK` - 周期性任务
-- `ISSUE_ONE_TIME_TASK` - 一次性任务
-
-## 文件结构
-
-```text
-examples/
-├── main.go              # 主要示例文件
-├── Dockerfile           # Docker构建文件
-├── docker-compose.yml   # Docker Compose配置
-├── hertzbeat-collector.yaml  # 配置文件示例
-└── README.md           # 本文档
-```
-
-## 故障排除
-
-如果遇到连接问题,请检查:
-
-1. 确保管理服务器正在运行
-2. 检查网络连通性
-3. 验证端口是否开放
-4. 确认协议版本兼容性
-5. 检查日志输出
-
-### 常见问题
-
-**连接被拒绝**
-
-```bash
-# 检查管理服务器状态
-telnet $MANAGER_HOST $MANAGER_PORT
-
-# 检查防火墙设置
-sudo ufw status
-```
-
-**心跳超时**
-
-```bash
-# 增加心跳间隔
-export MANAGER_HEARTBEAT_INTERVAL=30
-
-# 检查网络延迟
-ping $MANAGER_HOST
-```
-
-## 开发指南
-
-### 本地开发
-
-```bash
-# 克隆项目
-git clone https://github.com/apache/hertzbeat-collector-go.git
-cd hertzbeat-collector-go
-
-# 安装依赖
-go mod tidy
-
-# 运行示例
-go run examples/main.go
-```
-
-### 自定义配置
-
-```go
-// 在代码中直接配置
-config := &transport.Config{
-    Server: clrServer.Server{
-        Logger: logger,
-    },
-    ServerAddr: "custom-host:1158",
-    Protocol:   "netty",
-}
-
-runner := transport.New(config)
-```
-
-### 添加自定义消息处理器
-
-```go
-// 注册自定义处理器
-runner.RegisterProcessor(100, func(msg interface{}) (interface{}, error) {
-    if pbMsg, ok := msg.(*pb.Message); ok {
-        // 处理消息
-        log.Printf("收到自定义消息: %s", string(pbMsg.Msg))
-        return &pb.Message{
-            Type:      pb.MessageType_HEARTBEAT,
-            Direction: pb.Direction_RESPONSE,
-            Identity:  pbMsg.Identity,
-            Msg:       []byte("custom response"),
-        }, nil
-    }
-    return nil, nil
-})
-```
-
-更多详细信息请参考主项目的README.md文件。
-
----
-
-## English Version
-
-This directory contains usage examples for HertzBeat Collector Go.
-
-## Quick Start
-
-### 1. Direct Run
-
-```bash
-# Set environment variables
-export IDENTITY=hertzbeat-collector-go
-export MODE=public
-export MANAGER_HOST=127.0.0.1
-export MANAGER_PORT=1158
-export MANAGER_PROTOCOL=netty
-
-# Run collector
-go run examples/main.go
-```
-
-### 2. Using Docker
-
-```bash
-# Build Docker image
-docker build -t hertzbeat-collector-go:latest examples/
-
-# Run container
-docker run -d \
-  -e IDENTITY=hertzbeat-collector-go \
-  -e MODE=public \
-  -e MANAGER_HOST=host.docker.internal \
-  -e MANAGER_PORT=1158 \
-  -e MANAGER_PROTOCOL=netty \
-  --name hertzbeat-collector-go \
-  hertzbeat-collector-go:latest
-```
-
-### 3. Using Docker Compose
-
-```bash
-# Start services
-docker-compose -f examples/docker-compose.yml up -d
-
-# View logs
-docker-compose -f examples/docker-compose.yml logs -f
-```
-
-## Environment Variables
-
-| Variable | Description | Default | Required |
-|----------|-------------|---------|----------|
-| `IDENTITY` | Collector identifier | - | Yes |
-| `MODE` | Operation mode (public/private) | public | No |
-| `MANAGER_HOST` | Manager server host | 127.0.0.1 | No |
-| `MANAGER_PORT` | Manager server port | 1158 | No |
-| `MANAGER_PROTOCOL` | Communication protocol (netty/grpc) | netty | No |
-| `MANAGER_TIMEOUT` | Connection timeout (milliseconds) | 5000 | No |
-| `MANAGER_HEARTBEAT_INTERVAL` | Heartbeat interval (seconds) | 10 | No |
-
-## Configuration File
-
-You can use the `examples/hertzbeat-collector.yaml` file for configuration, or 
override configuration with environment variables.
-
-## Features
-
-- ✅ Dual protocol support (Netty and gRPC)
-- ✅ Auto-reconnection mechanism
-- ✅ Heartbeat detection
-- ✅ Graceful shutdown
-- ✅ Complete error handling
-- ✅ Docker containerization support
-- ✅ Environment variable configuration
-- ✅ Signal handling
-
-## Supported Message Types
-
-- `HEARTBEAT` - Heartbeat message
-- `GO_ONLINE` - Online message
-- `GO_OFFLINE` - Offline message
-- `GO_CLOSE` - Close message
-- `ISSUE_CYCLIC_TASK` - Cyclic task
-- `ISSUE_ONE_TIME_TASK` - One-time task
-
-## File Structure
-
-```text
-examples/
-├── main.go              # Main example file
-├── Dockerfile           # Docker build file
-├── docker-compose.yml   # Docker Compose configuration
-├── hertzbeat-collector.yaml  # Configuration file example
-└── README.md           # This document
-```
-
-## Troubleshooting
-
-If you encounter connection issues, please check:
-
-1. Ensure the manager server is running
-2. Check network connectivity
-3. Verify the port is open
-4. Confirm protocol version compatibility
-5. Check log output
-
-### Common Issues
-
-**Connection Refused**
-
-```bash
-# Check manager server status
-telnet $MANAGER_HOST $MANAGER_PORT
-
-# Check firewall settings
-sudo ufw status
-```
-
-**Heartbeat Timeout**
-
-```bash
-# Increase heartbeat interval
-export MANAGER_HEARTBEAT_INTERVAL=30
-
-# Check network latency
-ping $MANAGER_HOST
-```
-
-## Development Guide
-
-### Local Development
-
-```bash
-# Clone project
-git clone https://github.com/apache/hertzbeat-collector-go.git
-cd hertzbeat-collector-go
-
-# Install dependencies
-go mod tidy
-
-# Run example
-go run examples/main.go
-```
-
-### Custom Configuration
-
-```go
-// Configure directly in code
-config := &transport.Config{
-    Server: clrServer.Server{
-        Logger: logger,
-    },
-    ServerAddr: "custom-host:1158",
-    Protocol:   "netty",
-}
-
-runner := transport.New(config)
-```
-
-### Add Custom Message Processor
-
-```go
-// Register custom processor
-runner.RegisterProcessor(100, func(msg interface{}) (interface{}, error) {
-    if pbMsg, ok := msg.(*pb.Message); ok {
-        // Process message
-        log.Printf("Received custom message: %s", string(pbMsg.Msg))
-        return &pb.Message{
-            Type:      pb.MessageType_HEARTBEAT,
-            Direction: pb.Direction_RESPONSE,
-            Identity:  pbMsg.Identity,
-            Msg:       []byte("custom response"),
-        }, nil
-    }
-    return nil, nil
-})
-```
-
-For more detailed information, please refer to the main project's README.md 
file.
diff --git a/examples/docker-compose.yml b/examples/docker-compose.yml
deleted file mode 100644
index 40f5a27..0000000
--- a/examples/docker-compose.yml
+++ /dev/null
@@ -1,58 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-version: '3.8'
-
-services:
-  hertzbeat-collector-go:
-    build: .
-    container_name: hertzbeat-collector-go
-    restart: unless-stopped
-    environment:
-      # Collector identity (required)
-      - IDENTITY=hertzbeat-collector-go
-      # Manager server configuration
-      - MANAGER_HOST=host.docker.internal
-      - MANAGER_PORT=1158
-      - MANAGER_PROTOCOL=netty
-      # Collector mode
-      - MODE=public
-      # Optional: collector configuration
-      - COLLECTOR_NAME=hertzbeat-collector-go
-      - COLLECTOR_IP=0.0.0.0
-      - COLLECTOR_PORT=8080
-      - LOG_LEVEL=info
-    ports:
-      - "8080:8080"
-    networks:
-      - hertzbeat-network
-    healthcheck:
-      test: ["CMD", "pgrep", "hertzbeat-collector-go"]
-      interval: 30s
-      timeout: 10s
-      retries: 3
-      start_period: 40s
-    volumes:
-      - ./hertzbeat-collector.yaml:/app/etc/hertzbeat-collector.yaml:ro
-      - ./logs:/app/logs
-
-networks:
-  hertzbeat-network:
-    driver: bridge
-
-volumes:
-  logs:
diff --git a/examples/main.go b/examples/main.go
deleted file mode 100644
index 662ed25..0000000
--- a/examples/main.go
+++ /dev/null
@@ -1,102 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package main
-
-import (
-       "context"
-       "os"
-       "os/signal"
-       "syscall"
-
-       
"hertzbeat.apache.org/hertzbeat-collector-go/internal/collector/common/transport"
-       loggertypes 
"hertzbeat.apache.org/hertzbeat-collector-go/internal/collector/common/types/logger"
-       config 
"hertzbeat.apache.org/hertzbeat-collector-go/internal/collector/config"
-       "hertzbeat.apache.org/hertzbeat-collector-go/internal/util/logger"
-)
-
-func main() {
-       // Create simple logger
-       logging := &loggertypes.HertzBeatLogging{
-               Level: 
map[loggertypes.HertzbeatLogComponent]loggertypes.LogLevel{
-                       loggertypes.LogComponentHertzbeatDefault: 
loggertypes.LogLevelInfo,
-               },
-       }
-       log := logger.NewLogger(os.Stdout, logging)
-
-       log.Info("=== HertzBeat Collector Go ===")
-
-       // Load configuration from environment variables
-       envLoader := config.NewEnvConfigLoader()
-       cfg := envLoader.LoadFromEnv()
-
-       if cfg == nil {
-               log.Error(nil, "Failed to load configuration")
-               os.Exit(1)
-       }
-
-       // Display configuration
-       log.Info("=== Configuration ===")
-       log.Info("Collector Identity", "identity", cfg.Collector.Identity)
-       log.Info("Collector Mode", "mode", cfg.Collector.Mode)
-       log.Info("Manager Host", "host", cfg.Collector.Manager.Host)
-       log.Info("Manager Port", "port", cfg.Collector.Manager.Port)
-       log.Info("Manager Protocol", "protocol", cfg.Collector.Manager.Protocol)
-       log.Info("====================")
-
-       // Create transport runner from configuration
-       runner := transport.NewFromConfig(cfg)
-       if runner == nil {
-               log.Error(nil, "Failed to create transport runner")
-               os.Exit(1)
-       }
-
-       // Setup signal handling for graceful shutdown
-       ctx, cancel := context.WithCancel(context.Background())
-       defer cancel()
-
-       // Handle shutdown signals
-       sigChan := make(chan os.Signal, 1)
-       signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
-
-       go func() {
-               sig := <-sigChan
-               log.Info("Received shutdown signal", "signal", sig)
-               cancel()
-       }()
-
-       // Start the transport client
-       log.Info("Starting HertzBeat Collector Go...")
-
-       go func() {
-               if err := runner.Start(ctx); err != nil {
-                       log.Error(err, "Transport client error")
-                       cancel()
-               }
-       }()
-
-       // Wait for context cancellation
-       <-ctx.Done()
-
-       // Shutdown gracefully
-       log.Info("Shutting down HertzBeat Collector Go...")
-       if err := runner.Close(); err != nil {
-               log.Error(err, "Error during shutdown")
-       }
-
-       log.Info("HertzBeat Collector Go stopped gracefully")
-}
diff --git a/docker-compose.yml b/tools/docker/docker-compose/docker-compose.yml
similarity index 93%
rename from docker-compose.yml
rename to tools/docker/docker-compose/docker-compose.yml
index 7c158b5..f6df109 100644
--- a/docker-compose.yml
+++ b/tools/docker/docker-compose/docker-compose.yml
@@ -1,3 +1,4 @@
+
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
 # distributed with this work for additional information
@@ -19,11 +20,11 @@ services:
 
   # collector go service
   hertzbeat-collector:
-    image: hertzbeat/hertzbeat-collector-go:latest
+    image: hertzbeat-collector-go:latest
     container_name: hertzbeat-collector-go
     restart: on-failure
     ports:
-      - "8090:8090"
+      - "8080:8080"
     networks:
       hcg-network:
 
diff --git a/examples/hertzbeat-collector.yaml b/tools/docker/hcg/Dockerfile
similarity index 51%
rename from examples/hertzbeat-collector.yaml
rename to tools/docker/hcg/Dockerfile
index 2a06385..2bb553d 100644
--- a/examples/hertzbeat-collector.yaml
+++ b/tools/docker/hcg/Dockerfile
@@ -15,21 +15,21 @@
 # specific language governing permissions and limitations
 # under the License.
 
-collector:
-  info:
-    name: hertzbeat-collector-go
-    ip: 127.0.0.1
-    port: 8080
+FROM 
docker.io/library/busybox@sha256:ab33eacc8251e3807b85bb6dba570e4698c3998eca6f0fc2ccb60575a563ea74
 AS builder
 
-  log:
-    level: info
+# prepare hertzbeat data dir
+RUN mkdir -p /var/hertzbeat
 
-  # Manager server configuration
-  manager:
-    host: 127.0.0.1
-    port: 1158
-    protocol: netty  # netty or grpc
+# Use distroless as minimal base image to package the manager binary
+# Refer to https://github.com/GoogleContainerTools/distroless for more details
+FROM 
gcr.io/distroless/base-nossl:nonroot@sha256:8981b63f968e829d21351ea9d28cc21127e5f034707f1d8483d2993d9577be0b
 
-  # Collector identity and mode
-  identity: hertzbeat-collector-go
-  mode: public  # public or private
+COPY --from=builder /var/hertzbeat/ /var/hertzbeat/
+
+# copy binary to image, run make build to generate binary.
+COPY bin /usr/local/bin/
+COPY etc /var/hertzbeat/config/
+
+USER 65532:65532
+
+ENTRYPOINT ["/usr/local/bin/collector", "server", "--config", 
"/var/hertzbeat/config/hertzbeat-collector.yaml"]
diff --git a/tools/make/image.mk b/tools/make/image.mk
new file mode 100644
index 0000000..fc37001
--- /dev/null
+++ b/tools/make/image.mk
@@ -0,0 +1,58 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# This is a wrapper to build and push docker image
+#
+
+# All make targets related to docker image are defined in this file.
+
+REGISTRY ?= docker.io
+
+TAG ?= $(shell git rev-parse HEAD)
+
+DOCKER := docker
+DOCKER_SUPPORTED_API_VERSION ?= 1.32
+
+IMAGES_DIR ?= $(wildcard tools/docker/hcg)
+
+IMAGES ?= hertzbeat-collector-go
+IMAGE_PLATFORMS ?= amd64 arm64
+
+BUILDX_CONTEXT = hcg-build-tools-builder
+
+##@ Image
+
+# todo: multi-platform build
+
+.PHONY: image-build
+image-build: ## Build docker image
+image-build: IMAGE_PLATFORMS = ${shell uname -m}
+image-build:
+       @$(LOG_TARGET)
+       make build
+       $(DOCKER) buildx create --name $(BUILDX_CONTEXT) --use; \
+       $(DOCKER) buildx use $(BUILDX_CONTEXT); \
+       $(DOCKER) buildx build --load \
+        -t $(REGISTRY)/${IMAGES}:$(TAG) \
+        --platform linux/${IMAGE_PLATFORMS} \
+        --file $(IMAGES_DIR)/Dockerfile . ; \
+        $(DOCKER) buildx rm $(BUILDX_CONTEXT)
+
+.PHONY: image-push
+image-push: ## Push docker image
+image-push:
+       @$(LOG_TARGET)
+       $(DOCKER) push $(REGISTRY)/$${image}:$(TAG)-$${platform}; \


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

Reply via email to