Skip to content

Commit

Permalink
Build images from local repository, push them, install stuff using them
Browse files Browse the repository at this point in the history
  • Loading branch information
aliok committed Oct 4, 2023
1 parent 0013b9f commit b392fc6
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 29 deletions.
67 changes: 40 additions & 27 deletions .github/workflows/build-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@ on:
push:
branches: [ "main" ]

env:
DOCKER_REPO_OVERRIDE: quay.io/kevent-mesh
AI_DEMO_IMAGE_TAG: main

jobs:
build:
name: build images
runs-on: ubuntu-latest

steps:
- name: Print env
run: echo "Going to push to container registry ${{ env.DOCKER_REPO_OVERRIDE }} with image tags ${{ env.AI_DEMO_IMAGE_TAG }}"

- uses: actions/checkout@v3

- uses: actions/setup-python@v4
Expand All @@ -20,140 +27,146 @@ jobs:
run: |
pip install --no-input gsutil
# necessary for Running Red Hat Quay GitHub Action locally
- name: Install podman
if: ${{ !github.event.act }} # only run when local actions testing
run: |
apt-get update && apt-get -y install podman
- name: Download model files
run: |
gsutil cp -r gs://knative-ai-demo/kserve-models/knative_01/0001 ./services/inference-service/v1/model
ls -la ./services/inference-service/v1/model
- name: Build ai-demo-inference-service
id: build-ai-demo-inference-service
run: docker build services/inference-service/v1 --file services/inference-service/v1/Dockerfile -t ai-demo-inference-service-v1:main
run: docker build services/inference-service/v1 --file services/inference-service/v1/Dockerfile -t ai-demo-inference-service-v1${{ env.AI_DEMO_IMAGE_TAG }}
- name: Push ai-demo-inference-service
id: push-ai-demo-inference-service
uses: redhat-actions/push-to-registry@v2
with:
image: ai-demo-inference-service-v1
tags: main
registry: quay.io/kevent-mesh
tags: ${{ env.AI_DEMO_IMAGE_TAG }}
registry: ${{ env.DOCKER_REPO_OVERRIDE }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Print ai-demo-inference-service image url
run: echo "ai-demo-inference-service image pushed to ${{ steps.push-ai-demo-inference-service.outputs.registry-paths }}"

- name: Build ai-demo-upload-service
id: build-ai-demo-upload-service
run: docker build services/upload-service --file services/upload-service/Dockerfile -t ai-demo-upload-service:main
run: docker build services/upload-service --file services/upload-service/Dockerfile -t ai-demo-upload-service:${{ env.AI_DEMO_IMAGE_TAG }}
- name: Push ai-demo-upload-service
id: push-ai-demo-upload-service
uses: redhat-actions/push-to-registry@v2
with:
image: ai-demo-upload-service
tags: main
registry: quay.io/kevent-mesh
tags: ${{ env.AI_DEMO_IMAGE_TAG }}
registry: ${{ env.DOCKER_REPO_OVERRIDE }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Print ai-demo-upload-service image url
run: echo "ai-demo-upload-service image pushed to ${{ steps.push-ai-demo-upload-service.outputs.registry-paths }}"

- name: Build ai-demo-minio-webhook-source
id: build-ai-demo-minio-webhook-source
run: docker build services/minio-webhook-source --file services/minio-webhook-source/Dockerfile -t ai-demo-minio-webhook-source:main
run: docker build services/minio-webhook-source --file services/minio-webhook-source/Dockerfile -t ai-demo-minio-webhook-source:${{ env.AI_DEMO_IMAGE_TAG }}
- name: Push ai-demo-minio-webhook-source
id: push-ai-demo-minio-webhook-source
uses: redhat-actions/push-to-registry@v2
with:
image: ai-demo-minio-webhook-source
tags: main
registry: quay.io/kevent-mesh
tags: ${{ env.AI_DEMO_IMAGE_TAG }}
registry: ${{ env.DOCKER_REPO_OVERRIDE }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Print ai-demo-minio-webhook-source image url
run: echo "ai-demo-minio-webhook-source image pushed to ${{ steps.push-ai-demo-minio-webhook-source.outputs.registry-paths }}"

- name: Build ai-demo-ui-service
id: build-ai-demo-ui-service
run: docker build services/ui-service --file services/ui-service/Dockerfile -t ai-demo-ui-service:main
run: docker build services/ui-service --file services/ui-service/Dockerfile -t ai-demo-ui-service:${{ env.AI_DEMO_IMAGE_TAG }}
- name: Push ai-demo-ui-service
id: push-ai-demo-ui-service
uses: redhat-actions/push-to-registry@v2
with:
image: ai-demo-ui-service
tags: main
registry: quay.io/kevent-mesh
tags: ${{ env.AI_DEMO_IMAGE_TAG }}
registry: ${{ env.DOCKER_REPO_OVERRIDE }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Print ai-demo-ui-service image url
run: echo "ai-demo-ui-service image pushed to ${{ steps.push-ai-demo-ui-service.outputs.registry-paths }}"

- name: Build ai-demo-reply-service
id: build-ai-demo-reply-service
run: docker build services/reply-service --file services/reply-service/Dockerfile -t ai-demo-reply-service:main
run: docker build services/reply-service --file services/reply-service/Dockerfile -t ai-demo-reply-service:${{ env.AI_DEMO_IMAGE_TAG }}
- name: Push ai-demo-reply-service
id: push-ai-demo-reply-service
uses: redhat-actions/push-to-registry@v2
with:
image: ai-demo-reply-service
tags: main
registry: quay.io/kevent-mesh
tags: ${{ env.AI_DEMO_IMAGE_TAG }}
registry: ${{ env.DOCKER_REPO_OVERRIDE }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Print ai-demo-reply-service image url
run: echo "ai-demo-reply-service image pushed to ${{ steps.push-ai-demo-reply-service.outputs.registry-paths }}"

- name: Build ai-demo-analytics-service
id: build-ai-demo-analytics-service
run: docker build services/analytics-service --file services/analytics-service/Dockerfile -t ai-demo-analytics-service:main
run: docker build services/analytics-service --file services/analytics-service/Dockerfile -t ai-demo-analytics-service:${{ env.AI_DEMO_IMAGE_TAG }}
- name: Push ai-demo-analytics-service
id: push-ai-demo-analytics-service
uses: redhat-actions/push-to-registry@v2
with:
image: ai-demo-analytics-service
tags: main
registry: quay.io/kevent-mesh
tags: ${{ env.AI_DEMO_IMAGE_TAG }}
registry: ${{ env.DOCKER_REPO_OVERRIDE }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Print ai-demo-analytics-service image url
run: echo "ai-demo-analytics-service image pushed to ${{ steps.push-ai-demo-analytics-service.outputs.registry-paths }}"

- name: Build ai-demo-prediction-service
id: build-ai-demo-prediction-service
run: docker build services/prediction-service --file services/prediction-service/Dockerfile -t ai-demo-prediction-service:main
run: docker build services/prediction-service --file services/prediction-service/Dockerfile -t ai-demo-prediction-service:${{ env.AI_DEMO_IMAGE_TAG }}
- name: Push ai-demo-prediction-service
id: push-ai-demo-prediction-service
uses: redhat-actions/push-to-registry@v2
with:
image: ai-demo-prediction-service
tags: main
registry: quay.io/kevent-mesh
tags: ${{ env.AI_DEMO_IMAGE_TAG }}
registry: ${{ env.DOCKER_REPO_OVERRIDE }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Print ai-demo-prediction-service image url
run: echo "ai-demo-prediction-service image pushed to ${{ steps.push-ai-demo-prediction-service.outputs.registry-paths }}"

- name: Build ai-demo-feedback-service
id: build-ai-demo-feedback-service
run: docker build services/feedback-service --file services/feedback-service/Dockerfile -t ai-demo-feedback-service:main
run: docker build services/feedback-service --file services/feedback-service/Dockerfile -t ai-demo-feedback-service:${{ env.AI_DEMO_IMAGE_TAG }}
- name: Push ai-demo-feedback-service
id: push-ai-demo-feedback-service
uses: redhat-actions/push-to-registry@v2
with:
image: ai-demo-feedback-service
tags: main
registry: quay.io/kevent-mesh
tags: ${{ env.AI_DEMO_IMAGE_TAG }}
registry: ${{ env.DOCKER_REPO_OVERRIDE }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Print ai-demo-feedback-service image url
run: echo "ai-demo-feedback-service image pushed to ${{ steps.push-ai-demo-feedback-service.outputs.registry-paths }}"

- name: Build ai-demo-admin-service
id: build-ai-demo-admin-service
run: docker build services/admin-service --file services/admin-service/Dockerfile -t ai-demo-admin-service:main
run: docker build services/admin-service --file services/admin-service/Dockerfile -t ai-demo-admin-service:${{ env.AI_DEMO_IMAGE_TAG }}
- name: Push ai-demo-admin-service
id: push-ai-demo-admin-service
uses: redhat-actions/push-to-registry@v2
with:
image: ai-demo-admin-service
tags: main
registry: quay.io/kevent-mesh
tags: ${{ env.AI_DEMO_IMAGE_TAG }}
registry: ${{ env.DOCKER_REPO_OVERRIDE }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Print ai-demo-admin-service image url
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ training/TensorFlow/workspace/training_01/models
training/TensorFlow/workspace/training_01/exported-models/my_model

kserve_test/models

# sensitive data
.build.secrets
34 changes: 32 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,46 @@ TODO:
- Use Gunicorn for production (containers) (https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-xix-deployment-on-docker-containers)
-

## Building images
## Building and pushing images

Just use the existing GitHub Actions workflows, by passing some environment variables.

Install act (https://github.com/nektos/act) first.

Create a `.build.secrets` file with the following content:

```shell
# get a token by running `gh auth token`
GITHUB_TOKEN=...
# if you're using Quay, make sure you have a robot account with push permissions
REGISTRY_USERNAME=...
REGISTRY_PASSWORD=...
````

Define your container registry and your tag:
```shell
export DOCKER_REPO_OVERRIDE="quay.io/kevent-mesh"
export AI_DEMO_IMAGE_TAG="my-tag"
```

```shell
# reuse the local build container - some stuff will be cached - faster builds
# do not copy files that are ignored by Git
# Change `--remote-name=origin` if that's how your upstream Git remote is named
act --job=build \
--env DOCKER_REPO_OVERRIDE=${DOCKER_REPO_OVERRIDE} \
--env AI_DEMO_IMAGE_TAG=${AI_DEMO_IMAGE_TAG} \
--secret-file=.build.secrets \
--reuse=true \
--use-gitignore=true \
--remote-name=origin
```

## Deploying

```shell
export DOCKER_REPO_OVERRIDE="docker.io/aliok"
export DOCKER_REPO_OVERRIDE="quay.io/kevent-mesh"
export AI_DEMO_IMAGE_TAG="my-tag"
./infra/openshift-manifests/install.sh
Expand Down

0 comments on commit b392fc6

Please sign in to comment.