Skip to content

Commit

Permalink
enhance CI for build image logic
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Yuan <[email protected]>
  • Loading branch information
SamYuan1990 committed Dec 1, 2023
1 parent 9decb38 commit f1784ce
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 64 deletions.
62 changes: 38 additions & 24 deletions .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,56 @@ name: BuildPushDeployImage

on:
push:

env:
IMAGE_VERSION: '0.7'
IMAGE_REGISTRY: quay.io/sustainable_computing_io
IMAGE_NAME: kepler_model_server
branches: [ main ]

jobs:
build:
buildbase:
runs-on: ubuntu-latest

steps:
- name: checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
- name: set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: build Kepler model server
run: make build

uses: docker/setup-buildx-action@v3
- name: Login to Quay
if: ${{ (github.repository_owner == 'sustainable-computing-io') && (github.ref == 'refs/heads/main') }}
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
registry: quay.io/sustainable_computing_io
username: ${{ secrets.BOT_NAME }}
password: ${{ secrets.BOT_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64,linux/s390x
push: true
tags: quay.io/sustainable_computing_io/kepler_model_server_base:v0.7
file: dockerfiles/Dockerfile.base

- name: Push to quay
if: ${{ (github.repository_owner == 'sustainable-computing-io') && (github.ref == 'refs/heads/main') }}
run: make push


- name: Tag latest and push to quay
build:
needs: [buildbase]
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: set up QEMU
uses: docker/setup-qemu-action@v3
- name: set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Quay
if: ${{ (github.repository_owner == 'sustainable-computing-io') && (github.ref == 'refs/heads/main') }}
run: |
docker tag ${{env.IMAGE_REGISTRY}}/${{env.IMAGE_NAME}}:v${{env.IMAGE_VERSION}} ${{env.IMAGE_REGISTRY}}/${{env.IMAGE_NAME}}:latest
docker push ${{env.IMAGE_REGISTRY}}/${{env.IMAGE_NAME}}:v${{env.IMAGE_VERSION}}
docker push ${{env.IMAGE_REGISTRY}}/${{env.IMAGE_NAME}}:latest
uses: docker/login-action@v3
with:
registry: quay.io/sustainable_computing_io
username: ${{ secrets.BOT_NAME }}
password: ${{ secrets.BOT_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64,linux/s390x
push: true
tags: quay.io/sustainable_computing_io/kepler_model_server:latest,quay.io/sustainable_computing_io/kepler_model_server:v0.7
file: dockerfiles/Dockerfile
38 changes: 0 additions & 38 deletions .github/workflows/docker-base-image.yml

This file was deleted.

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ CTR_CMD = docker
DOCKERFILES_PATH := "./dockerfiles"

build:
$(CTR_CMD) build --platform linux/amd64 -t $(IMAGE) -f $(DOCKERFILES_PATH)/Dockerfile .
$(CTR_CMD) build -t $(IMAGE) -f $(DOCKERFILES_PATH)/Dockerfile .

build-test:
$(CTR_CMD) build --platform linux/amd64 -t $(TEST_IMAGE) -f $(DOCKERFILES_PATH)/Dockerfile.test .
$(CTR_CMD) build -t $(TEST_IMAGE) -f $(DOCKERFILES_PATH)/Dockerfile.test .

push:
$(CTR_CMD) push $(IMAGE)
Expand Down

0 comments on commit f1784ce

Please sign in to comment.