Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: default download from origin #479

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions scripts/0_prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ IMAGE_DIR="${BASE_DIR}/images"
function download_and_verify() {
local url=$1
local target_path=$2
local md5_url=$3
local md5_target_path="${target_path}.md5"

parent_dir=$(dirname "${target_path}")
Expand All @@ -19,7 +20,12 @@ function download_and_verify() {
prepare_check_required_pkg
if [[ ! -f "${md5_target_path}" ]]; then
echo "$(gettext 'Starting to download'): ${url}.md5"
wget -q "${url}.md5" -O "${md5_target_path}" || {

if [[ -z "${md5_url}" ]]; then
md5_url="${url}.md5"
fi

wget -q "${md5_url}" -O "${md5_target_path}" || {
log_error "$(gettext 'Download fails, check the network is normal')"
rm -f "${md5_target_path}"
exit 1
Expand All @@ -43,11 +49,11 @@ function download_and_verify() {
}

function prepare_docker_bin() {
download_and_verify "${DOCKER_BIN_URL}" "${BASE_DIR}/docker/docker.tar.gz"
download_and_verify "${DOCKER_BIN_URL}" "${BASE_DIR}/docker/docker.tar.gz" "${DOCKER_MD5_URL}"
}

function prepare_compose_bin() {
download_and_verify "${DOCKER_COMPOSE_BIN_URL}" "${BASE_DIR}/docker/docker-compose"
download_and_verify "${COMPOSE_BIN_URL}" "${BASE_DIR}/docker/docker-compose" "${COMPOSE_MD5_URL}"
chown -R root:root "${BASE_DIR}/docker/docker-compose"
chmod +x "${BASE_DIR}/docker/docker-compose"
}
Expand Down
19 changes: 15 additions & 4 deletions scripts/const.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,27 @@ STATIC_ENV=${PROJECT_DIR}/static.env

export OS=$(uname -s)
export DOCKER_VERSION=27.1.1
export DOCKER_MIRROR="https://download.jumpserver.org/docker/docker-ce/linux/static/stable"
DOCKER_URL="https://download.docker.com/linux/static/stable"
DOCKER_MIRROR="https://download.jumpserver.org/docker/docker-ce/linux/static/stable"

if [[ "${USE_MIRROR}" == "1" ]];then
DOCKER_URL=${DOCKER_MIRROR}
fi

export DOCKER_COMPOSE_VERSION=v2.29.1
export DOCKER_COMPOSE_MIRROR="https://download.jumpserver.org/docker/compose/releases/download"
COMPOSE_URL="https://github.com/docker/compose/releases/download"
COMPOSE_MIRROR="https://download.jumpserver.org/docker/compose/releases/download"
if [[ "${USE_MIRROR}" == "1" ]];then
COMPOSE_URL=${COMPOSE_MIRROR}
fi

ARCH=$(uname -m)
if [ -n "${BUILD_ARCH}" ]; then
ARCH=${BUILD_ARCH}
fi

export ARCH
export DOCKER_BIN_URL="${DOCKER_MIRROR}/${ARCH}/docker-${DOCKER_VERSION}.tgz"
export DOCKER_COMPOSE_BIN_URL="${DOCKER_COMPOSE_MIRROR}/${DOCKER_COMPOSE_VERSION}/docker-compose-linux-${ARCH}"
export DOCKER_BIN_URL="${DOCKER_URL}/${ARCH}/docker-${DOCKER_VERSION}.tgz"
export DOCKER_MD5_URL="${DOCKER_MIRROR}/${ARCH}/docker-${DOCKER_VERSION}.tgz.md5"
export COMPOSE_BIN_URL="${COMPOSE_URL}/${DOCKER_COMPOSE_VERSION}/docker-compose-linux-${ARCH}"
export COMPOSE_MD5_URL="${COMPOSE_MIRROR}/${DOCKER_COMPOSE_VERSION}/docker-compose-linux-${ARCH}.md5"