Skip to content

Commit

Permalink
[CI] Push images to Github container registry (#246)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeffwan authored Sep 27, 2024
1 parent 10bacc6 commit bad1f1f
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 31 deletions.
55 changes: 37 additions & 18 deletions .github/workflows/docker-push-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
jobs:
build:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -18,21 +21,37 @@ jobs:
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
- name: Docker Build - Users
run: make docker-build-users
# 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
- name: Push Image - Users
run: make docker-push-users
- name: Login to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build Container Images
run: |
make docker-build
make docker-build-plugins
make docker-build-runtime
make docker-build-users
- name: Push Container Images to DockerHub
run: |
make docker-push
make docker-push-plugins
make docker-push-runtime
make docker-push-users
- name: Build Container Images with Github Container Registry prefix
run: |
IMG=ghcr.io/aibrix/controller-manager:${{ github.sha }} make docker-build
PLUGINS_IMG=ghcr.io/aibrix/plugins:${{ github.sha }} make docker-build-plugins
RUNTIME_IMG=ghcr.io/aibrix/runtime:${{ github.sha }} make docker-build-runtime
USERS_IMG=ghcr.io/aibrix/users:${{ github.sha }} make docker-build-users
- name: Push Container Images to Github Container Registry
run: |
IMG=ghcr.io/aibrix/controller-manager:${{ github.sha }} AIBRIX_CONTAINER_REGISTRY_NAMESPACE=ghcr.io/aibrix make docker-push
PLUGINS_IMG=ghcr.io/aibrix/plugins:${{ github.sha }} AIBRIX_CONTAINER_REGISTRY_NAMESPACE=ghcr.io/aibrix make docker-push-plugins
RUNTIME_IMG=ghcr.io/aibrix/runtime:${{ github.sha }} AIBRIX_CONTAINER_REGISTRY_NAMESPACE=ghcr.io/aibrix make docker-push-runtime
USERS_IMG=ghcr.io/aibrix/users:${{ github.sha }} AIBRIX_CONTAINER_REGISTRY_NAMESPACE=ghcr.io/aibrix make docker-push-users
26 changes: 13 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
GIT_COMMIT_HASH := $(shell git rev-parse HEAD)

# Image URL to use all building/pushing image targets
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}
USERS_IMG ?= ${AIBRIX_DOCKERHUB_NAMESPACE}/users:${GIT_COMMIT_HASH}
AIBRIX_CONTAINER_REGISTRY_NAMESPACE ?= aibrix
IMG ?= ${AIBRIX_CONTAINER_REGISTRY_NAMESPACE}/controller-manager:${GIT_COMMIT_HASH}
PLUGINS_IMG ?= ${AIBRIX_CONTAINER_REGISTRY_NAMESPACE}/plugins:${GIT_COMMIT_HASH}
RUNTIME_IMG ?= ${AIBRIX_CONTAINER_REGISTRY_NAMESPACE}/runtime:${GIT_COMMIT_HASH}
USERS_IMG ?= ${AIBRIX_CONTAINER_REGISTRY_NAMESPACE}/users:${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,42 +123,42 @@ run: manifests generate fmt vet ## Run a controller from your host.
.PHONY: docker-build
docker-build: ## Build docker image with the manager.
$(CONTAINER_TOOL) build -t ${IMG} .
$(CONTAINER_TOOL) tag ${IMG} ${AIBRIX_DOCKERHUB_NAMESPACE}/controller-manager:nightly
$(CONTAINER_TOOL) tag ${IMG} ${AIBRIX_CONTAINER_REGISTRY_NAMESPACE}/controller-manager:nightly

.PHONY: docker-build-plugins
docker-build-plugins: ## Build docker image with the manager.
$(CONTAINER_TOOL) build -t ${PLUGINS_IMG} -f Dockerfile.gateway .
$(CONTAINER_TOOL) tag ${PLUGINS_IMG} ${AIBRIX_DOCKERHUB_NAMESPACE}/plugins:nightly
$(CONTAINER_TOOL) tag ${PLUGINS_IMG} ${AIBRIX_CONTAINER_REGISTRY_NAMESPACE}/plugins:nightly

.PHONY: docker-build-runtime
docker-build-runtime: ## Build docker image with the AI Runime.
$(CONTAINER_TOOL) build -t ${RUNTIME_IMG} -f runtime.Dockerfile .
$(CONTAINER_TOOL) tag ${RUNTIME_IMG} ${AIBRIX_DOCKERHUB_NAMESPACE}/runtime:nightly
$(CONTAINER_TOOL) tag ${RUNTIME_IMG} ${AIBRIX_CONTAINER_REGISTRY_NAMESPACE}/runtime:nightly

.PHONY: docker-build-users
docker-build-users: ## Build docker image with the manager.
$(CONTAINER_TOOL) build -t ${USERS_IMG} -f Dockerfile.users .
$(CONTAINER_TOOL) tag ${USERS_IMG} ${AIBRIX_DOCKERHUB_NAMESPACE}/users:nightly
$(CONTAINER_TOOL) tag ${USERS_IMG} ${AIBRIX_CONTAINER_REGISTRY_NAMESPACE}/users:nightly

.PHONY: docker-push
docker-push: ## Push docker image with the manager.
$(CONTAINER_TOOL) push ${IMG}
$(CONTAINER_TOOL) push ${AIBRIX_DOCKERHUB_NAMESPACE}/controller-manager:nightly
$(CONTAINER_TOOL) push ${AIBRIX_CONTAINER_REGISTRY_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
$(CONTAINER_TOOL) push ${AIBRIX_CONTAINER_REGISTRY_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
$(CONTAINER_TOOL) push ${AIBRIX_CONTAINER_REGISTRY_NAMESPACE}/runtime:nightly

.PHONY: docker-push-users
docker-push-users: ## Push docker image with the manager.
$(CONTAINER_TOOL) push ${USERS_IMG}
$(CONTAINER_TOOL) push ${AIBRIX_DOCKERHUB_NAMESPACE}/users:nightly
$(CONTAINER_TOOL) push ${AIBRIX_CONTAINER_REGISTRY_NAMESPACE}/users: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 Down

0 comments on commit bad1f1f

Please sign in to comment.