Skip to content

Commit

Permalink
[CI] Integrates temp into build, integration, publishing pipeline
Browse files Browse the repository at this point in the history
This PR contains a renovated Actions setup for DJL Serving as promised in
#1264. The major change is to
create a new nightly orchestration action that will call the build, integration,
and publish actions. Note that the lmic performance and PySDK integration tests
were not included and will run as usual.

The build was changed to always push to the temp repo. It does still take a
nightly/release to determine the version used during build. All of the
publishing to both docker hub and ECR are done in the publish pipeline. It will
pull the images from the temp repo and then retag and upload them to both docker
hub (nightly or release) and ECR.

The integration tests are changed to run off only the temp builds. Each of them
will pull and use the instances from the temp repo.

In summary, here is a summary of the major workflows you will need:

- Nightly - The nightly action runs almost everything by a cron job like usual.
It will not publish a bad release failing the tests. The list of actions to
monitor consists of nightly and the two integration tests not included in it.
- Release - The release can be done by running the nightly action. Only the
single action needs to be run and it will complete the full verification up to ECR.
- Development - For development with integration tests, you should begin by
making a branch on upstream. Then, run the build for your branch. Once it is
built, you can run any integration test on your branch as usual. You no longer
have to worry about conflicts with other developers or polluting the public
docker hub.
  • Loading branch information
zachgk committed Feb 3, 2024
1 parent a3dad0f commit 55288d0
Show file tree
Hide file tree
Showing 14 changed files with 833 additions and 327 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
name: Build and push docker nightly
name: Docker build

on:
workflow_dispatch:
inputs:
mode:
description: 'release/nightly/temp, default is nightly'
description: 'release/nightly, default is nightly'
required: true
default: 'nightly'
options:
- release
- nightly
workflow_call:
inputs:
mode:
description: 'release/nightly, default is nightly'
type: string
required: true
default: 'nightly'
schedule:
- cron: '0 13 * * *'

permissions:
id-token: write
Expand All @@ -35,6 +43,7 @@ jobs:
password: ${{ secrets.DOCKER_PASSWORD }}
- name: install awscli
run: |
sudo dpkg --configure -a
sudo apt-get update
sudo apt-get install awscli -y
- name: Configure AWS Credentials
Expand All @@ -55,17 +64,9 @@ jobs:
if: ${{ github.event.inputs.mode == '' || github.event.inputs.mode == 'nightly' }}
run: |
./gradlew :serving:dockerDeb -Psnapshot
- name: Build and push nightly docker image
- name: Build and push nightly image
if: ${{ github.event.inputs.mode == '' || github.event.inputs.mode == 'nightly' }}
working-directory: serving/docker
run: |
DJL_VERSION=$(cat ../../gradle.properties | awk -F '=' '/djl_version/ {print $2}')
export NIGHTLY="-nightly"
docker compose build --no-cache --build-arg djl_version=${DJL_VERSION}~SNAPSHOT ${{ matrix.arch }}
docker compose push ${{ matrix.arch }}
- name: Build and push temp image
if: ${{ github.event.inputs.mode == 'temp' }}
working-directory: serving/docker
run: |
DJL_VERSION=$(cat ../../gradle.properties | awk -F '=' '/djl_version/ {print $2}')
export NIGHTLY="-nightly"
Expand All @@ -75,22 +76,19 @@ jobs:
tempTag="$repo:${{ matrix.arch }}-${GITHUB_SHA}"
docker tag deepjavalibrary/djl-serving:${{ matrix.arch }}-nightly $tempTag
docker push $tempTag
- name: Build and push release docker image
- name: Build and push release image
if: ${{ github.event.inputs.mode == 'release' }}
working-directory: serving/docker
run: |
DJL_VERSION=$(cat ../../gradle.properties | awk -F '=' '/djl_version/ {print $2}')
export BASE_RELEASE_VERSION="${DJL_VERSION}"
export RELEASE_VERSION="${DJL_VERSION}-"
docker compose build --no-cache --build-arg djl_version=${DJL_VERSION} ${{ matrix.arch }}
docker compose push ${{ matrix.arch }}
- name: Retag image for release
if: ${{ matrix.arch == 'cpu' && github.event.inputs.mode == 'release' }}
working-directory: serving/docker
run: |
DJL_VERSION=$(cat ../../gradle.properties | awk -F '=' '/djl_version/ {print $2}')
docker tag deepjavalibrary/djl-serving:${DJL_VERSION} deepjavalibrary/djl-serving:latest
docker push deepjavalibrary/djl-serving:latest
repo="185921645874.dkr.ecr.us-east-1.amazonaws.com/djl-ci-temp"
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $repo
tempTag="$repo:${{ matrix.arch }}-${GITHUB_SHA}"
docker tag deepjavalibrary/djl-serving:${{ matrix.arch }} $tempTag
docker push $tempTag
create-runner:
runs-on: [ self-hosted, scheduler ]
Expand Down Expand Up @@ -123,6 +121,11 @@ jobs:
needs: create-runner
steps:
- uses: actions/checkout@v4
- name: install awscli
run: |
sudo dpkg --configure -a
sudo apt-get update
sudo apt-get install awscli -y
- name: Clean docker env
working-directory: serving/docker
run: |
Expand All @@ -132,10 +135,6 @@ jobs:
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: install awscli
run: |
sudo apt-get update
sudo apt-get install awscli -y
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
Expand All @@ -154,17 +153,9 @@ jobs:
if: ${{ github.event.inputs.mode == '' || github.event.inputs.mode == 'nightly' }}
run: |
./gradlew :serving:dockerDeb -Psnapshot
- name: Build and push nightly docker image
- name: Build and push nightly image
if: ${{ github.event.inputs.mode == '' || github.event.inputs.mode == 'nightly' }}
working-directory: serving/docker
run: |
DJL_VERSION=$(cat ../../gradle.properties | awk -F '=' '/djl_version/ {print $2}')
export NIGHTLY="-nightly"
docker compose build --no-cache --build-arg djl_version=${DJL_VERSION}~SNAPSHOT aarch64
docker compose push aarch64
- name: Build and push temp image
if: ${{ github.event.inputs.mode == 'temp' }}
working-directory: serving/docker
run: |
DJL_VERSION=$(cat ../../gradle.properties | awk -F '=' '/djl_version/ {print $2}')
export NIGHTLY="-nightly"
Expand All @@ -174,22 +165,31 @@ jobs:
tempTag="$repo:aarch64-${GITHUB_SHA}"
docker tag deepjavalibrary/djl-serving:aarch64-nightly $tempTag
docker push $tempTag
- name: Build and push release docker image
- name: Build and push release image
if: ${{ github.event.inputs.mode == 'release' }}
working-directory: serving/docker
run: |
DJL_VERSION=$(cat ../../gradle.properties | awk -F '=' '/djl_version/ {print $2}')
export BASE_RELEASE_VERSION="${DJL_VERSION}"
export RELEASE_VERSION="${DJL_VERSION}-"
docker compose build --no-cache --build-arg djl_version=${DJL_VERSION} aarch64
docker compose push aarch64
repo="185921645874.dkr.ecr.us-east-1.amazonaws.com/djl-ci-temp"
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $repo
tempTag="$repo:aarch64-${GITHUB_SHA}"
docker tag deepjavalibrary/djl-serving:aarch64 $tempTag
docker push $tempTag
nightly-deepspeed:
runs-on: [ self-hosted, cpu ]
timeout-minutes: 60
needs: create-runner
steps:
- uses: actions/checkout@v4
- name: install awscli
run: |
sudo dpkg --configure -a
sudo apt-get update
sudo apt-get install awscli -y
- name: Clean docker env
working-directory: serving/docker
run: |
Expand All @@ -199,10 +199,6 @@ jobs:
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: install awscli
run: |
sudo apt-get update
sudo apt-get install awscli -y
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
Expand All @@ -221,35 +217,31 @@ jobs:
if: ${{ github.event.inputs.mode == '' || github.event.inputs.mode == 'nightly' }}
run: |
./gradlew :serving:dockerDeb -Psnapshot
- name: Build and push nightly docker image
- name: Build and push nightly image
if: ${{ github.event.inputs.mode == '' || github.event.inputs.mode == 'nightly' }}
working-directory: serving/docker
run: |
DJL_VERSION=$(cat ../../gradle.properties | awk -F '=' '/djl_version/ {print $2}')
export NIGHTLY="-nightly"
docker compose build --no-cache --build-arg djl_version=${DJL_VERSION}~SNAPSHOT deepspeed
docker compose push deepspeed
- name: Build and push temp image
if: ${{ github.event.inputs.mode == 'temp' }}
working-directory: serving/docker
run: |
DJL_VERSION=$(cat ../../gradle.properties | awk -F '=' '/djl_version/ {print $2}')
export NIGHTLY="-nightly"
docker compose build --no-cache --build-arg djl_version=${DJL_VERSION}~SNAPSHOT deepspeed
repo="185921645874.dkr.ecr.us-east-1.amazonaws.com/djl-ci-temp"
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $repo
tempTag="$repo:deepspeed-$GITHUB_SHA"
tempTag="$repo:deepspeed-${GITHUB_SHA}"
docker tag deepjavalibrary/djl-serving:deepspeed-nightly $tempTag
docker push $tempTag
- name: Build and push release docker image
- name: Build and push release image
if: ${{ github.event.inputs.mode == 'release' }}
working-directory: serving/docker
run: |
DJL_VERSION=$(cat ../../gradle.properties | awk -F '=' '/djl_version/ {print $2}')
export BASE_RELEASE_VERSION="${DJL_VERSION}"
export RELEASE_VERSION="${DJL_VERSION}-"
docker compose build --no-cache --build-arg djl_version=${DJL_VERSION} deepspeed
docker compose push deepspeed
repo="185921645874.dkr.ecr.us-east-1.amazonaws.com/djl-ci-temp"
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $repo
tempTag="$repo:deepspeed-${GITHUB_SHA}"
docker tag deepjavalibrary/djl-serving:deepspeed $tempTag
docker push $tempTag
stop-runner:
if: always()
Expand Down
102 changes: 102 additions & 0 deletions .github/workflows/docker_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Sync docker and ECR repo

on:
workflow_dispatch:
inputs:
mode:
description: 'release/nightly, default is nightly'
required: true
default: 'nightly'
options:
- release
- nightly
workflow_call:
inputs:
mode:
description: 'release/nightly, default is nightly'
type: string
required: true
default: 'nightly'

permissions:
id-token: write
contents: read

jobs:
create-aarch64-runner:
runs-on: [ self-hosted, scheduler ]
steps:
- name: Create new Graviton instance
id: create_aarch64
run: |
cd /home/ubuntu/djl_benchmark_script/scripts
token=$( curl -X POST -H "Authorization: token ${{ secrets.ACTION_RUNNER_PERSONAL_TOKEN }}" \
https://api.github.com/repos/deepjavalibrary/djl-serving/actions/runners/registration-token \
--fail \
| jq '.token' | tr -d '"' )
./start_instance.sh action_graviton $token djl-serving
outputs:
aarch64_instance_id: ${{ steps.create_aarch64.outputs.action_graviton_instance_id }}

nightly-aarch64:
runs-on: [ self-hosted, aarch64 ]
timeout-minutes: 60
needs: create-aarch64-runner
steps:
- uses: actions/checkout@v3
- name: Clean docker env
working-directory: serving/docker
run: |
yes | docker system prune -a --volumes
- name: Login to Docker
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: install awscli
run: |
sudo apt-get update
sudo apt-get install awscli -y
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::185921645874:role/github-actions-djl-serving
aws-region: us-east-1
- name: Pull and sync to docker hub
working-directory: serving/docker
run: |
DJL_VERSION=$(cat ../../gradle.properties | awk -F '=' '/djl_version/ {print $2}')
[ -z "$version" ] && version="nightly"
repo="185921645874.dkr.ecr.us-east-1.amazonaws.com/djl-ci-temp"
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $repo
./scripts/pull_and_retag.sh $version deepjavalibrary/djl-serving {{ github.event.inputs.mode }}
- name: Pull and sync to ECR
working-directory: serving/docker
run: |
DJL_VERSION=$(cat ../../gradle.properties | awk -F '=' '/djl_version/ {print $2}')
[ -z "$version" ] && version="nightly"
repo="125045733377.dkr.ecr.us-east-1.amazonaws.com/djl-serving"
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $repo
./scripts/pull_and_retag.sh $version $repo {{ github.event.inputs.mode }}
- name: Retag image for release latest
if: ${{ github.event.inputs.mode == 'release' }}
working-directory: serving/docker
run: |
DJL_VERSION=$(cat ../../gradle.properties | awk -F '=' '/djl_version/ {print $2}')
docker tag deepjavalibrary/djl-serving:${DJL_VERSION} deepjavalibrary/djl-serving:latest
docker push deepjavalibrary/djl-serving:latest
- name: Clean docker env
working-directory: serving/docker
run: |
yes | docker system prune -a --volumes
stop-aarch64-runner:
if: always()
runs-on: [ self-hosted, scheduler ]
needs: [nightly-aarch64, create-aarch64-runner]
steps:
- name: Stop all instances
run: |
cd /home/ubuntu/djl_benchmark_script/scripts
instance_id=${{ needs.create-aarch64-runner.outputs.aarch64_instance_id }}
./stop_instance.sh $instance_id
Loading

0 comments on commit 55288d0

Please sign in to comment.