Skip to content

Commit cf5176d

Browse files
authored
chore(cleanup): fix Makefile, Dockerfile, compose, smoke, ext (#24)
- Makefile: fix go.work stub (invalid module directive) - Dockerfile: add ARG VERSION/COMMIT/BUILD_DATE, drop broken git describe - docker-compose.yml: add daemon start command - smoke-hawk.sh: remove dead yaad subcommand calls - size-check: bump from 50MB to 100MB - external/: sync submodules to latest main commits
1 parent bb7265e commit cf5176d

10 files changed

Lines changed: 36 additions & 15 deletions

File tree

Dockerfile

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,30 @@ RUN apk add --no-cache git ca-certificates tzdata
66
WORKDIR /build
77

88
# GrayCodeAI sibling modules are unpublished at their current code (the public proxy
9-
# froze v0.1.0 at old commits). Resolve them locally via the committed go.work
9+
# froze v0.1.0 at old commits). Resolve them locally via a generated go.work
1010
# (use . + replace => ./external/<repo>), bypassing the proxy/sumdb entirely.
1111
ENV GOPRIVATE=github.com/GrayCodeAI/* \
1212
GONOSUMDB=github.com/GrayCodeAI/* \
1313
GONOSUMCHECK=1
1414

15+
# Build-time provenance (passed by .github/workflows/docker.yml or `docker build
16+
# --build-arg VERSION=... --build-arg COMMIT=... --build-arg BUILD_DATE=...`).
17+
# Default to "dev"/"none"/"unknown" so plain `docker build .` still produces a
18+
# runnable image — matching the cmd/hawk/main.go ldflags fallbacks.
19+
ARG VERSION=dev
20+
ARG COMMIT=none
21+
ARG BUILD_DATE=unknown
22+
1523
COPY . .
1624

1725
# Clone every sibling hawk imports into ./external, then generate a go.work that
1826
# resolves them locally. NOTE: the committed go.work/go.work.sum are excluded by
1927
# .dockerignore, so we must (re)create the workspace here. Do NOT run
2028
# 'go mod download' first — the frozen-proxy v0.1.0 fails checksum verification.
29+
#
30+
# main.Version / main.Commit / main.BuildDate are baked in from the ARGs above;
31+
# this is the only correct source — `git describe` would always return empty
32+
# because `.dockerignore` excludes `.git/` from the build context.
2133
RUN rm -rf external go.work go.work.sum && mkdir -p external && \
2234
for repo in eyrie inspect sight tok trace yaad; do \
2335
git clone --depth=1 "https://github.com/GrayCodeAI/${repo}.git" "external/${repo}"; \
@@ -27,7 +39,10 @@ RUN rm -rf external go.work go.work.sum && mkdir -p external && \
2739
echo " github.com/GrayCodeAI/${repo} => ./external/${repo}"; \
2840
done; echo ")"; } > go.work && \
2941
CGO_ENABLED=0 GOOS=linux go build -trimpath \
30-
-ldflags="-s -w -X main.Version=$(git describe --tags --always 2>/dev/null || echo dev)" \
42+
-ldflags="-s -w \
43+
-X main.Version=${VERSION} \
44+
-X main.Commit=${COMMIT} \
45+
-X main.BuildDate=${BUILD_DATE}" \
3146
-o hawk ./cmd/hawk
3247

3348
# Runtime stage — Alpine (hawk requires git + bash for workspace operations; distroless excluded)

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ setup: ## Set up local development environment (go.work + external repos).
152152
fi; \
153153
done
154154
@echo "Generating go.work..."
155-
@echo "module hawk-eco" > go.work
155+
@echo "go 1.26.4" > go.work
156156
@echo "" >> go.work
157157
@echo "use (" >> go.work
158158
@echo " ." >> go.work
@@ -219,8 +219,8 @@ build-static: ## Build fully static binaries for Linux (musl-compatible)
219219
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -trimpath -ldflags="$(LDFLAGS)" -o bin/$(NAME)-linux-amd64-static $(MAIN_PKG)
220220
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -trimpath -ldflags="$(LDFLAGS)" -o bin/$(NAME)-linux-arm64-static $(MAIN_PKG)
221221

222-
size-check: build ## Report binary size and warn if over threshold (50MB)
222+
size-check: build ## Report binary size and warn if over threshold (100MB, matching CI).
223223
@SIZE=$$(stat -f%z bin/$(NAME) 2>/dev/null || stat -c%s bin/$(NAME) 2>/dev/null); \
224224
MB=$$(echo "scale=1; $$SIZE / 1048576" | bc); \
225225
echo "Binary size: $${MB} MB"; \
226-
if [ $$SIZE -gt 52428800 ]; then echo "WARNING: binary exceeds 50MB"; exit 1; fi
226+
if [ $$SIZE -gt 104857600 ]; then echo "ERROR: binary exceeds 100MB (CI threshold)"; exit 1; fi

deploy/docker/docker-compose.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,17 @@ services:
55
build:
66
context: ../../
77
dockerfile: Dockerfile
8+
args:
9+
# Optional: set VERSION/COMMIT/BUILD_DATE to stamp the binary.
10+
# Defaults in the Dockerfile produce "dev"/"none"/"unknown".
11+
VERSION: ${VERSION:-dev}
12+
COMMIT: ${COMMIT:-none}
13+
BUILD_DATE: ${BUILD_DATE:-unknown}
814
image: ghcr.io/graycodeai/hawk:dev
15+
# Override the Dockerfile's default `CMD ["--help"]` so the container
16+
# actually runs the HTTP/SSE daemon. `--host 0.0.0.0` is required for
17+
# the published port to be reachable from outside the container.
18+
command: ["daemon", "start", "--host", "0.0.0.0", "--port", "4590"]
919
ports:
1020
- "4590:4590"
1121
environment:

external/eyrie

Submodule eyrie updated from b455064 to cc782e4

external/inspect

external/sight

Submodule sight updated from 2f2d408 to c0ee67f

external/tok

Submodule tok updated from cd29254 to 138f7e4

external/trace

Submodule trace updated from 55c2519 to 6c99b54

external/yaad

Submodule yaad updated from d76ee40 to df99a3a

scripts/smoke-hawk.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ set +o pipefail
2121
"$BIN" path >/dev/null 2>&1 || true
2222
set -o pipefail
2323

24-
echo "== hawk yaad =="
25-
"$BIN" yaad --limit 2 >/dev/null || true
26-
"$BIN" yaad search decision --limit 2 >/dev/null || true
27-
2824
echo "== ecosystem tests =="
2925
go test ./internal/config/ -run TestFormatEcosystemPanel -count=1
3026
go test ./cmd/ -run 'TestDoctor|TestYaad|TestEcosystem|TestPath' -count=1

0 commit comments

Comments
 (0)