Skip to content

Commit

Permalink
[CI] Support container image build and push in CI (#120)
Browse files Browse the repository at this point in the history
* Support container image build and push in CI

* Remove the pull request check for image push

* Optimize the test parallelism
  • Loading branch information
Jeffwan authored Sep 5, 2024
1 parent 9f25dff commit 142e85e
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 6 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/docker-build-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Docker Build Images

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Docker Build - Controller Manager
run: make docker-build
- name: Docker Build - Gateway Plugins
run: make docker-build-plugins
- name: Docker Build - Runtime
run: make docker-build-runtime
34 changes: 34 additions & 0 deletions .github/workflows/docker-push-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Docker Push Images

on:
push:
branches: [ "main", "release-*"]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: 'true'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
# build container images
- name: Docker Build - Controller Manager
run: make docker-build
- name: Docker Build - Gateway Plugins
run: make docker-build-plugins
- name: Docker Build - Runtime
run: make docker-build-runtime
# push container image to dockerhub
- name: Push Image - Controller Manager
run: make docker-push
- name: Push Image - Gateway Plugins
run: make docker-push-plugins
- name: Push Image - Runtime
run: make docker-push-runtime
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Tests
name: Linter and Unit Tests

on:
push:
Expand Down
24 changes: 19 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Git Commit Hash
GIT_COMMIT_HASH := $(shell git rev-parse HEAD)

# Image URL to use all building/pushing image targets
AIBRIX_REPO ?= aibrix
IMG ?= controller:latest
PLUGINS_IMG ?= aibrix/plugins:v0.1.0
RUNTIME_IMG ?= ${AIBRIX_REPO}/runtime:latest
AIBRIX_DOCKERHUB_NAMESPACE ?= aibrix
IMG ?= ${AIBRIX_DOCKERHUB_NAMESPACE}/controller-manager:${GIT_COMMIT_HASH}
PLUGINS_IMG ?= ${AIBRIX_DOCKERHUB_NAMESPACE}/plugins:${GIT_COMMIT_HASH}
RUNTIME_IMG ?= ${AIBRIX_DOCKERHUB_NAMESPACE}/runtime:${GIT_COMMIT_HASH}
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.29.0

Expand Down Expand Up @@ -123,6 +126,17 @@ docker-build-runtime: ## Build docker image with the AI Runime.
.PHONY: docker-push
docker-push: ## Push docker image with the manager.
$(CONTAINER_TOOL) push ${IMG}
$(CONTAINER_TOOL) push ${AIBRIX_DOCKERHUB_NAMESPACE}/controller-manager:nightly

.PHONY: docker-push-plugins
docker-push-plugins: ## Push docker image with the manager.
$(CONTAINER_TOOL) push ${PLUGINS_IMG}
$(CONTAINER_TOOL) push ${AIBRIX_DOCKERHUB_NAMESPACE}/plugins:nightly

.PHONY: docker-push-runtime
docker-push-runtime: ## Push docker image with the manager.
$(CONTAINER_TOOL) push ${RUNTIME_IMG}
$(CONTAINER_TOOL) push ${AIBRIX_DOCKERHUB_NAMESPACE}/runtime:nightly

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

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

##@ Deployment

Expand Down

0 comments on commit 142e85e

Please sign in to comment.