-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
60 lines (49 loc) · 2.37 KB
/
Copy pathDockerfile
File metadata and controls
60 lines (49 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Build stage
FROM golang:1.26.4-alpine AS builder
RUN apk add --no-cache git ca-certificates tzdata
WORKDIR /build
# GrayCodeAI sibling modules are unpublished at their current code (the public proxy
# froze v0.1.0 at old commits). Resolve them locally via a generated go.work
# (use . + replace => ./external/<repo>), bypassing the proxy/sumdb entirely.
ENV GOPRIVATE=github.com/GrayCodeAI/* \
GONOSUMDB=github.com/GrayCodeAI/* \
GONOSUMCHECK=1
# Build-time provenance (passed by .github/workflows/docker.yml or `docker build
# --build-arg VERSION=... --build-arg COMMIT=... --build-arg BUILD_DATE=...`).
# Default to "dev"/"none"/"unknown" so plain `docker build .` still produces a
# runnable image — matching the cmd/hawk/main.go ldflags fallbacks.
ARG VERSION=dev
ARG COMMIT=none
ARG BUILD_DATE=unknown
COPY . .
# external/<repo> are committed submodules pinned to the integrated revisions
# (populated by `submodules: recursive` in .github/workflows/docker.yml, or
# `git submodule update --init --recursive` for a local `docker build`). Build
# against those pinned checkouts via a generated go.work — the committed
# go.work/go.work.sum are excluded by .dockerignore, and the public proxy froze
# v0.1.0 at older commits. Do NOT run 'go mod download' first.
#
# main.Version / main.Commit / main.BuildDate are baked in from the ARGs above;
# this is the only correct source — `git describe` would always return empty
# because `.dockerignore` excludes `.git/` from the build context.
RUN rm -f go.work go.work.sum && \
{ echo "go 1.26.4"; echo; echo "use ."; echo; echo "replace ("; \
for repo in hawk-core-contracts eyrie inspect sight tok trace yaad; do \
echo " github.com/GrayCodeAI/${repo} => ./external/${repo}"; \
done; echo ")"; } > go.work && \
CGO_ENABLED=0 GOOS=linux go build -trimpath \
-ldflags="-s -w \
-X main.Version=${VERSION} \
-X main.Commit=${COMMIT} \
-X main.BuildDate=${BUILD_DATE}" \
-o hawk ./cmd/hawk
# Runtime stage — Alpine (hawk requires git + bash for workspace operations; distroless excluded)
FROM alpine:3.21
RUN apk add --no-cache ca-certificates git bash tini && \
adduser -D -u 1000 -h /home/hawk hawk
COPY --from=builder /build/hawk /usr/local/bin/hawk
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
USER hawk
WORKDIR /workspace
ENTRYPOINT ["tini", "--", "hawk"]
CMD ["--help"]