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

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

commit ac347e7d24df448a8a11ecfcae29f3a136798b8a
Author: yuluo-yx <[email protected]>
AuthorDate: Fri Dec 12 22:39:31 2025 +0800

    feat: adjust docker deploy
    
    Signed-off-by: yuluo-yx <[email protected]>
---
 Makefile                                           |  1 +
 .../docker/docker-compose/docker-compose.yml       | 23 +++++----
 Makefile => tools/docker/hcg/Dockerfile            | 25 ++++++----
 tools/make/image.mk                                | 58 ++++++++++++++++++++++
 4 files changed, 89 insertions(+), 18 deletions(-)

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/Makefile b/tools/docker/docker-compose/docker-compose.yml
similarity index 74%
copy from Makefile
copy to tools/docker/docker-compose/docker-compose.yml
index cd02530..f6df109 100644
--- a/Makefile
+++ 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
@@ -15,14 +16,18 @@
 # specific language governing permissions and limitations
 # under the License.
 
-_run:
-       @$(MAKE) --warn-undefined-variables \
-               -f tools/make/common.mk \
-               -f tools/make/golang.mk \
-               -f tools/make/linter.mk \
-               -f tools/make/tools.mk \
-               $(MAKECMDGOALS)
+services:
 
-.PHONY: _run
+  # collector go service
+  hertzbeat-collector:
+    image: hertzbeat-collector-go:latest
+    container_name: hertzbeat-collector-go
+    restart: on-failure
+    ports:
+      - "8080:8080"
+    networks:
+      hcg-network:
 
-$(if $(MAKECMDGOALS),$(MAKECMDGOALS): %: _run)
+networks:
+  hcg-network:
+    driver: bridge
diff --git a/Makefile b/tools/docker/hcg/Dockerfile
similarity index 51%
copy from Makefile
copy to tools/docker/hcg/Dockerfile
index cd02530..2bb553d 100644
--- a/Makefile
+++ b/tools/docker/hcg/Dockerfile
@@ -15,14 +15,21 @@
 # specific language governing permissions and limitations
 # under the License.
 
-_run:
-       @$(MAKE) --warn-undefined-variables \
-               -f tools/make/common.mk \
-               -f tools/make/golang.mk \
-               -f tools/make/linter.mk \
-               -f tools/make/tools.mk \
-               $(MAKECMDGOALS)
+FROM 
docker.io/library/busybox@sha256:ab33eacc8251e3807b85bb6dba570e4698c3998eca6f0fc2ccb60575a563ea74
 AS builder
 
-.PHONY: _run
+# prepare hertzbeat data dir
+RUN mkdir -p /var/hertzbeat
 
-$(if $(MAKECMDGOALS),$(MAKECMDGOALS): %: _run)
+# 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
+
+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