diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7ccc89b4..2a910789 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,6 +23,8 @@ jobs: uses: actions/setup-go@v5 with: go-version: "1.21" + - name: install go deps + run: make go-deps - name: Set up Python uses: actions/setup-python@v5 with: diff --git a/Dockerfile b/Dockerfile index 89a741c5..5b94011d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,11 +30,11 @@ COPY patches/ patches/ COPY templates/ templates/ # Download tools -RUN make deps +RUN make deps go-deps # Build USER root -RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 make clean model-registry +RUN PATH=$PATH:/opt/app-root/src/go/bin CGO_ENABLED=1 GOOS=linux GOARCH=amd64 make clean model-registry # Use distroless as minimal base image to package the model-registry binary # Refer to https://github.com/GoogleContainerTools/distroless for more details diff --git a/Dockerfile.odh b/Dockerfile.odh index a442a6bb..37ddc72a 100644 --- a/Dockerfile.odh +++ b/Dockerfile.odh @@ -21,7 +21,7 @@ COPY internal/ internal/ COPY pkg/ pkg/ # Build -RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 make clean/odh build/odh +RUN PATH=$PATH:/opt/app-root/src/go/bin CGO_ENABLED=1 GOOS=linux GOARCH=amd64 make clean/odh build/odh # Use distroless as minimal base image to package the model-registry binary # Refer to https://github.com/GoogleContainerTools/distroless for more details diff --git a/Makefile b/Makefile index ed5503bd..a28e8508 100644 --- a/Makefile +++ b/Makefile @@ -64,7 +64,7 @@ internal/ml_metadata/proto/%.pb.go: api/grpc/ml_metadata/proto/%.proto gen/grpc: internal/ml_metadata/proto/metadata_store.pb.go internal/ml_metadata/proto/metadata_store_service.pb.go internal/converter/generated/converter.go: internal/converter/*.go - ${GOVERTER} gen github.com/kubeflow/model-registry/internal/converter/ + goverter gen github.com/kubeflow/model-registry/internal/converter/ .PHONY: gen/converter gen/converter: gen/grpc internal/converter/generated/converter.go @@ -104,30 +104,23 @@ vet: clean: rm -Rf ./model-registry internal/ml_metadata/proto/*.go internal/converter/generated/*.go pkg/openapi -.PHONY: clean/odh -clean/odh: +.PHONY: clean/docker +clean/docker: rm -Rf ./model-registry bin/protoc: ./scripts/install_protoc.sh -bin/go-enum: - GOBIN=$(PROJECT_BIN) ${GO} install github.com/searKing/golang/tools/go-enum@v1.2.97 - -bin/protoc-gen-go: - GOBIN=$(PROJECT_BIN) ${GO} install google.golang.org/protobuf/cmd/protoc-gen-go@v1.31.0 - -bin/protoc-gen-go-grpc: - GOBIN=$(PROJECT_BIN) ${GO} install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3.0 +go-deps: + ${GO} install github.com/searKing/golang/tools/go-enum@v1.2.97 + ${GO} install google.golang.org/protobuf/cmd/protoc-gen-go@v1.31.0 + ${GO} install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3.0 + ${GO} install github.com/jmattheis/goverter/cmd/goverter@v1.4.1 GOLANGCI_LINT ?= ${PROJECT_BIN}/golangci-lint bin/golangci-lint: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(PROJECT_BIN) v1.59.1 -GOVERTER ?= ${PROJECT_BIN}/goverter -bin/goverter: - GOBIN=$(PROJECT_PATH)/bin ${GO} install github.com/jmattheis/goverter/cmd/goverter@v1.4.1 - OPENAPI_GENERATOR ?= ${PROJECT_BIN}/openapi-generator-cli NPM ?= "$(shell which npm)" bin/openapi-generator-cli: @@ -151,7 +144,7 @@ clean/deps: rm -Rf bin/* .PHONY: deps -deps: bin/protoc bin/go-enum bin/protoc-gen-go bin/protoc-gen-go-grpc bin/golangci-lint bin/goverter bin/openapi-generator-cli +deps: bin/protoc bin/golangci-lint bin/openapi-generator-cli .PHONY: vendor vendor: @@ -159,11 +152,11 @@ vendor: .PHONY: build build: gen vet lint - ${GO} build -buildvcs=false + ${GO} build -.PHONY: build/odh -build/odh: vet - ${GO} build -buildvcs=false +.PHONY: build/docker +build/docker: vet + ${GO} build .PHONY: gen gen: deps gen/grpc gen/openapi gen/openapi-server gen/converter diff --git a/README.md b/README.md index 6d9bdf8f..1c3b9d95 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,21 @@ Model registry provides a central repository for model developers to store and m ## Pre-requisites: - go >= 1.21 +- go-enum >= 1.2.97 +- protoc-gen-go >= 1.31.0 +- protoc-gen-go-grpc >= 1.3.0 +- goverter >= 1.4.1 - protoc v24.3 - [Protocol Buffers v24.3 Release](https://github.com/protocolbuffers/protobuf/releases/tag/v24.3) - npm >= 10.2.0 - [Installing Node.js and npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) - Java >= 11.0 - python 3.9 +To install the go dependencies you can use + +```sh +make go-deps +``` + ## OpenAPI Proxy Server The model registry proxy server implementation follows a contract-first approach, where the contract is identified by [model-registry.yaml](api/openapi/model-registry.yaml) OpenAPI specification. diff --git a/csi/Dockerfile b/csi/Dockerfile index 70153975..699b770e 100644 --- a/csi/Dockerfile +++ b/csi/Dockerfile @@ -22,7 +22,7 @@ COPY pkg/ pkg/ # Build USER root -RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 make build +RUN PATH=$PATH:/opt/app-root/src/go/bin CGO_ENABLED=1 GOOS=linux GOARCH=amd64 make build # Use distroless as minimal base image to package the model-registry storage initializer binary # Refer to https://github.com/GoogleContainerTools/distroless for more details @@ -32,4 +32,4 @@ WORKDIR / COPY --from=builder /workspace/bin/mr-storage-initializer . USER 65532:65532 -ENTRYPOINT ["/mr-storage-initializer"] \ No newline at end of file +ENTRYPOINT ["/mr-storage-initializer"] diff --git a/csi/Dockerfile.dev b/csi/Dockerfile.dev index 3f3cf8ec..86008ea6 100644 --- a/csi/Dockerfile.dev +++ b/csi/Dockerfile.dev @@ -32,7 +32,7 @@ COPY csi/pkg/ pkg/ # Build USER root -RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 make build +RUN PATH=$PATH:/opt/app-root/src/go/bin CGO_ENABLED=1 GOOS=linux GOARCH=amd64 make build # Use distroless as minimal base image to package the model-registry storage initializer binary # Refer to https://github.com/GoogleContainerTools/distroless for more details @@ -42,4 +42,4 @@ WORKDIR / COPY --from=builder /modelregistry/csi/bin/mr-storage-initializer . USER 65532:65532 -ENTRYPOINT ["/mr-storage-initializer"] \ No newline at end of file +ENTRYPOINT ["/mr-storage-initializer"] diff --git a/csi/Makefile b/csi/Makefile index c614901f..eb705e69 100644 --- a/csi/Makefile +++ b/csi/Makefile @@ -1,12 +1,5 @@ -# Useful paths -MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) -PROJECT_PATH := $(patsubst %/,%,$(dir $(MKFILE_PATH))) -PROJECT_BIN := $(PROJECT_PATH)/bin GO ?= "$(shell which go)" -# add tools bin directory -PATH := $(PROJECT_BIN):$(PATH) - # container tool DOCKER ?= docker DOCKERFILE ?= Dockerfile