Skip to content

Commit b67d2db

Browse files
authored
docs/add examples (#9)
* chore: add microservice architecture scaffolding Add .env.example, api/openapi.yaml, deploy/docker/docker-compose.yml, docs/architecture.md, and .github/workflows/docker.yml for GHCI build+push CI. * fix: resolve lint, module hygiene, and markdown CI failures Fix errcheck on rows.Close(), simplify bool comparison, remove unused knownFields var, fix empty badge links, and run go work sync to update module consistency. * fix: exclude go.work from Docker build context hawk's go.work references external/ symlinks to sibling repos that don't exist in the Docker build context. * fix: add Windows support for safewrite and update go.sum Add //go:build !windows constraint to safewrite.go (uses unix syscalls), create safewrite_windows.go with portable fallback, skip tests on Windows, and run go mod download to add missing go.sum entry for golang.org/x/tools. * fix: gofumpt format safewrite_windows.go and add missing go.sum entry The Windows stub needed formatting. Also add the /go.mod hash for golang.org/x/tools v0.45.0 that was missing from go.sum, causing the Docker build to fail. * fix: clone eyrie in Docker build for unpublished packages hawk depends on eyrie packages (credentials, runtime, setup, catalog/registry) that aren't in the published v0.5.0. Clone eyrie into the builder and add a replace directive. * fix: use go mod tidy in Docker to resolve eyrie replace directive The replace directive needs go mod tidy (not just download) to resolve all transitive dependencies from the local eyrie clone. Use -mod=mod to allow go.mod changes during build. * fix: add eyrie replace directive after source copy COPY . . was overwriting go.mod that had the replace directive. Move the replace + go mod tidy to after the source copy. * docs: add examples directory with usage guide Add examples/README.md demonstrating basic usage, advanced features, and MCP integration.
1 parent 96ed84b commit b67d2db

16 files changed

Lines changed: 626 additions & 116 deletions

File tree

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ hawk_bin
99
hawk_test_bin
1010
coverage.out
1111
coverage.html
12+
go.work
13+
go.work.sum

.env.example

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# hawk daemon environment variables — copy to .env and fill in
2+
HAWK_DAEMON_API_KEY=
3+
HAWK_DAEMON_PORT=4590
4+
HAWK_DAEMON_HOST=127.0.0.1
5+
# Eyrie connection (LLM provider runtime)
6+
EYRIE_API_KEY=
7+
EYRIE_BASE_URL=http://localhost:8080
8+
# Yaad connection (memory service)
9+
YAAD_API_KEY=
10+
YAAD_ADDR=127.0.0.1:3456

.github/workflows/docker.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Docker
2+
3+
on:
4+
push:
5+
branches: [main]
6+
tags: ["v*"]
7+
pull_request:
8+
branches: [main]
9+
paths:
10+
- "Dockerfile"
11+
- "**.go"
12+
- "go.mod"
13+
- "go.sum"
14+
15+
permissions:
16+
contents: read
17+
packages: write
18+
19+
env:
20+
REGISTRY: ghcr.io
21+
IMAGE_NAME: graycodeai/hawk
22+
23+
jobs:
24+
build-and-push:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v4
28+
29+
- name: Set up Docker Buildx
30+
uses: docker/setup-buildx-action@v3
31+
32+
- name: Log in to GHCR
33+
if: github.event_name != 'pull_request'
34+
uses: docker/login-action@v3
35+
with:
36+
registry: ${{ env.REGISTRY }}
37+
username: ${{ github.actor }}
38+
password: ${{ secrets.GITHUB_TOKEN }}
39+
40+
- name: Docker metadata
41+
id: meta
42+
uses: docker/metadata-action@v5
43+
with:
44+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
45+
tags: |
46+
type=ref,event=branch
47+
type=semver,pattern={{version}}
48+
type=semver,pattern={{major}}.{{minor}}
49+
type=sha,prefix=sha-
50+
51+
- name: Build and push
52+
uses: docker/build-push-action@v6
53+
with:
54+
context: .
55+
push: ${{ github.event_name != 'pull_request' }}
56+
tags: ${{ steps.meta.outputs.tags }}
57+
labels: ${{ steps.meta.outputs.labels }}
58+
cache-from: type=gha
59+
cache-to: type=gha,mode=max
60+
build-args: |
61+
VERSION=${{ github.ref_name }}
62+
COMMIT=${{ github.sha }}
63+
BUILD_DATE=${{ github.event.head_commit.timestamp }}

Dockerfile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,18 @@ FROM golang:1.26.3-alpine AS builder
44
RUN apk add --no-cache git ca-certificates tzdata
55

66
WORKDIR /build
7+
8+
# Clone eyrie (unpublished dependency with local-only packages)
9+
RUN git clone --depth=1 https://github.com/GrayCodeAI/eyrie.git /eyrie
10+
711
COPY go.mod go.sum ./
8-
RUN go mod download && go mod verify
12+
RUN go mod download
913

1014
COPY . .
11-
RUN CGO_ENABLED=0 GOOS=linux go build -trimpath \
15+
# Add replace after source copy so it doesn't get overwritten
16+
RUN echo "" >> go.mod && echo "replace github.com/GrayCodeAI/eyrie => /eyrie" >> go.mod && go mod tidy
17+
18+
RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -mod=mod \
1219
-ldflags="-s -w -X main.Version=$(git describe --tags --always 2>/dev/null || echo dev)" \
1320
-o hawk .
1421

0 commit comments

Comments
 (0)