Build and push docker nightly #1152
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, default is nightly' | |
required: true | |
default: 'nightly' | |
schedule: | |
- cron: '0 13 * * *' | |
jobs: | |
nightly-build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
arch: [ cpu, cpu-full, pytorch-inf2, pytorch-cu118, fastertransformer ] | |
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@v3 | |
- name: Login to Docker | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'corretto' | |
java-version: 11 | |
- uses: actions/cache@v3 | |
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 serving package for release | |
if: ${{ github.event.inputs.mode == 'release' }} | |
run: | | |
./gradlew :serving:dockerDeb -Pstaging | |
- 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 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@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: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'corretto' | |
java-version: 11 | |
- uses: actions/cache@v3 | |
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 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@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: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'corretto' | |
java-version: 11 | |
- uses: actions/cache@v3 | |
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 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 |