-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add cas server dockerfile (#757)
* feat: add cas server dockerfile * feat: add cas server dockerfile * feat: add cas server dockerfile * feat: add cas server dockerfile * feat: add cas server dockerfile * feat: add cas server dockerfile * feat: add cas server dockerfile * feat: add cas server dockerfile * feat: add cas server dockerfile * feat: add cas server dockerfile * feat: add cas server dockerfile * feat: add cas server dockerfile * feat: add cas server dockerfile * feat: add cas server dockerfile * feat: add cas server dockerfile * feat: add cas server dockerfile * feat: add cas server dockerfile * fix: absolute path in hub image
- Loading branch information
Showing
29 changed files
with
367 additions
and
136 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
name: Manual CAS 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 }} | ||
|
||
regular-release: | ||
needs: token-check | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
pip_tag: [ "", "onnx", "tensorrt"] # default: "" = core | ||
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 | ||
if [[ "${{ matrix.pip_tag }}" == "perf" ]]; then | ||
echo "JINA_PIP_INSTALL_PERF=1" >> $GITHUB_ENV | ||
fi | ||
if [[ "${{ matrix.pip_tag }}" == "" ]]; then | ||
echo "JINA_PIP_INSTALL_CORE=1" >> $GITHUB_ENV | ||
fi | ||
JINA_VERSION=$(sed -n '/^__version__/p' ./server/clip_server/__init__.py | cut -d \' -f2) | ||
V_JINA_VERSION=v${JINA_VERSION} | ||
JINA_MINOR_VERSION=${JINA_VERSION%.*} | ||
JINA_MAJOR_VERSION=${JINA_MINOR_VERSION%.*} | ||
PY_TAG=${{matrix.py_version}} | ||
if [ -n "${PY_TAG}" ]; then | ||
PY_TAG=-py${PY_TAG//./} | ||
fi | ||
PIP_TAG=${{ matrix.pip_tag }} | ||
if [ -n "${PIP_TAG}" ]; then | ||
PIP_TAG=-${PIP_TAG} | ||
fi | ||
if [[ "${{ github.event.inputs.triggered_by }}" == "CD" ]]; then | ||
if [[ "${{ matrix.py_version }}" == "$DEFAULT_PY_VERSION" ]]; then | ||
echo "TAG_ALIAS=\ | ||
jinaai/clip-as-service:master${PY_TAG}${PIP_TAG}, \ | ||
jinaai/clip-as-service:master${PIP_TAG}" \ | ||
>> $GITHUB_ENV | ||
else | ||
# on every CD | ||
echo "TAG_ALIAS=\ | ||
jinaai/clip-as-service:master${PY_TAG}${PIP_TAG}" \ | ||
>> $GITHUB_ENV | ||
fi | ||
elif [[ "${{ github.event.inputs.triggered_by }}" == "TAG" ]]; then | ||
# on every tag release | ||
if [[ "${{ matrix.py_version }}" == "$DEFAULT_PY_VERSION" ]]; then | ||
echo "TAG_ALIAS=\ | ||
jinaai/clip-as-service:latest${PY_TAG}${PIP_TAG}, \ | ||
jinaai/clip-as-service:${JINA_VERSION}${PY_TAG}${PIP_TAG}, \ | ||
jinaai/clip-as-service:${JINA_MINOR_VERSION}${PY_TAG}${PIP_TAG}, \ | ||
jinaai/clip-as-service:${JINA_MAJOR_VERSION}${PY_TAG}${PIP_TAG}, \ | ||
jinaai/clip-as-service:latest${PIP_TAG}, \ | ||
jinaai/clip-as-service:${JINA_VERSION}${PIP_TAG}, \ | ||
jinaai/clip-as-service:${JINA_MINOR_VERSION}${PIP_TAG}, \ | ||
jinaai/clip-as-service:${JINA_MAJOR_VERSION}${PIP_TAG} \ | ||
" >> $GITHUB_ENV | ||
else | ||
echo "TAG_ALIAS=\ | ||
jinaai/clip-as-service:latest${PY_TAG}${PIP_TAG}, \ | ||
jinaai/clip-as-service:${JINA_VERSION}${PY_TAG}${PIP_TAG}, \ | ||
jinaai/clip-as-service:${JINA_MINOR_VERSION}${PY_TAG}${PIP_TAG}, \ | ||
jinaai/clip-as-service:${JINA_MAJOR_VERSION}${PY_TAG}${PIP_TAG} \ | ||
" >> $GITHUB_ENV | ||
fi | ||
elif [[ "${{ github.event.inputs.triggered_by }}" == "MANUAL" ]]; then | ||
# on every manual release | ||
if [[ "${{ matrix.py_version }}" == "$DEFAULT_PY_VERSION" ]]; then | ||
echo "TAG_ALIAS=\ | ||
jinaai/clip-as-service:${JINA_VERSION}${PIP_TAG}, \ | ||
jinaai/clip-as-service:${JINA_VERSION}${PY_TAG}${PIP_TAG} \ | ||
" >> $GITHUB_ENV | ||
else | ||
echo "TAG_ALIAS=\ | ||
jinaai/clip-as-service:${JINA_VERSION}${PY_TAG}${PIP_TAG} \ | ||
" >> $GITHUB_ENV | ||
fi | ||
else | ||
echo "Bad triggered_by: ${{ github.event.inputs.triggered_by }}!" | ||
exit 1 | ||
fi | ||
echo "JINA_VERSION=${JINA_VERSION}" >> $GITHUB_ENV | ||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v1 | ||
with: | ||
install: true | ||
- name: Login to DockerHub | ||
uses: docker/login-action@v1 | ||
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 | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: Dockerfiles/server.Dockerfile | ||
platforms: linux/amd64 | ||
push: true | ||
tags: ${{env.TAG_ALIAS}} | ||
build-args: | | ||
BUILD_DATE=${{env.BUILD_DATE}} | ||
JINA_VERSION=${{env.JINA_VERSION}} | ||
VCS_REF=${{env.VCS_REF}} | ||
PIP_INSTALL_CORE=${{env.JINA_PIP_INSTALL_CORE}} | ||
PIP_INSTALL_PERF=${{env.JINA_PIP_INSTALL_PERF}} | ||
PIP_TAG=${{matrix.pip_tag}} |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
ARG CUDA_VERSION=11.6.0 | ||
|
||
FROM nvidia/cuda:${CUDA_VERSION}-devel-ubuntu20.04 | ||
|
||
ARG CAS_NAME=cas | ||
WORKDIR /${CAS_NAME} | ||
|
||
ENV PIP_NO_CACHE_DIR=1 \ | ||
PIP_DISABLE_PIP_VERSION_CHECK=1 | ||
|
||
# constant, wont invalidate cache | ||
LABEL org.opencontainers.image.vendor="Jina AI Limited" \ | ||
org.opencontainers.image.licenses="Apache 2.0" \ | ||
org.opencontainers.image.title="CLIP-as-Service" \ | ||
org.opencontainers.image.description="Embed images and sentences into fixed-length vectors with CLIP" \ | ||
org.opencontainers.image.authors="hello@jina.ai" \ | ||
org.opencontainers.image.url="clip-as-service" \ | ||
org.opencontainers.image.documentation="https://clip-as-service.jina.ai/" | ||
|
||
|
||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends python3 python3-pip wget \ | ||
&& ln -sf python3 /usr/bin/python \ | ||
&& ln -sf pip3 /usr/bin/pip \ | ||
&& pip install --upgrade pip \ | ||
&& pip install wheel setuptools nvidia-pyindex \ | ||
&& pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113 | ||
|
||
COPY server ./server | ||
# given by builder | ||
ARG PIP_TAG | ||
RUN pip install --default-timeout=1000 --compile ./server/ \ | ||
&& if [ -n "${PIP_TAG}" ]; then pip install --default-timeout=1000 --compile "./server[${PIP_TAG}]" ; fi | ||
|
||
ENV LD_LIBRARY_PATH=/usr/local/cuda/lib64 | ||
|
||
ARG USER_ID=1000 | ||
ARG GROUP_ID=1000 | ||
ARG USER_NAME=${CAS_NAME} | ||
ARG GROUP_NAME=${CAS_NAME} | ||
|
||
RUN groupadd -g ${GROUP_ID} ${USER_NAME} &&\ | ||
useradd -l -u ${USER_ID} -g ${USER_NAME} ${GROUP_NAME} &&\ | ||
mkdir /home/${USER_NAME} &&\ | ||
chown ${USER_NAME}:${GROUP_NAME} /home/${USER_NAME} &&\ | ||
chown -R ${USER_NAME}:${GROUP_NAME} /${CAS_NAME}/ | ||
|
||
USER ${USER_NAME} | ||
|
||
ENTRYPOINT ["python", "-m", "clip_server"] |
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
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
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
File renamed without changes.
File renamed without changes
File renamed without changes
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
File renamed without changes
Oops, something went wrong.