From b5f2758dc0765091c535181889a56138a6e7ec5a Mon Sep 17 00:00:00 2001 From: FangYin Cheng Date: Fri, 18 Aug 2023 17:42:16 +0800 Subject: [PATCH] fix: modify docker image CICD fix: Fix error CICD config fix: Fix docker image error fix: Reduce docker image size fix: remove other architecture fix: remove llama.cpp dependencies from base image --- .github/workflows/docker-image-publish.yml | 35 ++++++++++++++++++++ .github/workflows/python-publish.yml | 25 +------------- docker/base/Dockerfile | 38 +++++++++------------- 3 files changed, 51 insertions(+), 47 deletions(-) create mode 100644 .github/workflows/docker-image-publish.yml diff --git a/.github/workflows/docker-image-publish.yml b/.github/workflows/docker-image-publish.yml new file mode 100644 index 000000000..bbc37b57d --- /dev/null +++ b/.github/workflows/docker-image-publish.yml @@ -0,0 +1,35 @@ + +name: Push docker image + +on: + release: + types: [published] + workflow_dispatch: + +permissions: + contents: read + +jobs: + build-image: + runs-on: ubuntu-latest + # run unless event type is pull_request + if: github.event_name != 'pull_request' + steps: + - uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + file: ./docker/base/Dockerfile + platforms: linux/amd64 + push: true + tags: eosphorosai/dbgpt:${{ github.ref_name }} \ No newline at end of file diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 304749dfb..9d5e52d7b 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -35,27 +35,4 @@ jobs: uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 with: user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }} - build-image: - runs-on: ubuntu-latest - needs: deploy - # run unless event type is pull_request - if: github.event_name != 'pull_request' - steps: - - uses: actions/checkout@v3 - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push - uses: docker/build-push-action@v4 - with: - context: . - platforms: linux/amd64,linux/arm64 - push: true - tags: eosphorosai/dbgpt:${{ github.ref_name }} + password: ${{ secrets.PYPI_API_TOKEN }} \ No newline at end of file diff --git a/docker/base/Dockerfile b/docker/base/Dockerfile index 3cb063e47..e273b8bd9 100644 --- a/docker/base/Dockerfile +++ b/docker/base/Dockerfile @@ -1,4 +1,4 @@ -ARG BASE_IMAGE="nvidia/cuda:11.8.0-devel-ubuntu22.04" +ARG BASE_IMAGE="nvidia/cuda:11.8.0-runtime-ubuntu22.04" FROM ${BASE_IMAGE} ARG BASE_IMAGE @@ -11,16 +11,6 @@ ARG LANGUAGE="en" ARG PIP_INDEX_URL="https://pypi.org/simple" ENV PIP_INDEX_URL=$PIP_INDEX_URL -RUN pip3 install --upgrade pip -i $PIP_INDEX_URL \ - && (if [ "${LANGUAGE}" = "zh" ]; \ - # language is zh, download zh_core_web_sm from github - then wget https://github.com/explosion/spacy-models/releases/download/zh_core_web_sm-3.5.0/zh_core_web_sm-3.5.0-py3-none-any.whl -O /tmp/zh_core_web_sm-3.5.0-py3-none-any.whl \ - && pip3 install /tmp/zh_core_web_sm-3.5.0-py3-none-any.whl -i $PIP_INDEX_URL \ - && rm /tmp/zh_core_web_sm-3.5.0-py3-none-any.whl; \ - # not zh, download directly - else python3 -m spacy download zh_core_web_sm; \ - fi;) - RUN mkdir -p /app # COPY only requirements.txt first to leverage Docker cache @@ -30,20 +20,22 @@ COPY ./README.md /app/README.md WORKDIR /app -# RUN pip3 install --upgrade pip -i $PIP_INDEX_URL \ -# && (if [ "${BUILD_LOCAL_CODE}" = "false" ]; \ -# # if not build local code, clone latest code from git, and rename to /app, TODO: download by version, like: https://github.com/eosphoros-ai/DB-GPT/archive/refs/tags/$DBGPT_VERSION.zip -# then git clone https://github.com/eosphoros-ai/DB-GPT.git /app \ -# && cp /app/requirements.txt /tmp/requirements.txt; \ -# fi;) \ -# && pip3 install -r /tmp/requirements.txt -i $PIP_INDEX_URL --no-cache-dir \ -# && rm /tmp/requirements.txt - -RUN pip3 install -i $PIP_INDEX_URL . - # ENV CMAKE_ARGS="-DLLAMA_CUBLAS=ON -DLLAMA_AVX2=OFF -DLLAMA_F16C=OFF -DLLAMA_FMA=OFF" # ENV FORCE_CMAKE=1 -RUN pip3 install -i $PIP_INDEX_URL .[llama_cpp] \ +# Install all +# RUN pip3 install -i $PIP_INDEX_URL ".[all]" + +RUN pip3 install --upgrade pip -i $PIP_INDEX_URL \ + && pip3 install -i $PIP_INDEX_URL . \ + # && pip3 install -i $PIP_INDEX_URL ".[llama_cpp]" \ + && (if [ "${LANGUAGE}" = "zh" ]; \ + # language is zh, download zh_core_web_sm from github + then wget https://github.com/explosion/spacy-models/releases/download/zh_core_web_sm-3.5.0/zh_core_web_sm-3.5.0-py3-none-any.whl -O /tmp/zh_core_web_sm-3.5.0-py3-none-any.whl \ + && pip3 install /tmp/zh_core_web_sm-3.5.0-py3-none-any.whl -i $PIP_INDEX_URL \ + && rm /tmp/zh_core_web_sm-3.5.0-py3-none-any.whl; \ + # not zh, download directly + else python3 -m spacy download zh_core_web_sm; \ + fi;) \ && rm -rf `pip3 cache dir` ARG BUILD_LOCAL_CODE="false"