Skip to content

Commit

Permalink
ci(s3): build and publish s3 image
Browse files Browse the repository at this point in the history
Signed-off-by: Sunil Thaha <[email protected]>
  • Loading branch information
sthaha committed Jul 9, 2024
1 parent f90382c commit 0eeac7d
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 11 deletions.
23 changes: 19 additions & 4 deletions .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ on:
description: 'Change flag on base image'
required: true
type: string
s3_change:
description: 'Change flag on s3 image'
required: true
type: string
image_repo:
description: 'The image repo to use'
required: true
Expand All @@ -33,6 +37,8 @@ env:
base_change: ${{ inputs.base_change }}
base_image: ${{ inputs.image_repo }}/kepler_model_server_base:${{ inputs.image_tag }}
image: ${{ inputs.image_repo }}/kepler_model_server:${{ inputs.image_tag }}
s3_change: ${{ inputs.s3_change }}
s3_image: ${{ inputs.image_repo }}/kepler_model_server/s3:${{ inputs.image_tag }}

jobs:

Expand Down Expand Up @@ -82,22 +88,31 @@ jobs:
- name: set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker
if: ${{ needs.check-secret.outputs.available == 'true' }}
if: ${{ needs.check-secret.outputs.available == 'true' }}
uses: docker/login-action@v3
with:
registry: ${{ inputs.image_repo }}
username: ${{ secrets.docker_username }}
password: ${{ secrets.docker_password }}
password: ${{ secrets.docker_password }}
- name: Build-push s3 image
if: ${{ needs.check-secret.outputs.available == 'true' && env.s3_change == 'true' }}
uses: docker/build-push-action@v6
with:
platforms: linux/amd64
push: true
tags: ${{ env.s3_image }}
context: model_training/s3
file: model_training/s3/Dockerfile
- name: Build-push base image
if: ${{ (needs.check-secret.outputs.available == 'true') && ((needs.check-base-exist.outputs.exists == 'false') || (env.base_change == 'true')) }}
if: ${{ (needs.check-secret.outputs.available == 'true') && ((needs.check-base-exist.outputs.exists == 'false') || (env.base_change == 'true')) }}
uses: docker/build-push-action@v6
with:
platforms: linux/amd64
push: true
tags: ${{ env.base_image }}
file: dockerfiles/Dockerfile.base
- name: Replace value in file
if: ${{ (needs.check-secret.outputs.available == 'true') && ((needs.check-base-exist.outputs.exists == 'false') || (env.base_change == 'true')) }}
if: ${{ (needs.check-secret.outputs.available == 'true') && ((needs.check-base-exist.outputs.exists == 'false') || (env.base_change == 'true')) }}
run: |
sed -i "s|quay.io/sustainable_computing_io/kepler_model_server_base:latest|${{ env.base_image }}|" dockerfiles/Dockerfile
- name: Build-push image
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,12 @@ jobs:
with:
push: false
load: true
tags: ${{ vars.IMAGE_REPO || 'docker.io/library' }}/kepler_model_server_s3:${{ needs.check-branch.outputs.tag }}
tags: ${{ vars.IMAGE_REPO || 'docker.io/library' }}/kepler_model_server/s3:${{ needs.check-branch.outputs.tag }}
context: model_training/s3
file: model_training/s3/Dockerfile

- name: test s3 image
- name: Test s3 image
run: |
img=${{ vars.IMAGE_REPO || 'docker.io/library' }}/kepler_model_server_s3:${{ needs.check-branch.outputs.tag }}
img=${{ vars.IMAGE_REPO || 'docker.io/library' }}/kepler_model_server/s3:${{ needs.check-branch.outputs.tag }}
docker run --rm $img s3-pusher --version
docker run --rm $img s3-loader --version
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/push-to-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,15 @@ jobs:
- 'model_training/**'
- 'hack/**'
- '.github/workflows/train-model.yml'
s3:
- 'model_training/s3/**'
build-push:
needs: [check-change, check-branch]
uses: ./.github/workflows/build-push.yml
with:
base_change: ${{ needs.check-change.outputs.base }}
s3_change: ${{ needs.check-change.outputs.s3 }}
image_repo: ${{ vars.IMAGE_REPO }}
image_tag: ${{ needs.check-branch.outputs.tag }}
push: true
Expand Down
2 changes: 2 additions & 0 deletions model_training/s3/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# NOTE: Dockerfile for generating quay.io/kepler_model_server/s3 images

FROM python:3.10-slim

WORKDIR /usr/local
Expand Down
2 changes: 1 addition & 1 deletion model_training/tekton/tasks/s3/aws-s3-load.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ spec:
optional: true
steps:
- name: load
image: quay.io/sustainability/kepler_model_server/s3:v0.7-py3.10
image: quay.io/sustainable_computing_io/kepler_model_server/s3:latest
env:
- name: ACCESS_KEY_ID
valueFrom:
Expand Down
2 changes: 1 addition & 1 deletion model_training/tekton/tasks/s3/aws-s3-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ spec:
optional: true
steps:
- name: push
image: quay.io/sustainability/kepler_model_server/s3:v0.7-py3.10
image: quay.io/sustainable_computing_io/kepler_model_server/s3:latest
env:
- name: ACCESS_KEY_ID
valueFrom:
Expand Down
2 changes: 1 addition & 1 deletion model_training/tekton/tasks/s3/ibmcloud-s3-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ spec:
optional: true
steps:
- name: push
image: quay.io/sustainability/kepler_model_server/s3:v0.7-py3.10
image: quay.io/sustainable_computing_io/kepler_model_server/s3:latest
env:
- name: SERVICE_ENDPOINT
valueFrom:
Expand Down

0 comments on commit 0eeac7d

Please sign in to comment.