Skip to content

Commit 59a84f5

Browse files
authored
Merge pull request #255 from dgageot/build-host-binary-in-docker
Compile the host-binary in docker
2 parents 6ad01bf + 0673a84 commit 59a84f5

File tree

4 files changed

+22
-12
lines changed

4 files changed

+22
-12
lines changed

.github/workflows/extension.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ jobs:
1212
- name: Checkout code
1313
uses: actions/checkout@v4
1414

15-
- name: Build Host Binary
16-
run: |
17-
cd src/extension
18-
make cross
19-
2015
- name: Set up QEMU
2116
uses: docker/setup-qemu-action@v3
2217

@@ -37,3 +32,6 @@ jobs:
3732
tags: docker/labs-ai-tools-for-devs:${{ github.event.release.tag_name }}
3833
file: src/extension/Dockerfile
3934
context: src/extension
35+
build-contexts: |
36+
prompts=../../prompts
37+

src/extension/.dockerignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
ui/node_modules
2-
dist/install/_internal
2+
dist/install/_internal
3+
/**/dist/*
4+
/**/bin/host-binary
5+
/**/Makefile

src/extension/Dockerfile

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,23 @@
22

33
FROM alpine:3.21@sha256:a8560b36e8b8210634f77d9f7f9efd7ffa463e380b75e2e74aff4511df3ef88c AS alpine
44

5+
FROM --platform=$BUILDPLATFORM golang:1.24.2-alpine3.21@sha256:7772cb5322baa875edd74705556d08f0eeca7b9c4b5367754ce3f2f00041ccee AS go-builder
6+
WORKDIR /app
7+
COPY host-binary ./
8+
RUN --mount=type=cache,target=/root/.cache/go-build <<EOT
9+
GOOS=linux CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /dist/linux/host-binary ./cmd
10+
GOOS=darwin CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /dist/darwin/host-binary ./cmd
11+
GOOS=windows CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /dist/windows/host-binary.exe ./cmd
12+
EOT
13+
514
FROM --platform=$BUILDPLATFORM node:23-alpine3.21@sha256:86703151a18fcd06258e013073508c4afea8e19cd7ed451554221dd00aea83fc AS client-builder
615
WORKDIR /ui
716
COPY ui/package.json ui/package-lock.json ./
817
RUN --mount=type=cache,target=/root/.npm npm ci
918
COPY ui/. .
1019
RUN --mount=type=cache,target=/root/.npm npm run build
1120

12-
FROM alpine AS pull-catalog-images
21+
FROM --platform=$BUILDPLATFORM alpine AS pull-catalog-images
1322
RUN apk add --no-cache curl yq
1423
COPY --from=prompts catalog.yaml /
1524
RUN <<EOT
@@ -38,8 +47,8 @@ LABEL org.opencontainers.image.title="Docker MCP Toolkit" \
3847
com.docker.extension.changelog="Added MCP catalog"
3948

4049
COPY docker-compose.yaml metadata.json extension-icon.svg /
41-
COPY host-binary/dist/windows-${TARGETARCH}/host-binary.exe /windows/host-binary.exe
42-
COPY host-binary/dist/darwin-${TARGETARCH}/host-binary /darwin/host-binary
43-
COPY host-binary/dist/linux-${TARGETARCH}/host-binary /linux/host-binary
50+
COPY --from=go-builder /dist/linux/host-binary /linux/host-binary
51+
COPY --from=go-builder /dist/darwin/host-binary /darwin/host-binary
52+
COPY --from=go-builder /dist/windows/host-binary.exe /windows/host-binary.exe
4453
COPY --from=pull-catalog-images /icons ui/static-assets
4554
COPY --from=client-builder /ui/build ui

src/extension/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ bin:
1313
cross:
1414
cd host-binary && $(MAKE) cross
1515

16-
build-extension: cross ## Build service image to be deployed as a desktop extension
16+
build-extension: ## Build service image to be deployed as a desktop extension
1717
docker buildx build --build-context prompts=../../prompts --load --tag=$(IMAGE):$(TAG) .
1818

1919
install-extension: build-extension ## Install the extension
@@ -25,7 +25,7 @@ update-extension: build-extension ## Update the extension
2525
prepare-buildx: ## Create buildx builder for multi-arch build, if not exists
2626
docker buildx inspect $(BUILDER) || docker buildx create --name=$(BUILDER) --driver=docker-container --driver-opt=network=host
2727

28-
push-extension: prepare-buildx cross ## Build & Upload extension image to hub. Do not push if tag already exists: make push-extension tag=0.1
28+
push-extension: prepare-buildx ## Build & Upload extension image to hub. Do not push if tag already exists: make push-extension tag=0.1
2929
docker pull $(IMAGE):$(TAG) && echo "Failure: Tag already exists" || docker buildx build --build-context prompts=../../prompts --push --builder=$(BUILDER) --platform=linux/amd64,linux/arm64 --build-arg TAG=$(TAG) --tag=$(IMAGE):$(TAG) .
3030

3131
help: ## Show this help

0 commit comments

Comments
 (0)