Implement proper storage metrics (P0-009)\n\n- Add dedicated storage_metrics table\n- Create StorageMetricReport models with proper field names\n- Add ReportStorageMetrics to agent client\n- Update storage scanner to use new method\n- Implement server-side handlers and queries\n- Register new routes and update UI\n- Remove legacy Scan() method\n- Follow ETHOS principles: honest naming, clean architecture
This commit is contained in:
@@ -18,23 +18,59 @@ FROM golang:1.24-alpine AS agent-builder
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
# Install git for module resolution
|
||||
# Install git for version detection
|
||||
RUN apk add --no-cache git
|
||||
|
||||
# Copy .git directory to get version info
|
||||
COPY .git/ ./.git/
|
||||
|
||||
# Generate semantic version from git (BASE_VERSION.COMMIT_COUNT)
|
||||
# Examples:
|
||||
# Tagged release: v0.1.26.0 → 0.1.26.0
|
||||
# 5 commits after tag: 0.1.26.5
|
||||
# No tags: 0.1.0.0
|
||||
RUN cd /build && \
|
||||
# Get latest tag or default to 0.1.0 \
|
||||
if git describe --tags --dirty --always >/dev/null 2>&1; then \
|
||||
LATEST_TAG=$(git describe --tags --dirty --always); \
|
||||
BASE_VERSION=$(echo "$LATEST_TAG" | sed 's/^v//' | cut -d. -f1-3); \
|
||||
else \
|
||||
BASE_VERSION="0.1.0"; \
|
||||
fi && \
|
||||
# Count commits since tag (0 if on tag) \
|
||||
COMMITS_SINCE=$(git rev-list $(git describe --tags --dirty --always 2>/dev/null)..HEAD 2>/dev/null | wc -l | tr -d ' ') && \
|
||||
if [ "$COMMITS_SINCE" = "" ] || [ "$COMMITS_SINCE" -eq 0 ]; then BUILD=0; else BUILD=$COMMITS_SINCE; fi && \
|
||||
# Write semantic version (base.commits) \
|
||||
VERSION="${BASE_VERSION}.${BUILD}" && \
|
||||
echo "Building agent version: $VERSION" && \
|
||||
echo "$VERSION" > /build/version.txt
|
||||
|
||||
# Copy agent source code
|
||||
COPY aggregator-agent/ ./
|
||||
|
||||
# Build for Linux amd64
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o binaries/linux-amd64/redflag-agent ./cmd/agent
|
||||
RUN VERSION=$(cat /build/version.txt) && \
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
|
||||
-ldflags "-X github.com/Fimeg/RedFlag/aggregator-agent/internal/version.Version=$VERSION" \
|
||||
-o binaries/linux-amd64/redflag-agent ./cmd/agent
|
||||
|
||||
# Build for Linux arm64
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o binaries/linux-arm64/redflag-agent ./cmd/agent
|
||||
RUN VERSION=$(cat /build/version.txt) && \
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build \
|
||||
-ldflags "-X github.com/Fimeg/RedFlag/aggregator-agent/internal/version.Version=$VERSION" \
|
||||
-o binaries/linux-arm64/redflag-agent ./cmd/agent
|
||||
|
||||
# Build for Windows amd64
|
||||
RUN CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o binaries/windows-amd64/redflag-agent.exe ./cmd/agent
|
||||
RUN VERSION=$(cat /build/version.txt) && \
|
||||
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build \
|
||||
-ldflags "-X github.com/Fimeg/RedFlag/aggregator-agent/internal/version.Version=$VERSION" \
|
||||
-o binaries/windows-amd64/redflag-agent.exe ./cmd/agent
|
||||
|
||||
# Build for Windows arm64
|
||||
RUN CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build -o binaries/windows-arm64/redflag-agent.exe ./cmd/agent
|
||||
RUN VERSION=$(cat /build/version.txt) && \
|
||||
CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build \
|
||||
-ldflags "-X github.com/Fimeg/RedFlag/aggregator-agent/internal/version.Version=$VERSION" \
|
||||
-o binaries/windows-arm64/redflag-agent.exe ./cmd/agent
|
||||
|
||||
# Stage 3: Final image with server and all agent binaries
|
||||
FROM alpine:latest
|
||||
|
||||
Reference in New Issue
Block a user