Build and push docker nightly #1398
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and push docker nightly | |
on: | |
workflow_dispatch: | |
inputs: | |
mode: | |
description: 'release/nightly/temp, default is nightly' | |
required: true | |
default: 'nightly' | |
schedule: | |
- cron: '0 13 * * *' | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
nightly-build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
arch: [ cpu, cpu-full, pytorch-inf2, pytorch-gpu, tensorrt-llm ] | |
steps: | |
- name: Clean disk space | |
run: | | |
sudo rm -rf \ | |
/usr/share/dotnet /usr/local/lib/android /opt/ghc \ | |
/usr/local/share/powershell /usr/share/swift /usr/local/.ghcup \ | |
$AGENT_TOOLSDIRECTORY | |
- uses: actions/checkout@v4 | |
- 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: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'corretto' | |
java-version: 17 | |
- uses: actions/cache@v4 | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} | |
- name: Build serving package for nightly | |
if: ${{ github.event.inputs.mode == '' || github.event.inputs.mode == 'nightly' }} | |
run: | | |
./gradlew :serving:dockerDeb -Psnapshot | |
- name: Build and push nightly docker 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" | |
docker compose build --no-cache --build-arg djl_version=${DJL_VERSION}~SNAPSHOT ${{ matrix.arch }} | |
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 }}-nightly $tempTag | |
docker push $tempTag | |
- name: Build and push release docker 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 | |
create-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 | |
- name: Create new CPU instance | |
id: create_cpu | |
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_cpu $token djl-serving | |
outputs: | |
aarch64_instance_id: ${{ steps.create_aarch64.outputs.action_graviton_instance_id }} | |
cpu_instance_id: ${{ steps.create_cpu.outputs.action_cpu_instance_id }} | |
nightly-aarch64: | |
runs-on: [ self-hosted, aarch64 ] | |
timeout-minutes: 60 | |
needs: create-runner | |
steps: | |
- uses: actions/checkout@v4 | |
- 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: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'corretto' | |
java-version: 17 | |
- uses: actions/cache@v4 | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} | |
- name: Build serving package for nightly | |
if: ${{ github.event.inputs.mode == '' || github.event.inputs.mode == 'nightly' }} | |
run: | | |
./gradlew :serving:dockerDeb -Psnapshot | |
- name: Build and push nightly docker 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" | |
docker compose build --no-cache --build-arg djl_version=${DJL_VERSION}~SNAPSHOT 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-nightly $tempTag | |
docker push $tempTag | |
- name: Build and push release docker 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 | |
nightly-deepspeed: | |
runs-on: [ self-hosted, cpu ] | |
timeout-minutes: 60 | |
needs: create-runner | |
steps: | |
- uses: actions/checkout@v4 | |
- 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: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'corretto' | |
java-version: 17 | |
- uses: actions/cache@v4 | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} | |
- name: Build serving package for nightly | |
if: ${{ github.event.inputs.mode == '' || github.event.inputs.mode == 'nightly' }} | |
run: | | |
./gradlew :serving:dockerDeb -Psnapshot | |
- name: Build and push nightly docker 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" | |
docker tag deepjavalibrary/djl-serving:deepspeed-nightly $tempTag | |
docker push $tempTag | |
- name: Build and push release docker 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 | |
stop-runner: | |
if: always() | |
runs-on: [ self-hosted, scheduler ] | |
needs: [nightly-aarch64, nightly-deepspeed, create-runner] | |
steps: | |
- name: Stop all instances | |
run: | | |
cd /home/ubuntu/djl_benchmark_script/scripts | |
instance_id=${{ needs.create-runner.outputs.aarch64_instance_id }} | |
./stop_instance.sh $instance_id | |
instance_id=${{ needs.create-runner.outputs.cpu_instance_id }} | |
./stop_instance.sh $instance_id |