feat(core): Multi-module dependency splitting

This commit is contained in:
FangYin Cheng
2023-09-20 17:31:56 +08:00
parent d31a220c6e
commit 33506b062b
28 changed files with 253 additions and 193 deletions

View File

@@ -4,14 +4,21 @@ SCRIPT_LOCATION=$0
cd "$(dirname "$SCRIPT_LOCATION")"
WORK_DIR=$(pwd)
BASE_IMAGE="nvidia/cuda:11.8.0-runtime-ubuntu22.04"
BASE_IMAGE_DEFAULT="nvidia/cuda:11.8.0-runtime-ubuntu22.04"
BASE_IMAGE_DEFAULT_CPU="ubuntu:22.04"
BASE_IMAGE=$BASE_IMAGE_DEFAULT
IMAGE_NAME="eosphorosai/dbgpt"
IMAGE_NAME_ARGS=""
# zh: https://pypi.tuna.tsinghua.edu.cn/simple
PIP_INDEX_URL="https://pypi.org/simple"
# en or zh
LANGUAGE="en"
BUILD_LOCAL_CODE="false"
LOAD_EXAMPLES="true"
BUILD_NETWORK=""
DB_GPT_INSTALL_MODEL="default"
usage () {
echo "USAGE: $0 [--base-image nvidia/cuda:11.8.0-runtime-ubuntu22.04] [--image-name db-gpt]"
@@ -21,6 +28,8 @@ usage () {
echo " [--language en or zh] You language, default: en"
echo " [--build-local-code true or false] Whether to use the local project code to package the image, default: false"
echo " [--load-examples true or false] Whether to load examples to default database default: true"
echo " [--network network name] The network of docker build"
echo " [--install-mode mode name] Installation mode name, default: default, If you completely use openai's service, you can set the mode name to 'openai'"
echo " [-h|--help] Usage message"
}
@@ -33,7 +42,7 @@ while [[ $# -gt 0 ]]; do
shift # past value
;;
-n|--image-name)
IMAGE_NAME="$2"
IMAGE_NAME_ARGS="$2"
shift # past argument
shift # past value
;;
@@ -57,6 +66,20 @@ while [[ $# -gt 0 ]]; do
shift
shift
;;
--network)
BUILD_NETWORK=" --network $2 "
shift # past argument
shift # past value
;;
-h|--help)
help="true"
shift
;;
--install-mode)
DB_GPT_INSTALL_MODEL="$2"
shift # past argument
shift # past value
;;
-h|--help)
help="true"
shift
@@ -73,11 +96,29 @@ if [[ $help ]]; then
exit 0
fi
docker build \
if [ "$DB_GPT_INSTALL_MODEL" != "default" ]; then
IMAGE_NAME="$IMAGE_NAME-$DB_GPT_INSTALL_MODEL"
echo "install mode is not 'default', set image name to: ${IMAGE_NAME}"
fi
if [ -z "$IMAGE_NAME_ARGS" ]; then
if [ "$DB_GPT_INSTALL_MODEL" == "openai" ]; then
# Use cpu image
BASE_IMAGE=$BASE_IMAGE_DEFAULT_CPU
fi
else
# User input image is not empty
BASE_IMAGE=$IMAGE_NAME_ARGS
fi
echo "Begin build docker image, base image: ${BASE_IMAGE}, target image name: ${IMAGE_NAME}"
docker build $BUILD_NETWORK \
--build-arg BASE_IMAGE=$BASE_IMAGE \
--build-arg PIP_INDEX_URL=$PIP_INDEX_URL \
--build-arg LANGUAGE=$LANGUAGE \
--build-arg BUILD_LOCAL_CODE=$BUILD_LOCAL_CODE \
--build-arg LOAD_EXAMPLES=$LOAD_EXAMPLES \
--build-arg DB_GPT_INSTALL_MODEL=$DB_GPT_INSTALL_MODEL \
-f Dockerfile \
-t $IMAGE_NAME $WORK_DIR/../../