1- # ## Stage 0: build krane
2- FROM golang:1.26-alpine AS krane-builder
3-
4- ENV KRANE_VERSION=v0.21.2
5- WORKDIR /build
6-
7- RUN apk add --no-cache git && \
8- git clone --depth 1 --branch $KRANE_VERSION \
9- https://github.com/google/go-containerregistry.git
10-
11- WORKDIR /build/go-containerregistry/cmd/krane
12-
13- RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /build/krane .
14-
1+ # ## Stage 0: build the skills-init Go binary
2+ ARG BASE_IMAGE_REGISTRY=cgr.dev
3+ ARG BUILDPLATFORM
4+ FROM --platform=$BUILDPLATFORM $BASE_IMAGE_REGISTRY/chainguard/go:latest AS builder
5+ ARG TARGETARCH
6+ ARG TARGETOS
7+
8+ WORKDIR /workspace
9+
10+ COPY go.mod go.sum ./
11+ RUN --mount=type=cache,target=/root/go/pkg/mod,rw \
12+ --mount=type=cache,target=/root/.cache/go-build,rw \
13+ go mod download
14+
15+ COPY api/ api/
16+ COPY core/ core/
17+ COPY adk/ adk/
18+
19+ ARG LDFLAGS
20+ RUN --mount=type=cache,target=/root/go/pkg/mod,rw \
21+ --mount=type=cache,target=/root/.cache/go-build,rw \
22+ CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} \
23+ go build -a -trimpath -ldflags "$LDFLAGS" -o /skills-init ./core/cmd/skills-init
24+
25+ # ## Stage 1: runtime
1526FROM alpine:3.23
1627
1728ARG PYTHON_UID=1001
1829ARG PYTHON_GID=1001
1930
20- RUN apk upgrade --no-cache && apk add --no-cache git jq
21- COPY --from=krane-builder /build/krane /usr/local/bin/krane
31+ # git is invoked by skills-init via exec.Command with an argv vector — never
32+ # through a shell — so the only attack surface here is git itself. OCI fetch
33+ # uses the in-process go-containerregistry library, so krane and jq are gone.
34+ RUN apk upgrade --no-cache && apk add --no-cache git openssh-client ca-certificates
35+
36+ COPY --from=builder /skills-init /usr/local/bin/skills-init
2237
2338# Run as the same UID/GID as the main agent container (python user) so that
2439# files written to the shared /skills volume are readable by the main container.
@@ -28,3 +43,5 @@ RUN addgroup -g ${PYTHON_GID} pythongroup && \
2843 adduser -u ${PYTHON_UID} -G pythongroup -s /bin/sh -D python
2944
3045USER ${PYTHON_UID}:${PYTHON_GID}
46+
47+ ENTRYPOINT ["/usr/local/bin/skills-init" ]
0 commit comments