2020-11-13 12:27:41 +08:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2024-02-01 11:49:03 +08:00
|
|
|
set -eo pipefail
|
2020-11-13 12:27:41 +08:00
|
|
|
|
2024-08-02 19:32:32 +08:00
|
|
|
source ./build/util.sh
|
|
|
|
|
2021-06-10 17:33:49 +08:00
|
|
|
# Absolute path to the toplevel milvus directory.
|
2020-11-13 12:27:41 +08:00
|
|
|
toplevel=$(dirname "$(cd "$(dirname "${0}")"; pwd)")
|
|
|
|
|
2024-02-01 11:49:03 +08:00
|
|
|
if [[ "$IS_NETWORK_MODE_HOST" == "true" ]]; then
|
|
|
|
sed -i '/builder:/,/^\s*$/s/image: \${IMAGE_REPO}\/milvus-env:\${OS_NAME}-\${DATE_VERSION}/&\n network_mode: "host"/' $toplevel/docker-compose.yml
|
|
|
|
fi
|
|
|
|
|
2023-08-18 18:32:19 +08:00
|
|
|
if [[ -f "$toplevel/.env" ]]; then
|
2023-12-25 10:28:47 +08:00
|
|
|
set -a # automatically export all variables from .env
|
|
|
|
source $toplevel/.env
|
|
|
|
set +a # stop automatically exporting
|
2023-08-18 18:32:19 +08:00
|
|
|
fi
|
|
|
|
|
2020-11-13 12:27:41 +08:00
|
|
|
pushd "${toplevel}"
|
|
|
|
|
2021-04-29 11:28:27 +08:00
|
|
|
if [[ "${1-}" == "pull" ]]; then
|
2024-08-02 19:32:32 +08:00
|
|
|
$DOCKER_COMPOSE_COMMAND pull builder
|
2020-11-13 12:27:41 +08:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2021-04-29 11:28:27 +08:00
|
|
|
if [[ "${1-}" == "down" ]]; then
|
2024-08-02 19:32:32 +08:00
|
|
|
$DOCKER_COMPOSE_COMMAND down
|
2020-11-18 16:38:28 +08:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2023-08-29 19:10:28 +08:00
|
|
|
PLATFORM_ARCH="${PLATFORM_ARCH:-${IMAGE_ARCH}}"
|
|
|
|
|
|
|
|
export IMAGE_ARCH=${PLATFORM_ARCH}
|
|
|
|
|
2023-08-18 18:32:19 +08:00
|
|
|
mkdir -p "${DOCKER_VOLUME_DIRECTORY:-.docker}/${IMAGE_ARCH}-${OS_NAME}-ccache"
|
|
|
|
mkdir -p "${DOCKER_VOLUME_DIRECTORY:-.docker}/${IMAGE_ARCH}-${OS_NAME}-go-mod"
|
|
|
|
mkdir -p "${DOCKER_VOLUME_DIRECTORY:-.docker}/${IMAGE_ARCH}-${OS_NAME}-vscode-extensions"
|
|
|
|
mkdir -p "${DOCKER_VOLUME_DIRECTORY:-.docker}/${IMAGE_ARCH}-${OS_NAME}-conan"
|
2020-11-13 12:27:41 +08:00
|
|
|
chmod -R 777 "${DOCKER_VOLUME_DIRECTORY:-.docker}"
|
|
|
|
|
2024-08-02 19:32:32 +08:00
|
|
|
$DOCKER_COMPOSE_COMMAND pull builder
|
2023-08-21 09:54:20 +08:00
|
|
|
if [[ "${CHECK_BUILDER:-}" == "1" ]]; then
|
2024-08-02 19:32:32 +08:00
|
|
|
$DOCKER_COMPOSE_COMMAND build builder
|
2020-11-17 18:36:03 +08:00
|
|
|
fi
|
2021-04-29 11:28:27 +08:00
|
|
|
|
2024-08-02 19:32:32 +08:00
|
|
|
$DOCKER_COMPOSE_COMMAND run --no-deps --rm builder "$@"
|
2020-11-13 12:27:41 +08:00
|
|
|
|
|
|
|
popd
|