Skip to content

Agent Mesh

1.3 KB
Raw Blame
# Stage 1: Build
FROM --platform=$BUILDPLATFORM golang:1.27.2@sha256:820153096fda4de6ac1b7194d12e416b7dd8f4e9a33d17e0345b111b945162d8 AS builder
WORKDIR /app
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod go mod download
COPY . .
ARG VERSION=devel
ARG TARGETOS=linux
ARG TARGETARCH
RUN --mount=type=cache,target=/go/pkg/mod \
    --mount=type=cache,target=/root/.cache/go-build \
    CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -buildvcs=false -ldflags="-X github.com/google/agentmesh/internal/version.Version=${VERSION}" -o agentmesh-one ./cmd/agentmesh-one
# Pre-create the data dir owned by the nonroot UID so that a fresh
# named/anonymous volume mounted over it inherits writable ownership instead
# of defaulting to root.
RUN mkdir -p /data-seed && chown 65532:65532 /data-seed

# Stage 2: Final
FROM gcr.io/distroless/static:nonroot@sha256:25ac8f0c3b2334a9eb05452266bd4697864a8c8ef0ef71e5e6480d7f92868329
WORKDIR /tmp
COPY --from=builder --chown=nonroot:nonroot /app/agentmesh-one /
COPY --from=builder --chown=nonroot:nonroot /data-seed /data
USER nonroot:nonroot
ENTRYPOINT ["/agentmesh-one"]
# Default args only: a container needs a stable published port, and overriding
# the command line must re-point --data-dir at a writable mount or the sqlite
# db lands on the container filesystem.
CMD ["--data-dir", "/data", "--port", "8080"]