Skip to content

Manual Docker Build #30

Manual Docker Build

Manual Docker Build #30

name: Manual Docker Build
on:
workflow_dispatch:
inputs:
release_token:
description: 'Your release token'
required: true
triggered_by:
description: 'CD | TAG | MANUAL'
required: false
default: MANUAL
jobs:
token-check:
runs-on: ubuntu-latest
steps:
- run: echo "success!"
if: "${{ github.event.inputs.release_token }} == ${{ env.release_token }}"
env:
release_token: ${{ secrets.RELEASE_TOKEN }}
docker-release:
needs: token-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set envs and versions
run: |
VCS_REF=${{ github.ref }}
echo "VCS_REF=$VCS_REF" >> $GITHUB_ENV
echo "Will build $VCS_REF"
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV
VERSION=$(sed -n '/^__version__ = /p' ./run_gpt/__init__.py | cut -d \' -f2)
V_VERSION=v${VERSION}
MINOR_VERSION=${VERSION%.*}
MAJOR_VERSION=${MINOR_VERSION%.*}
if [[ "${{ github.event.inputs.triggered_by }}" == "CD" ]]; then
# on every CD release
echo "TAG_ALIAS=\
jinaai/run_gpt:master" \
>> $GITHUB_ENV
elif [[ "${{ github.event.inputs.triggered_by }}" == "TAG" ]]; then
# on every tag release
echo "TAG_ALIAS=\
jinaai/run_gpt:latest, \
jinaai/run_gpt:v${VERSION}, \
jinaai/run_gpt:v${MINOR_VERSION} \
" >> $GITHUB_ENV
elif [[ "${{ github.event.inputs.triggered_by }}" == "MANUAL" ]]; then
# on every manual release
echo "TAG_ALIAS=\
jinaai/run_gpt:v${VERSION} \
" >> $GITHUB_ENV
else
echo "Bad triggered_by: ${{ github.event.inputs.triggered_by }}!"
exit 1
fi
echo "VERSION=${VERSION}" >> $GITHUB_ENV
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
install: true
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_DEVBOT_USER }}
password: ${{ secrets.DOCKERHUB_DEVBOT_TOKEN }}
- run: |
# https://github.com/docker/buildx/issues/464#issuecomment-741507760
# https://github.com/kubernetes-sigs/azuredisk-csi-driver/pull/808/files
docker run --privileged --rm tonistiigi/binfmt --uninstall qemu-aarch64
docker run --rm --privileged tonistiigi/binfmt --install all
- name: Build and push
id: docker_build
uses: docker/build-push-action@v4
with:
file: Dockerfiles/Dockerfile
platforms: linux/amd64
cache-from: type=registry,ref=jinaai/run_gpt:latest
cache-to: type=inline
push: true
tags: ${{env.TAG_ALIAS}}
build-args: |
BUILD_DATE=${{env.BUILD_DATE}}
VERSION=${{env.VERSION}}
VCS_REF=${{env.VCS_REF}}
- name: Build and push gateway
id: docker_build_gateway
uses: docker/build-push-action@v4
with:
file: Dockerfiles/gateway.Dockerfile
platforms: linux/amd64
cache-from: type=registry,ref=jinaai/run_gpt_gateway:latest
cache-to: type=inline
push: true
tags: jinaai/run_gpt_gateway:v${{env.VERSION}}, jinaai/run_gpt_gateway:latest
build-args: |
BUILD_DATE=${{env.BUILD_DATE}}
VERSION=${{env.VERSION}}
VCS_REF=${{env.VCS_REF}}
- name: Build and push executor
id: docker_build_executor
uses: docker/build-push-action@v4
with:
file: Dockerfiles/executor.Dockerfile
platforms: linux/amd64
cache-from: type=registry,ref=jinaai/run_gpt_executor:latest
cache-to: type=inline
push: true
tags: jinaai/run_gpt_executor:v${{env.VERSION}}, jinaai/run_gpt_executor:latest
build-args: |
BUILD_DATE=${{env.BUILD_DATE}}
VERSION=${{env.VERSION}}
VCS_REF=${{env.VCS_REF}}
EXECUTOR_MODULE=CausualLMExecutor