Skip to content

Commit 142e85e

Browse files
authored
[CI] Support container image build and push in CI (#120)
* Support container image build and push in CI * Remove the pull request check for image push * Optimize the test parallelism
1 parent 9f25dff commit 142e85e

File tree

4 files changed

+76
-6
lines changed

4 files changed

+76
-6
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Docker Build Images
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Check out code
14+
uses: actions/checkout@v4
15+
- name: Set up Docker Buildx
16+
uses: docker/setup-buildx-action@v2
17+
- name: Docker Build - Controller Manager
18+
run: make docker-build
19+
- name: Docker Build - Gateway Plugins
20+
run: make docker-build-plugins
21+
- name: Docker Build - Runtime
22+
run: make docker-build-runtime
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Docker Push Images
2+
3+
on:
4+
push:
5+
branches: [ "main", "release-*"]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
with:
13+
submodules: 'true'
14+
- name: Set up Docker Buildx
15+
uses: docker/setup-buildx-action@v2
16+
- name: Login to DockerHub
17+
uses: docker/login-action@v2
18+
with:
19+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
20+
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
21+
# build container images
22+
- name: Docker Build - Controller Manager
23+
run: make docker-build
24+
- name: Docker Build - Gateway Plugins
25+
run: make docker-build-plugins
26+
- name: Docker Build - Runtime
27+
run: make docker-build-runtime
28+
# push container image to dockerhub
29+
- name: Push Image - Controller Manager
30+
run: make docker-push
31+
- name: Push Image - Gateway Plugins
32+
run: make docker-push-plugins
33+
- name: Push Image - Runtime
34+
run: make docker-push-runtime

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Tests
1+
name: Linter and Unit Tests
22

33
on:
44
push:

Makefile

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
# Git Commit Hash
2+
GIT_COMMIT_HASH := $(shell git rev-parse HEAD)
3+
14
# Image URL to use all building/pushing image targets
2-
AIBRIX_REPO ?= aibrix
3-
IMG ?= controller:latest
4-
PLUGINS_IMG ?= aibrix/plugins:v0.1.0
5-
RUNTIME_IMG ?= ${AIBRIX_REPO}/runtime:latest
5+
AIBRIX_DOCKERHUB_NAMESPACE ?= aibrix
6+
IMG ?= ${AIBRIX_DOCKERHUB_NAMESPACE}/controller-manager:${GIT_COMMIT_HASH}
7+
PLUGINS_IMG ?= ${AIBRIX_DOCKERHUB_NAMESPACE}/plugins:${GIT_COMMIT_HASH}
8+
RUNTIME_IMG ?= ${AIBRIX_DOCKERHUB_NAMESPACE}/runtime:${GIT_COMMIT_HASH}
69
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
710
ENVTEST_K8S_VERSION = 1.29.0
811

@@ -123,6 +126,17 @@ docker-build-runtime: ## Build docker image with the AI Runime.
123126
.PHONY: docker-push
124127
docker-push: ## Push docker image with the manager.
125128
$(CONTAINER_TOOL) push ${IMG}
129+
$(CONTAINER_TOOL) push ${AIBRIX_DOCKERHUB_NAMESPACE}/controller-manager:nightly
130+
131+
.PHONY: docker-push-plugins
132+
docker-push-plugins: ## Push docker image with the manager.
133+
$(CONTAINER_TOOL) push ${PLUGINS_IMG}
134+
$(CONTAINER_TOOL) push ${AIBRIX_DOCKERHUB_NAMESPACE}/plugins:nightly
135+
136+
.PHONY: docker-push-runtime
137+
docker-push-runtime: ## Push docker image with the manager.
138+
$(CONTAINER_TOOL) push ${RUNTIME_IMG}
139+
$(CONTAINER_TOOL) push ${AIBRIX_DOCKERHUB_NAMESPACE}/runtime:nightly
126140

127141
# PLATFORMS defines the target platforms for the manager image be built to provide support to multiple
128142
# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
@@ -149,7 +163,7 @@ build-installer: manifests generate kustomize ## Generate a consolidated YAML wi
149163

150164
.PHONY: docker-buildx-runtime
151165
docker-buildx-runtime:
152-
$(CONTAINER_TOOL) buildx build --push --platform=${PLATFORMS} -f runtime.Dockerfile . -t ${AIBRIX_REPO}/${RUNTIME_IMG}
166+
$(CONTAINER_TOOL) buildx build --push --platform=${PLATFORMS} -f runtime.Dockerfile . -t ${RUNTIME_IMG}
153167

154168
##@ Deployment
155169

0 commit comments

Comments
 (0)