mirror of
https://github.com/hanzoai/gateway.git
synced 2026-10-30 15:04:44 +00:00
Modules declare go 1.27.1 and the build images follow. go fix applied the modernizers; omitzero is not applied, since it changes what the JSON says. Co-authored-by: Hanzo Dev <[email protected]>
44 lines
1.7 KiB
Docker
44 lines
1.7 KiB
Docker
# syntax=docker/dockerfile:1
|
|
# admin-api — god-mode backend for the Hanzo Operator console (admin.hanzo.ai).
|
|
# Aggregates every product into the ZAP-native datastore and serves the
|
|
# superadmin-gated /v1/admin/* read API. Reuses github.com/hanzoai/gateway/v2
|
|
# iamauth + github.com/hanzoai/datastore-go/v2.
|
|
ARG GOLANG_VERSION=1.27.1
|
|
ARG ALPINE_VERSION=3.23
|
|
|
|
FROM --platform=$BUILDPLATFORM golang:${GOLANG_VERSION}-alpine${ALPINE_VERSION} AS builder
|
|
ARG TARGETOS TARGETARCH
|
|
|
|
RUN apk --no-cache add git
|
|
|
|
COPY . /app
|
|
WORKDIR /app
|
|
|
|
# Private cross-repo modules (hanzoai/cloud, hanzoai/datastore-go) are fetched
|
|
# via authenticated git (gh_token secret). Everything else resolves through the
|
|
# public proxy and is verified against sum.golang.org.
|
|
ENV GOPRIVATE=github.com/hanzoai/*
|
|
|
|
RUN --mount=type=cache,target=/go/pkg/mod \
|
|
--mount=type=cache,target=/root/.cache/go-build \
|
|
--mount=type=secret,id=gh_token \
|
|
if [ -s /run/secrets/gh_token ]; then \
|
|
export GIT_CONFIG_COUNT=1 \
|
|
GIT_CONFIG_KEY_0="url.https://x-access-token:$(cat /run/secrets/gh_token)@github.com/.insteadOf" \
|
|
GIT_CONFIG_VALUE_0="https://github.com/"; \
|
|
fi; \
|
|
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
|
|
go build -trimpath -ldflags="-s -w" -o /admin-api ./cmd/admin-api
|
|
|
|
FROM alpine:${ALPINE_VERSION}
|
|
LABEL maintainer="[email protected]"
|
|
RUN apk upgrade --no-cache && \
|
|
apk add --no-cache ca-certificates tzdata wget && \
|
|
adduser -u 1000 -S -D -H adminapi
|
|
COPY --from=builder /admin-api /usr/bin/admin-api
|
|
USER 1000
|
|
EXPOSE 8080
|
|
HEALTHCHECK --interval=15s --timeout=3s --start-period=5s --retries=3 \
|
|
CMD wget -qO- http://localhost:8080/v1/admin/healthz || exit 1
|
|
ENTRYPOINT ["/usr/bin/admin-api"]
|