-
Notifications
You must be signed in to change notification settings - Fork 2.1k
134 lines (122 loc) · 4.76 KB
/
force-docker-build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
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.CAS_RELEASE_TOKEN }}
docker-release:
needs: token-check
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
pip_tag: ["", "onnx", "tensorrt"] # default: "" = torch
engine_tag: ["", "cuda"] # default: "" = cpu
steps:
- uses: actions/checkout@v2
- 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
echo "BUILD_TARGET=clip_executor" >> $GITHUB_ENV
CAS_VERSION=$(sed -n '/^__version__/p' ./server/clip_server/__init__.py | cut -d \' -f2)
V_CAS_VERSION=v${CAS_VERSION}
CAS_MINOR_VERSION=${CAS_VERSION%.*}
CAS_MAJOR_VERSION=${CAS_MINOR_VERSION%.*}
ENGINE_TAG=${{matrix.engine_tag}}
if [ -n "${ENGINE_TAG}" ]; then
ENGINE_TAG=-${ENGINE_TAG//./}
fi
PIP_TAG=${{ matrix.pip_tag }}
BACKEND_TAG=torch
if [ -n "${PIP_TAG}" ]; then
BACKEND_TAG=${PIP_TAG}
PIP_TAG=-${PIP_TAG}
fi
if [[ "${{ github.event.inputs.triggered_by }}" == "CD" ]]; then
# on every CD release
echo "TAG_ALIAS=\
jinaai/clip_executor:master${PIP_TAG}${ENGINE_TAG}" \
>> $GITHUB_ENV
elif [[ "${{ github.event.inputs.triggered_by }}" == "TAG" ]]; then
# on every tag release
echo "TAG_ALIAS=\
jinaai/clip_executor:latest${PIP_TAG}${ENGINE_TAG}, \
jinaai/clip_executor:${CAS_VERSION}${PIP_TAG}${ENGINE_TAG}, \
jinaai/clip_executor:${CAS_MINOR_VERSION}${PIP_TAG}${ENGINE_TAG} \
" >> $GITHUB_ENV
elif [[ "${{ github.event.inputs.triggered_by }}" == "MANUAL" ]]; then
# on every manual release
echo "TAG_ALIAS=\
jinaai/clip_executor:${CAS_VERSION}${PIP_TAG}${ENGINE_TAG} \
" >> $GITHUB_ENV
else
echo "Bad triggered_by: ${{ github.event.inputs.triggered_by }}!"
exit 1
fi
echo "CAS_VERSION=${CAS_VERSION}" >> $GITHUB_ENV
echo "BACKEND_TAG=${BACKEND_TAG}" >> $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: CPU Build and push
id: base_docker_build
if: ${{ matrix.engine_tag == '' && matrix.pip_tag != 'tensorrt' }}
uses: docker/build-push-action@v2
with:
context: server
file: Dockerfiles/base.Dockerfile
platforms: linux/amd64
cache-from: type=registry,ref=jinaai/clip_executor:latest
cache-to: type=inline
push: true
tags: ${{env.TAG_ALIAS}}
build-args: |
BUILD_DATE=${{env.BUILD_DATE}}
CAS_VERSION=${{env.CAS_VERSION}}
VCS_REF=${{env.VCS_REF}}
BACKEND_TAG=${{env.BACKEND_TAG}}
- name: CUDA Build and push
id: cuda_docker_build
if: ${{ matrix.engine_tag == 'cuda' }}
uses: docker/build-push-action@v2
with:
context: server
file: Dockerfiles/cuda.Dockerfile
platforms: linux/amd64
cache-from: type=registry,ref=jinaai/clip_executor:latest-cuda
cache-to: type=inline
push: true
tags: ${{env.TAG_ALIAS}}
build-args: |
BUILD_DATE=${{env.BUILD_DATE}}
CAS_VERSION=${{env.CAS_VERSION}}
VCS_REF=${{env.VCS_REF}}
BACKEND_TAG=${{env.BACKEND_TAG}}