Skip to content

Commit 5e2506b

Browse files
authored
Enhance builds and push (#559)
Signed-off-by: lucferbux <[email protected]>
1 parent 95e34e4 commit 5e2506b

File tree

6 files changed

+147
-14
lines changed

6 files changed

+147
-14
lines changed

clients/ui/.env

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
############### Default settings ###############
3+
CONTAINER_TOOL=docker
4+
IMG_BFF=kubeflow/model-registry-bff:dev-latest
5+
IMG_FRONTEND=kubeflow/model-registry-ui:dev-latest

clients/ui/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# editor
2+
.idea/
3+
.vscode/
4+
5+
# misc
6+
.DS_Store
7+
8+
.env*.local

clients/ui/Makefile

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
1-
CONTAINER_TOOL ?= docker
1+
DEFAULT_ENV_FILE := .env
2+
ifneq ("$(wildcard $(DEFAULT_ENV_FILE))","")
3+
include ${DEFAULT_ENV_FILE}
4+
export $(shell sed 's/=.*//' ${DEFAULT_ENV_FILE})
5+
endif
6+
7+
DEV_ENV_FILE := .env.development
8+
ifneq ("$(wildcard $(DEV_ENV_FILE))","")
9+
include ${DEV_ENV_FILE}
10+
export $(shell sed 's/=.*//' ${DEV_ENV_FILE})
11+
endif
12+
13+
ENV_FILE := .env.local
14+
ifneq ("$(wildcard $(ENV_FILE))","")
15+
include ${ENV_FILE}
16+
export $(shell sed 's/=.*//' ${ENV_FILE})
17+
endif
218

319
.PHONY: all
420
all: build
@@ -7,6 +23,9 @@ all: build
723
help: ## Display this help.
824
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
925

26+
27+
############ Dev Environment ############
28+
1029
.PHONY: dev-install-dependencies
1130
dev-install-dependencies:
1231
cd frontend && npm install
@@ -23,6 +42,34 @@ dev-frontend:
2342
dev-start:
2443
make -j 2 dev-bff dev-frontend
2544

45+
############ Build ############
46+
47+
.PHONY: build-bff
48+
build-bff:
49+
$(CONTAINER_TOOL) build -t ${IMG_BFF} ./bff
50+
51+
.PHONY: build-frontend
52+
build-frontend:
53+
$(CONTAINER_TOOL) build -t ${IMG_FRONTEND} ./frontend
54+
55+
.PHONY: build
56+
build: build-bff build-frontend
57+
58+
############ Push ############
59+
60+
.PHONY: push-bff
61+
push-bff:
62+
${CONTAINER_TOOL} push ${IMG_BFF}
63+
64+
.PHONY: push-frontend
65+
push-frontend:
66+
${CONTAINER_TOOL} push ${IMG_FRONTEND}
67+
68+
.PHONY: push
69+
push: push-bff push-frontend
70+
71+
############ Deployment ############
72+
2673
.PHONY: docker-compose
2774
docker-compose:
2875
$(CONTAINER_TOOL) compose -f docker-compose.yaml up

clients/ui/README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,68 @@ make kind-deployment
4646

4747
You can find the OpenAPI specification for the Model Registry UI in the [openapi](./api/openapi) directory.
4848
A live version of the OpenAPI specification can be found [here](https://editor.swagger.io/?url=https://raw.githubusercontent.com/kubeflow/model-registry/main/clients/ui/api/openapi/mod-arch.yaml).
49+
50+
## Environment Variables
51+
52+
The following environment variables are used to configure the deployment and development environment for the Model Registry UI. These variables should be defined in a `.env.local` file in the `clients/ui` directory of the project. **This values will affect the build and push commands**.
53+
54+
### `CONTAINER_TOOL`
55+
56+
* **Description**: Specifies the container tool to be used for building and running containers.
57+
* **Default Value**: `docker`
58+
* **Possible Values**: `docker`, `podman`, etc.
59+
* **Example**: `CONTAINER_TOOL=docker`
60+
61+
### `IMG_BFF`
62+
63+
* **Description**: Specifies the image name and tag for the Backend For Frontend (BFF) service.
64+
* **Default Value**: `model-registry-bff:latest`
65+
* **Example**: `IMG_BFF=model-registry-bff:latest`
66+
67+
### `IMG_FRONTEND`
68+
69+
* **Description**: Specifies the image name and tag for the frontend service.
70+
* **Default Value**: `model-registry-frontend:latest`
71+
* **Example**: `IMG_FRONTEND=model-registry-frontend:latest`
72+
73+
### Example `.env.local` File
74+
75+
Here is an example of what your `.env.local` file might look like:
76+
77+
```shell
78+
CONTAINER_TOOL=docker
79+
IMG_BFF=model-registry-bff:latest
80+
IMG_FRONTEND=model-registry-frontend:latest
81+
```
82+
83+
## Build and Push Commands
84+
85+
The following Makefile targets are used to build and push the Docker images for the Backend For Frontend (BFF) and frontend services. These targets utilize the environment variables defined in the `.env.local` file.
86+
87+
### Build Commands
88+
89+
* **`build-bff`**: Builds the Docker image for the BFF service.
90+
* Command: `make build-bff`
91+
* This command uses the `CONTAINER_TOOL` and `IMG_BFF` environment variables to build the image.
92+
93+
* **`build-frontend`**: Builds the Docker image for the frontend service.
94+
* Command: `make build-frontend`
95+
* This command uses the `CONTAINER_TOOL` and `IMG_FRONTEND` environment variables to build the image.
96+
97+
* **`build`**: Builds the Docker images for both the BFF and frontend services.
98+
* Command: `make build`
99+
* This command runs both `build-bff` and `build-frontend` targets.
100+
101+
### Push Commands
102+
103+
* **`push-bff`**: Pushes the Docker image for the BFF service to the container registry.
104+
* Command: `make push-bff`
105+
* This command uses the `CONTAINER_TOOL` and `IMG_BFF` environment variables to push the image.
106+
107+
* **`push-frontend`**: Pushes the Docker image for the frontend service to the container registry.
108+
* Command: `make push-frontend`
109+
* This command uses the `CONTAINER_TOOL` and `IMG_FRONTEND` environment variables to push the image.
110+
111+
* **`push`**: Pushes the Docker images for both the BFF and frontend services to the container registry.
112+
* Command: `make push`
113+
* This command runs both `push-bff` and `push-frontend` targets.

clients/ui/manifests/base/kustomization.yaml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@ apiVersion: kustomize.config.k8s.io/v1beta1
22
kind: Kustomization
33

44
resources:
5-
- model-registry-bff-role.yaml
6-
- model-registry-bff-service.yaml
7-
- model-registry-bff-deployment.yaml
8-
- model-registry-ui-service.yaml
9-
- model-registry-ui-deployment.yaml
10-
- model-registry-service-account.yaml
5+
- model-registry-bff-role.yaml
6+
- model-registry-bff-service.yaml
7+
- model-registry-bff-deployment.yaml
8+
- model-registry-ui-service.yaml
9+
- model-registry-ui-deployment.yaml
10+
- model-registry-service-account.yaml
1111

1212
images:
13-
- name: model-registry-ui-image
14-
newName: kubeflow/model-registry-ui:latest
15-
- name: model-registry-bff-image
16-
newName: kubeflow/model-registry-bff:latest
13+
- name: model-registry-bff-image
14+
newName: kubeflow/model-registry-bff
15+
newTag: latest
16+
- name: model-registry-ui-image
17+
newName: kubeflow/model-registry-ui
18+
newTag: latest

clients/ui/scripts/deploy_kind_cluster.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,29 @@ else
3333
kubectl get pods -n kubeflow
3434
fi
3535

36+
pushd ./manifests/base
37+
kustomize edit set namespace kubeflow
38+
kustomize edit set image model-registry-ui-image=${IMG_FRONTEND}
39+
kustomize edit set image model-registry-bff-image=${IMG_BFF}
40+
3641
# Step 4: Deploy model registry UI
3742
echo "Deploying Model Registry UI..."
38-
kubectl apply -n kubeflow -k ./manifests/base
43+
kubectl apply -n kubeflow -k .
3944

4045
# Wait for deployment to be available
4146
echo "Waiting Model Registry UI to be available..."
4247
kubectl wait --for=condition=available -n kubeflow deployment/model-registry-ui --timeout=1m
4348

49+
pushd ../user-rbac
4450
# Step 5: Apply admin user service account in the cluster
4551
echo "Applying admin user service account and rolebinding..."
46-
kubectl apply -k ./manifests/user-rbac
52+
kubectl apply -k .
4753

4854
# Step 6: Generate token for admin user and display it
4955
echo "Generating token for admin user, copy the following token in the local storage with key 'x-forwarded-access-token'..."
5056
echo -e "\033[32m$(kubectl -n kube-system create token admin-user)\033[0m"
5157

5258
# Step 5: Port-forward the service
53-
echo "Portfowarding Model Registry UI..."
59+
echo "Port-fowarding Model Registry UI..."
5460
echo -e "\033[32mDashboard available in http://localhost:8080\033[0m"
5561
kubectl port-forward svc/model-registry-ui-service -n kubeflow 8080:8080

0 commit comments

Comments
 (0)