Skip to content

Commit

Permalink
drop use of GOBIN
Browse files Browse the repository at this point in the history
Signed-off-by: Isabella do Amaral <idoamara@redhat.com>
  • Loading branch information
isinyaaa committed Aug 28, 2024
1 parent 7e645e0 commit 70ab410
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 34 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.odh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 13 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -151,19 +144,19 @@ 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:
${GO} mod 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
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions csi/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -32,4 +32,4 @@ WORKDIR /
COPY --from=builder /workspace/bin/mr-storage-initializer .
USER 65532:65532

ENTRYPOINT ["/mr-storage-initializer"]
ENTRYPOINT ["/mr-storage-initializer"]
4 changes: 2 additions & 2 deletions csi/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -42,4 +42,4 @@ WORKDIR /
COPY --from=builder /modelregistry/csi/bin/mr-storage-initializer .
USER 65532:65532

ENTRYPOINT ["/mr-storage-initializer"]
ENTRYPOINT ["/mr-storage-initializer"]
7 changes: 0 additions & 7 deletions csi/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 70ab410

Please sign in to comment.