Skip to content

Commit c71d250

Browse files
committed
add initial binary implementation for vmcp
This will be the entrypoint for the vmcp component See https://github.com/stacklok/stacklok-epics/issues/153
1 parent 0c44157 commit c71d250

File tree

8 files changed

+822
-5
lines changed

8 files changed

+822
-5
lines changed

.github/ko-ci.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ builds:
1919

2020
- id: thv-proxyrunner
2121
dir: ./cmd/thv-proxyrunner
22+
ldflags:
23+
- -s -w
24+
- -X github.com/stacklok/toolhive/pkg/versions.Version={{.Env.VERSION}}
25+
- -X github.com/stacklok/toolhive/pkg/versions.Commit={{.Env.COMMIT}}
26+
- -X github.com/stacklok/toolhive/pkg/versions.BuildDate={{.Env.BUILD_DATE}}
27+
- -X github.com/stacklok/toolhive/pkg/versions.BuildType=release
28+
29+
- id: vmcp
30+
dir: ./cmd/vmcp
2231
ldflags:
2332
- -s -w
2433
- -X github.com/stacklok/toolhive/pkg/versions.Version={{.Env.VERSION}}

.github/workflows/image-build-and-publish.yml

Lines changed: 81 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,12 +305,10 @@ jobs:
305305
run: |
306306
TAG=$(echo "${{ steps.version-string.outputs.tag }}" | sed 's/+/_/g')
307307
TAGS="-t $TAG"
308-
309308
# Add latest tag only if building from a tag
310309
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
311310
TAGS="$TAGS -t latest"
312311
fi
313-
314312
KO_DOCKER_REPO=$BASE_REPO ko build --platform=linux/amd64,linux/arm64 --bare $TAGS ./cmd/thv-proxyrunner \
315313
--image-label=org.opencontainers.image.source=https://github.com/stacklok/toolhive,org.opencontainers.image.title="toolhive-proxyrunner",org.opencontainers.image.vendor=Stacklok
316314
@@ -321,7 +319,87 @@ jobs:
321319
TAG=$(echo "${{ steps.version-string.outputs.tag }}" | sed 's/+/_/g')
322320
# Sign the ko image
323321
cosign sign -y $BASE_REPO:$TAG
324-
322+
323+
# Sign the latest tag if building from a tag
324+
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
325+
cosign sign -y $BASE_REPO:latest
326+
fi
327+
328+
vmcp-image-build-and-publish:
329+
name: Build and Publish Virtual MCP Server Image
330+
runs-on: ubuntu-latest
331+
permissions:
332+
contents: write
333+
packages: write
334+
id-token: write
335+
336+
env:
337+
BASE_REPO: "ghcr.io/stacklok/toolhive/vmcp"
338+
339+
steps:
340+
- name: Checkout repository
341+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
342+
343+
- name: Set up Go
344+
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6
345+
with:
346+
go-version-file: go.mod
347+
348+
- name: Compute version number
349+
id: version-string
350+
run: |
351+
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
352+
# For main branch, use semver with -dev suffix
353+
echo "tag=0.0.1-dev.$GITHUB_RUN_NUMBER+$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
354+
elif [[ "${{ github.ref }}" == refs/tags/* ]]; then
355+
# For tags, use the tag as is (assuming it's semver)
356+
TAG="${{ github.ref_name }}"
357+
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
358+
else
359+
# For other branches, use branch name and run number
360+
BRANCH="${{ github.ref_name }}"
361+
echo "tag=0.0.1-$BRANCH.$GITHUB_RUN_NUMBER+$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
362+
fi
363+
364+
- name: Login to GitHub Container Registry
365+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
366+
with:
367+
registry: ghcr.io
368+
username: ${{ github.actor }}
369+
password: ${{ secrets.GITHUB_TOKEN }}
370+
371+
- name: Setup ko
372+
uses: ko-build/setup-ko@d006021bd0c28d1ce33a07e7943d48b079944c8d # v0.9
373+
374+
- name: Install Cosign
375+
uses: sigstore/cosign-installer@7e8b541eb2e61bf99390e1afd4be13a184e9ebc5 # v3.10.1
376+
377+
- name: Build and Push Image to GHCR
378+
env:
379+
VERSION: ${{ steps.version-string.outputs.tag }}
380+
COMMIT: ${{ github.sha }}
381+
BUILD_DATE: ${{ github.event.head_commit.timestamp }}
382+
KO_CONFIG_PATH: ${{ github.workspace }}/.github/ko-ci.yml
383+
run: |
384+
TAG=$(echo "${{ steps.version-string.outputs.tag }}" | sed 's/+/_/g')
385+
TAGS="-t $TAG"
386+
387+
# Add latest tag only if building from a tag
388+
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
389+
TAGS="$TAGS -t latest"
390+
fi
391+
392+
KO_DOCKER_REPO=$BASE_REPO ko build --platform=linux/amd64,linux/arm64 --bare $TAGS ./cmd/vmcp \
393+
--image-label=org.opencontainers.image.source=https://github.com/stacklok/toolhive,org.opencontainers.image.title="toolhive-vmcp",org.opencontainers.image.vendor=Stacklok
394+
395+
- name: Sign Image with Cosign
396+
# This step uses the identity token to provision an ephemeral certificate
397+
# against the sigstore community Fulcio instance.
398+
run: |
399+
TAG=$(echo "${{ steps.version-string.outputs.tag }}" | sed 's/+/_/g')
400+
# Sign the ko image
401+
cosign sign -y $BASE_REPO:$TAG
402+
325403
# Sign the latest tag if building from a tag
326404
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
327405
cosign sign -y $BASE_REPO:latest

Taskfile.yml

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,37 @@ tasks:
171171
cmds:
172172
- go install -ldflags "-s -w -X github.com/stacklok/toolhive/pkg/versions.Version={{.VERSION}} -X github.com/stacklok/toolhive/pkg/versions.Commit={{.COMMIT}} -X github.com/stacklok/toolhive/pkg/versions.BuildDate={{.BUILD_DATE}}" -v ./cmd/thv
173173

174+
build-vmcp:
175+
desc: Build the vmcp binary
176+
deps: [gen]
177+
vars:
178+
VERSION:
179+
sh: git describe --tags --always --dirty --match "v*" || echo "dev"
180+
COMMIT:
181+
sh: git rev-parse --short HEAD || echo "unknown"
182+
BUILD_DATE: '{{dateInZone "2006-01-02T15:04:05Z" (now) "UTC"}}'
183+
cmds:
184+
- cmd: mkdir -p bin
185+
platforms: [linux, darwin]
186+
- cmd: go build -ldflags "-s -w -X github.com/stacklok/toolhive/pkg/versions.Version={{.VERSION}} -X github.com/stacklok/toolhive/pkg/versions.Commit={{.COMMIT}} -X github.com/stacklok/toolhive/pkg/versions.BuildDate={{.BUILD_DATE}}" -o bin/vmcp ./cmd/vmcp
187+
platforms: [linux, darwin]
188+
- cmd: cmd.exe /c mkdir bin
189+
platforms: [windows]
190+
ignore_error: true
191+
- cmd: go build -ldflags "-s -w -X github.com/stacklok/toolhive/pkg/versions.Version={{.VERSION}} -X github.com/stacklok/toolhive/pkg/versions.Commit={{.COMMIT}} -X github.com/stacklok/toolhive/pkg/versions.BuildDate={{.BUILD_DATE}}" -o bin/vmcp.exe ./cmd/vmcp
192+
platforms: [windows]
193+
194+
install-vmcp:
195+
desc: Install the vmcp binary to GOPATH/bin
196+
vars:
197+
VERSION:
198+
sh: git describe --tags --always --dirty --match "v*" || echo "dev"
199+
COMMIT:
200+
sh: git rev-parse --short HEAD || echo "unknown"
201+
BUILD_DATE: '{{dateInZone "2006-01-02T15:04:05Z" (now) "UTC"}}'
202+
cmds:
203+
- go install -ldflags "-s -w -X github.com/stacklok/toolhive/pkg/versions.Version={{.VERSION}} -X github.com/stacklok/toolhive/pkg/versions.Commit={{.COMMIT}} -X github.com/stacklok/toolhive/pkg/versions.BuildDate={{.BUILD_DATE}}" -v ./cmd/vmcp
204+
174205
all:
175206
desc: Run linting, tests, and build
176207
deps: [lint, test, build]
@@ -186,12 +217,18 @@ tasks:
186217
cmds:
187218
- ko build --local --bare ./cmd/thv
188219

220+
build-vmcp-image:
221+
desc: Build the vmcp image with ko
222+
env:
223+
KO_DOCKER_REPO: ghcr.io/stacklok/toolhive/vmcp
224+
cmds:
225+
- ko build --local --bare ./cmd/vmcp
189226

190227
build-egress-proxy:
191228
desc: Build the egress proxy container image
192229
cmds:
193230
- docker build --load -t ghcr.io/stacklok/toolhive/egress-proxy:local containers/egress-proxy/
194231

195232
build-all-images:
196-
desc: Build all container images (main app and egress proxy)
197-
deps: [build-image, build-egress-proxy]
233+
desc: Build all container images (main app, vmcp, and egress proxy)
234+
deps: [build-image, build-vmcp-image, build-egress-proxy]

0 commit comments

Comments
 (0)