Skip to content

Commit a78decd

Browse files
authored
Build multi-platform image using SUSE BCI image (#58)
* Instead of trying to build the binary for the target platform using the image for build platform arch, build the binary directly using the image with the right arch. * For image scanning build the multi-arch image, push it to an anonymous & ephemeral Docker image registry * Enable BATS test to use the built image for testing
1 parent 7e612e8 commit a78decd

File tree

5 files changed

+24
-31
lines changed

5 files changed

+24
-31
lines changed

.github/workflows/pr-workflow.yaml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,21 +61,23 @@ jobs:
6161
id: meta
6262
uses: docker/metadata-action@v5
6363
with:
64+
# ttl.sh is an anonymous & ephemeral Docker image registry,
65+
# check https://ttl.sh for more infos
6466
images: |
65-
registry.cloud.qdrant.io/library/qdrant-migration
67+
ttl.sh/qdrant-migration-${{ steps.extract_build_info.outputs.commit_short }}
6668
tags: |
67-
type=raw,value=dev
69+
type=raw,value=1h
6870
69-
- name: Build and push container image
71+
- name: Build and push container images
7072
uses: docker/build-push-action@v6
7173
id: build-and-push
7274
with:
7375
context: .
74-
push: false
75-
load: true
76-
sbom: false
76+
push: true
77+
load: false
78+
sbom: true
7779
provenance: false
78-
platforms: linux/amd64
80+
platforms: linux/amd64,linux/arm64
7981
labels: ${{ steps.meta.outputs.labels }}
8082
tags: ${{ steps.meta.outputs.tags }}
8183
build-args: |
@@ -85,7 +87,7 @@ jobs:
8587
- name: Run Trivy vulnerability scanner
8688
uses: aquasecurity/trivy-action@master
8789
with:
88-
image-ref: registry.cloud.qdrant.io/library/qdrant-migration:dev
90+
image-ref: ttl.sh/qdrant-migration-${{ steps.extract_build_info.outputs.commit_short }}:1h
8991
format: 'table'
9092
exit-code: '1'
9193
ignore-unfixed: true
@@ -98,4 +100,4 @@ jobs:
98100
bats-version: 1.11.1
99101

100102
- name: Integration tests
101-
run: make test_integration
103+
run: make test_integration DEV_IMAGE_REF=ttl.sh/qdrant-migration-${{ steps.extract_build_info.outputs.commit_short }}:1h

Dockerfile

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,18 @@
11
# syntax=docker/dockerfile:1
22
ARG BUILDKIT_SBOM_SCAN_CONTEXT=true
33
ARG BUILDKIT_SBOM_SCAN_STAGE=builder
4-
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.24 AS builder
4+
FROM registry.suse.com/bci/golang:1.24 AS builder
55

6-
ARG TARGETPLATFORM
7-
ARG BUILDPLATFORM
8-
ARG TARGETOS
9-
ARG TARGETARCH
106
ARG VERSION
117
ARG BUILD
128

13-
RUN apt-get update && case "${TARGETARCH}" in \
14-
amd64) apt-get install -y gcc-x86-64-linux-gnu ;; \
15-
arm64) apt-get install -y gcc-aarch64-linux-gnu ;; \
16-
esac && rm -rf /var/lib/apt/lists/*
17-
189
COPY . /app
1910

2011
WORKDIR /app
2112

22-
RUN case "${TARGETARCH}" in \
23-
amd64) CC=x86_64-linux-gnu-gcc ;; \
24-
arm64) CC=aarch64-linux-gnu-gcc ;; \
25-
esac && \
26-
CGO_ENABLED=1 GOOS=${TARGETOS} GOARCH=${TARGETARCH} CC=$CC \
27-
go build -ldflags "-X 'main.projectVersion=${VERSION:-0.0.0}' -X 'main.projectBuild=${BUILD:-dev}'" -o bin/qdrant-migration main.go
13+
RUN CGO_ENABLED=1 go build -ldflags "-X 'main.projectVersion=${VERSION:-0.0.0}' -X 'main.projectBuild=${BUILD:-dev}'" -o bin/qdrant-migration main.go
2814

29-
FROM --platform=${TARGETPLATFORM:-linux/amd64} registry.suse.com/bci/bci-minimal:15.6
15+
FROM registry.suse.com/bci/bci-minimal:15.6
3016

3117
COPY --from=builder /app/bin/qdrant-migration /opt/
3218

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
PLATFORMS=darwin/amd64 darwin/arm64 linux/amd64 linux/arm64 windows/amd64 windows/arm64
22
VERSION=0.0.0
33
BUILD=dev
4+
DEV_IMAGE_REF ?= registry.cloud.qdrant.io/library/qdrant-migration:dev
45

56
## Location to install dependencies to
67
LOCALBIN ?= $(shell pwd)/bin
@@ -38,7 +39,7 @@ test: fmt vet lint test_integration
3839

3940
.PHONY: test_integration
4041
test_integration:
41-
bats --print-output-on-failure integration_tests
42+
IMAGE_REF=$(DEV_IMAGE_REF) bats --print-output-on-failure integration_tests
4243

4344
.PHONY: test_unit
4445
test_unit:

integration_tests/milvus_to_qdrant.bats

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
IMAGE_REF=${IMAGE_REF-registry.cloud.qdrant.io/library/qdrant-migration:dev}
2+
13
setup() {
24
docker compose -f integration_tests/compose_files/milvus_to_qdrant.yaml up -d --wait
35
}
@@ -48,7 +50,7 @@ teardown() {
4850
echo "Wait for a few seconds to load the vectors"
4951
sleep 5
5052

51-
run docker run --net=host --rm registry.cloud.qdrant.io/library/qdrant-migration:dev milvus \
53+
run docker run --net=host --rm $IMAGE_REF milvus \
5254
--milvus.url 'http://localhost:19530' \
5355
--milvus.collection 'migrate_collection' \
5456
--qdrant.url 'http://localhost:6334' \

integration_tests/qdrant_to_qdrant.bats

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
IMAGE_REF=${IMAGE_REF-registry.cloud.qdrant.io/library/qdrant-migration:dev}
2+
13
@test "Migrate Qdrant to Qdrant" {
24
run curl -X PUT http://localhost:7333/collections/source_collection \
35
-H 'Content-Type: application/json' \
@@ -47,7 +49,7 @@
4749

4850
echo $source_result
4951

50-
run docker run --net=host --rm registry.cloud.qdrant.io/library/qdrant-migration:dev qdrant --source.url http://localhost:7334 --source.collection source_collection --target.url http://localhost:8334 --target.collection target_collection --migration.batch-size 1
52+
run docker run --net=host --rm $IMAGE_REF qdrant --source.url http://localhost:7334 --source.collection source_collection --target.url http://localhost:8334 --target.collection target_collection --migration.batch-size 1
5153
[ $status -eq 0 ]
5254

5355
run curl -s -X POST http://localhost:8333/collections/target_collection/points/scroll \
@@ -74,13 +76,13 @@
7476
[ $status -eq 0 ]
7577

7678

77-
run docker run --net=host --rm registry.cloud.qdrant.io/library/qdrant-migration:dev qdrant --source.url http://localhost:7334 --source.collection source_collection --target.url http://localhost:7334 --target.collection source_collection --migration.batch-size 1
79+
run docker run --net=host --rm $IMAGE_REF qdrant --source.url http://localhost:7334 --source.collection source_collection --target.url http://localhost:7334 --target.collection source_collection --migration.batch-size 1
7880
[ $status -ne 0 ]
7981
[[ "$output" =~ "source and target collections must be different" ]]
8082
}
8183

8284
@test "Migrating with invalid port should fail" {
83-
run docker run --net=host --rm registry.cloud.qdrant.io/library/qdrant-migration:dev qdrant --source.url http://localhost:invalid --source.collection source_collection --target.url http://localhost:8334 --target.collection source_collection --migration.batch-size 1
85+
run docker run --net=host --rm $IMAGE_REF qdrant --source.url http://localhost:invalid --source.collection source_collection --target.url http://localhost:8334 --target.collection source_collection --migration.batch-size 1
8486
[ $status -ne 0 ]
8587
[[ "$output" =~ "invalid port \":invalid\" after host" ]]
8688
}

0 commit comments

Comments
 (0)