Skip to content

Commit 6f38aaa

Browse files
authored
chore(core): update Dockerfile for multi-stage build and clean up README (#8)
1 parent d9ec038 commit 6f38aaa

File tree

4 files changed

+61
-4
lines changed

4 files changed

+61
-4
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ security/cmd/node_agent/na/pkey
4040
vendor
4141
# Contains the built artifacts
4242
out/
43-
etc/
4443
var/
4544
# Go compiled tests
4645
*.test

Dockerfile

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,39 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
From golang:1.24-alpine
18+
19+
# syntax=docker/dockerfile:1
20+
21+
# Build stage
22+
FROM golang:1.24-alpine AS builder
23+
24+
WORKDIR /app
25+
26+
# 安装 git 以支持 go mod 下载私有依赖(如有需要)
27+
RUN apk add --no-cache git
28+
29+
# 复制 go.mod 和 go.sum 并下载依赖
30+
COPY go.mod go.sum ./
31+
RUN go mod download
32+
33+
# 复制源代码
34+
COPY . .
35+
36+
# 构建二进制文件
37+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o collector ./cmd/main.go
38+
39+
# Production stage
40+
FROM alpine:3.19
41+
42+
WORKDIR /app
43+
44+
# 拷贝构建产物
45+
COPY --from=builder /app/collector /app/collector
46+
47+
# 如有配置文件等需要一并拷贝
48+
# COPY --from=builder /app/etc /app/etc
49+
50+
# 暴露端口(如有需要)
51+
# EXPOSE 1158
52+
53+
ENTRYPOINT ["./collector"]

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
go mod tidy
2-
31
# HertzBeat Collector Go
42

53
[![License](https://img.shields.io/badge/license-Apache%202-blue)](LICENSE)

etc/hertzbeat-collector.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
collector:
19+
info:
20+
name: hertzbeat-collector-go
21+
ip: 127.0.0.1
22+
port: 8080
23+
24+
log:
25+
level: debug

0 commit comments

Comments
 (0)