File tree Expand file tree Collapse file tree 11 files changed +683
-31
lines changed
Expand file tree Collapse file tree 11 files changed +683
-31
lines changed Original file line number Diff line number Diff line change 1+ # Git
2+ .git
3+ .gitignore
4+ .github
5+ .gitattributes
6+
7+ # Documentation
8+ README.md
9+ * .md
10+ LICENSE
11+ docs /
12+
13+ # IDE and Editor
14+ .vscode
15+ .idea
16+ * .swp
17+ * .swo
18+ * ~
19+ .DS_Store
20+
21+ # Build artifacts
22+ bin /
23+ * .exe
24+ * .dll
25+ * .so
26+ * .dylib
27+
28+ # Test files
29+ * _test.go
30+ testdata /
31+
32+ # Logs
33+ * .log
34+ * .tmp
35+ * .pid
36+
37+ # Environment and config (use volumes instead)
38+ .env
39+ config.json
40+ * .local.json
41+
42+ # Docker files
43+ Dockerfile
44+ docker-compose.yml
45+ .dockerignore
46+
47+ # CI/CD
48+ .github /
49+ .gitlab-ci.yml
50+ .circleci /
51+
52+ # Misc
53+ Makefile
54+ * .bak
55+ * .backup
56+ node_modules /
57+ vendor /
Original file line number Diff line number Diff line change 1717 - uses : actions/checkout@v4
1818
1919 - name : Set up Go
20- uses : actions/setup-go@v4
20+ uses : actions/setup-go@v5
2121 with :
22- go-version : ' 1.20 '
22+ go-version : ' 1.24 '
2323
2424 - name : Build
2525 run : go build -v ./...
Original file line number Diff line number Diff line change 1+ # Use Debian-based builder for better CGO/library compatibility
2+ FROM golang:1.24-bookworm AS builder
3+
4+ # Install build dependencies
5+ RUN apt-get update && apt-get install -y --no-install-recommends \
6+ git \
7+ make \
8+ && rm -rf /var/lib/apt/lists/*
9+
10+ WORKDIR /app
11+ COPY go.mod go.sum ./
12+ RUN go mod download
13+
14+ COPY . .
15+ # Build with all features including GPU support (NVML)
16+ RUN go build -ldflags '-w -s' -o metricsd cmd/metricsd/main.go
17+
18+ FROM debian:bookworm-slim
19+
20+ # Install runtime dependencies
21+ RUN apt-get update && apt-get install -y --no-install-recommends \
22+ ca-certificates \
23+ tzdata \
24+ wget \
25+ && rm -rf /var/lib/apt/lists/*
26+
27+ # Create non-root user
28+ RUN groupadd -g 1000 metricsd && \
29+ useradd -r -u 1000 -g metricsd -s /bin/false metricsd
30+
31+ # Create directories
32+ RUN mkdir -p /etc/metricsd/certs /var/lib/metricsd
33+ RUN chown -R metricsd:metricsd /etc/metricsd /var/lib/metricsd
34+
35+ WORKDIR /home/metricsd
36+
37+ # Copy binary
38+ COPY --from=builder /app/metricsd /usr/local/bin/metricsd
39+ RUN chmod +x /usr/local/bin/metricsd
40+
41+ # Switch to non-root user
42+ USER metricsd
43+
44+ # Health check
45+ HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
46+ CMD wget --no-verbose --tries=1 --spider http://localhost:8080/health || exit 1
47+
48+ EXPOSE 8080
49+
50+ ENTRYPOINT ["/usr/local/bin/metricsd" ]
51+ CMD ["-config" , "/etc/metricsd/config.json" ]
You can’t perform that action at this time.
0 commit comments