Skip to content

Commit

Permalink
Merge pull request #26 from strangiato/2.16
Browse files Browse the repository at this point in the history
2.16 update with actions rewrite
  • Loading branch information
strangiato authored Sep 5, 2024
2 parents 1977520 + 022a241 commit 8395d0a
Show file tree
Hide file tree
Showing 6 changed files with 1,129 additions and 836 deletions.
69 changes: 18 additions & 51 deletions .github/workflows/build-image-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,57 +8,24 @@ on:
- '!main'
paths:
- 'mlflow-server/**'
- '.github/**'

jobs:

build:
name: Build Image
runs-on: ubuntu-22.04
env:
BASE_IMAGE: 'registry.access.redhat.com/ubi9/python-311:latest'
REGISTRY: quay.io/troyer
IMAGE_NAME: mlflow-server
MAIN_TAG: latest-dev

steps:

- name: Checkout
uses: actions/checkout@v2

# Setup S2i and Build container image
- name: Setup and Build
id: build_image
uses: redhat-actions/s2i-build@v2
with:
path_context: 'mlflow-server'
builder_image: ${{ env.BASE_IMAGE }}
image: ${{ env.IMAGE_NAME }}
tags: ${{ env.MAIN_TAG }}
- name: Retrieve version
uses: addnab/docker-run-action@v3
with:
image: ${{ env.IMAGE_NAME }}:${{ env.MAIN_TAG }}
run: |
FULL_VERSION=$(pip show mlflow | grep -i version | awk '{print $2}')
major=`echo $FULL_VERSION | cut -d. -f1`
minor=`echo $FULL_VERSION | cut -d. -f2`
revision=`echo $FULL_VERSION | cut -d. -f3`
MINOR_VERSION=$(echo "$major.$minor")
echo "::set-output name=FULL_VERSION::${FULL_VERSION}"
echo "::set-output name=MINOR_VERSION::${MINOR_VERSION}"
id: version
get-version:
uses: ./.github/workflows/workflow-get-package-version.yaml
with:
context: "mlflow-server"
package: mlflow

- name: Add tags
run: |
docker tag ${{ env.IMAGE_NAME }}:${{ env.MAIN_TAG }} ${{ env.IMAGE_NAME }}:${{ steps.version.outputs.FULL_VERSION }}-dev
docker tag ${{ env.IMAGE_NAME }}:${{ env.MAIN_TAG }} ${{ env.IMAGE_NAME }}:${{ steps.version.outputs.MINOR_VERSION }}-dev
# Push Image to Quay registry
- name: Push To Quay Action
uses: redhat-actions/push-to-registry@v2.7
with:
image: ${{ steps.build_image.outputs.image }}
tags: ${{ steps.build_image.outputs.tags }} ${{ steps.version.outputs.FULL_VERSION }}-dev ${{ steps.version.outputs.MINOR_VERSION }}-dev
registry: ${{ env.REGISTRY }}
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
build:
uses: ./.github/workflows/workflow-build-image.yaml
needs: get-version
with:
registry: quay.io/troyer
image-name: mlflow-server
context: "mlflow-server"
version-tag: ${{ needs.get-version.outputs.package-version }}
tag-suffix: "-dev"
secrets:
registry-username: ${{ secrets.QUAY_USERNAME }}
registry-password: ${{ secrets.QUAY_PASSWORD }}
70 changes: 17 additions & 53 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,57 +8,21 @@ on:
- 'mlflow-server/**'

jobs:

build:
name: Build Image
runs-on: ubuntu-latest
env:
BASE_IMAGE: 'registry.access.redhat.com/ubi9/python-311:latest'
REGISTRY: quay.io/troyer
IMAGE_NAME: mlflow-server
MAIN_TAG: latest-dev

steps:

- name: Checkout
uses: actions/checkout@v2

# Setup S2i and Build container image
- name: Setup and Build
id: build_image
uses: redhat-actions/s2i-build@v2
with:
path_context: 'mlflow-server'
builder_image: ${{ env.BASE_IMAGE }}
image: ${{ env.IMAGE_NAME }}
tags: ${{ env.MAIN_TAG }}
get-version:
uses: ./.github/workflows/workflow-get-package-version.yaml
with:
context: "mlflow-server"
package: mlflow

- name: Retrieve version
uses: addnab/docker-run-action@v3
with:
image: ${{ env.IMAGE_NAME }}:${{ env.MAIN_TAG }}
run: |
FULL_VERSION=$(pip show mlflow | grep -i version | awk '{print $2}')
major=`echo $FULL_VERSION | cut -d. -f1`
minor=`echo $FULL_VERSION | cut -d. -f2`
revision=`echo $FULL_VERSION | cut -d. -f3`
MINOR_VERSION=$(echo "$major.$minor")
echo "::set-output name=FULL_VERSION::${FULL_VERSION}"
echo "::set-output name=MINOR_VERSION::${MINOR_VERSION}"
id: version

- name: Add tags
run: |
docker tag ${{ env.IMAGE_NAME }}:${{ env.MAIN_TAG }} ${{ env.IMAGE_NAME }}:latest
docker tag ${{ env.IMAGE_NAME }}:${{ env.MAIN_TAG }} ${{ env.IMAGE_NAME }}:${{ steps.version.outputs.FULL_VERSION }}
docker tag ${{ env.IMAGE_NAME }}:${{ env.MAIN_TAG }} ${{ env.IMAGE_NAME }}:${{ steps.version.outputs.MINOR_VERSION }}
# Push Image to Quay registry
- name: Push To Quay Action
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build_image.outputs.image }}
tags: ${{ steps.build_image.outputs.tags }} latest ${{ steps.version.outputs.FULL_VERSION }} ${{ steps.version.outputs.MINOR_VERSION }}
registry: ${{ env.REGISTRY }}
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
build:
uses: ./.github/workflows/workflow-build-image.yaml
needs: get-version
with:
registry: quay.io/troyer
image-name: mlflow-server
context: "mlflow-server"
version-tag: ${{ needs.get-version.outputs.package-version }}
tag-suffix: ""
secrets:
registry-username: ${{ secrets.QUAY_USERNAME }}
registry-password: ${{ secrets.QUAY_PASSWORD }}
94 changes: 94 additions & 0 deletions .github/workflows/workflow-build-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: build-image
on:
workflow_call:
inputs:
registry:
required: true
type: string
image-name:
required: true
type: string
context:
required: true
type: string
version-tag:
required: true
type: string
tag-suffix:
required: true
type: string
base-image:
required: false
type: string
default: 'registry.access.redhat.com/ubi9/python-311:latest'
secrets:
registry-username:
required: true
registry-password:
required: true
outputs:
target_tag:
value: ${{ jobs.build-image.outputs.target_tag }}

jobs:
build-image:
name: Build Image
runs-on: ubuntu-latest
outputs:
target_tag: ${{ steps.tags.outputs.date_tag }}
steps:

- name: Checkout Repository
id: checkout
uses: actions/checkout@v4

- name: downgrade docker
run: |
apt-cache madison docker.io
sudo apt-get remove containerd.io
sudo apt-get install docker.io=24.0.7-0ubuntu2~22.04.1
- name: Generate tags
id: tags
run: |
LATEST_TAG="latest"${{ inputs.tag-suffix }}
echo "latest_tag=$LATEST_TAG" | tee -a $GITHUB_OUTPUT
FULL_VERSION_TAG=${{ inputs.version-tag }}${{ inputs.tag-suffix }}
echo "full_version_tag=$FULL_VERSION_TAG" | tee -a $GITHUB_OUTPUT
major=`echo ${{ inputs.version-tag }} | cut -d. -f1`
minor=`echo ${{ inputs.version-tag }} | cut -d. -f2`
revision=`echo ${{ inputs.version-tag }} | cut -d. -f3`
MINOR_VERSION_TAG=$(echo "$major.$minor")${{ inputs.tag-suffix }}
echo "minor_version_tag=$MINOR_VERSION_TAG" | tee -a $GITHUB_OUTPUT
DATE=$(date -u +'%Y%m%dt%H%Mz')
echo "date=${DATE}" | tee -a $GITHUB_OUTPUT
DATE_TAG=${{ inputs.version-tag }}-${DATE}${{ inputs.tag-suffix }}
echo "date_tag=${DATE_TAG}" | tee -a $GITHUB_OUTPUT
- name: Setup and Build
id: build_image
uses: redhat-actions/s2i-build@v2
with:
path_context: ${{ inputs.context }}
builder_image: ${{ inputs.base-image }}
image: ${{ inputs.image-name }}
tags: ${{ steps.tags.outputs.latest_tag }}

- name: Add tags
run: |
docker tag ${{ inputs.image-name }}:${{ steps.tags.outputs.latest_tag }} ${{ inputs.image-name }}:${{ steps.tags.outputs.full_version_tag }}
docker tag ${{ inputs.image-name }}:${{ steps.tags.outputs.latest_tag }} ${{ inputs.image-name }}:${{ steps.tags.outputs.minor_version_tag }}
docker tag ${{ inputs.image-name }}:${{ steps.tags.outputs.latest_tag }} ${{ inputs.image-name }}:${{ steps.tags.outputs.date_tag }}
docker image ls
- name: Push-Image
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build_image.outputs.image }}
tags: ${{ steps.tags.outputs.latest_tag }} ${{ steps.tags.outputs.full_version_tag }} ${{ steps.tags.outputs.minor_version_tag }} ${{ steps.tags.outputs.date_tag }}
registry: ${{ inputs.registry }}
username: ${{ secrets.registry-username }}
password: ${{ secrets.registry-password }}
36 changes: 36 additions & 0 deletions .github/workflows/workflow-get-package-version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: get-package-version
on:
workflow_call:
inputs:
context:
required: true
type: string
package:
required: true
type: string
default: mlflow
outputs:
package-version:
value: ${{ jobs.get-version.outputs.package-version }}

jobs:
get-version:
runs-on: ubuntu-latest
outputs:
package-version: ${{ steps.package-version.outputs.package_version }}
steps:
- name: Checkout Repository
id: checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install pipenv
run: pip install pipenv
- name: Get package-version
id: package-version
run: |
cd ${{ inputs.context }}
PACKAGE_VERSION=$(pipenv requirements | grep -o -E "${{ inputs.package }}==([0-9]+\.[0-9]+\.[0-9]+)" | cut -d '=' -f 3)
echo "package_version=$PACKAGE_VERSION" | tee -a $GITHUB_OUTPUT
2 changes: 1 addition & 1 deletion mlflow-server/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ verify_ssl = true
name = "pypi"

[packages]
mlflow = "~=2.12.0"
mlflow = "~=2.16.0"
boto3 = "*"
psycopg2-binary = "*"
environ-config = "*"
Expand Down
Loading

0 comments on commit 8395d0a

Please sign in to comment.