Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

Commit e0eee4c

Browse files
committed
fix build:
- added tokenizer lib linking - go package pulling from neuralmagic internal repo
1 parent ca12b30 commit e0eee4c

File tree

5 files changed

+44
-6
lines changed

5 files changed

+44
-6
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,8 @@ go.work.sum
3131
# generated docs
3232
site
3333

34+
# tokenizer lib
35+
lib
36+
37+
# local configuration files
3438
.envrc

.tekton/buildah-build.yaml

+13-2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ spec:
4444
USERNAME=$(jq -r '.auths["quay.io"].username' /root/.docker/config.json)
4545
PASSWORD=$(jq -r '.auths["quay.io"].password' /root/.docker/config.json)
4646
47+
echo "🔐 Extracting Git credentials from workspace..."
48+
GIT_USER=$(cat /workspace/git-auth/username)
49+
GIT_TOKEN=$(cat /workspace/git-auth/token)
50+
51+
if [ -z "$GIT_USER" ] || [ -z "$GIT_TOKEN" ]; then
52+
echo "❌ Error: Missing git-auth credentials"
53+
exit 1
54+
fi
55+
4756
if [ "$USERNAME" = "null" ] || [ "$PASSWORD" = "null" ]; then
4857
echo "❌ Error: Missing registry credentials"
4958
exit 1
@@ -56,8 +65,10 @@ spec:
5665
export DOCKER_CONFIG=/root/.docker
5766
export BUILDER=buildah
5867
export IMG=$(params.image_tag_base):$(params.dev-version)
59-
68+
export GIT_NM_USER=$GIT_USER
69+
export NM_TOKEN=$GIT_TOKEN
70+
6071
echo "🚀 Calling make buildah-build with IMG=$IMG..."
61-
make buildah-build IMG=$IMG
72+
make buildah-build IMG=$IMG
6273
6374
echo "$IMG" > /tekton/results/image-url

.tekton/go-build-task.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,8 @@ spec:
2828
git config --global url."https://${GIT_USER}:${GIT_TOKEN}@github.com".insteadOf "https://github.com"
2929
git config --global --add safe.directory "$(pwd)"
3030
31+
# required for go build with tokenizer lib linking
32+
dnf install -y gcc-c++ libstdc++ libstdc++-devel && dnf clean all
33+
3134
go env -w GOFLAGS=-buildvcs=false
3235
make build

.tekton/pipelinerun.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,8 @@ spec:
331331
workspace: registry-secret
332332
- name: container-storage
333333
workspace: container-storage
334+
- name: git-auth
335+
workspace: git-auth
334336

335337
- name: vulnerability-scan
336338
when:

Makefile

+22-4
Original file line numberDiff line numberDiff line change
@@ -439,11 +439,20 @@ lint: check-golangci-lint ## Run lint
439439
golangci-lint run
440440

441441
##@ Build
442+
LDFLAGS ?= -extldflags '-L$(shell pwd)/lib'
443+
CGO_ENABLED=1 # Enable CGO
444+
445+
.PHONY: download-tokenizer
446+
download-tokenizer: ## Download the HuggingFace tokenizer bindings.
447+
@echo "Downloading HuggingFace tokenizer bindings..."
448+
mkdir -p lib
449+
curl -L https://github.com/daulet/tokenizers/releases/download/v1.20.2/libtokenizers.$(TARGETOS)-$(TARGETARCH).tar.gz | tar -xz -C lib
450+
ranlib lib/*.a
442451

443452
.PHONY: build
444-
build: check-go ##
453+
build: check-go download-tokenizer ##
445454
@printf "\033[33;1m==== Building ====\033[0m\n"
446-
go build -o bin/epp cmd/epp/main.go cmd/epp/health.go
455+
go build -ldflags="$(LDFLAGS)" -o bin/epp cmd/epp/main.go cmd/epp/health.go
447456

448457
##@ Container Build/Push
449458

@@ -456,7 +465,12 @@ buildah-build: check-builder load-version-json ## Build and push image (multi-ar
456465
for arch in amd64; do \
457466
ARCH_TAG=$$FINAL_TAG-$$arch; \
458467
echo "📦 Building for architecture: $$arch"; \
459-
buildah build --arch=$$arch --os=linux --layers -t $(IMG)-$$arch . || exit 1; \
468+
buildah build \
469+
--arch=$$arch \
470+
--build-arg GIT_NM_USER=$(GIT_NM_USER) \
471+
--build-arg NM_TOKEN=$(NM_TOKEN) \
472+
--os=linux \
473+
--layers -t $(IMG)-$$arch . || exit 1; \
460474
echo "🚀 Pushing image: $(IMG)-$$arch"; \
461475
buildah push $(IMG)-$$arch docker://$(IMG)-$$arch || exit 1; \
462476
done; \
@@ -474,7 +488,11 @@ buildah-build: check-builder load-version-json ## Build and push image (multi-ar
474488
sed -e '1 s/\(^FROM\)/FROM --platform=$${BUILDPLATFORM}/' Dockerfile > Dockerfile.cross; \
475489
- docker buildx create --use --name image-builder || true; \
476490
docker buildx use image-builder; \
477-
docker buildx build --push --platform=$(PLATFORMS) --tag $(IMG) -f Dockerfile.cross . || exit 1; \
491+
docker buildx build --push \
492+
--platform=$(PLATFORMS) \
493+
--build-arg GIT_NM_USER=$(GIT_NM_USER)\
494+
--build-arg NM_TOKEN=$(NM_TOKEN) \
495+
--tag $(IMG) -f Dockerfile.cross . || exit 1; \
478496
docker buildx rm image-builder || true; \
479497
rm Dockerfile.cross; \
480498
elif [ "$(BUILDER)" = "podman" ]; then \

0 commit comments

Comments
 (0)