代码拉取完成,页面将自动刷新
同步操作将从 openGauss/openGauss-container 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/bin/bash
# Build docker image
# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved.
#
#openGauss is licensed under Mulan PSL v2.
#You can use this software according to the terms and conditions of the Mulan PSL v2.
#You may obtain a copy of Mulan PSL v2 at:
#
# http://license.coscl.org.cn/MulanPSL2
#
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.
#-------------------------------------------------------------------------
#
# buildDockerImage.sh
# Build docker image
#
# IDENTIFICATION
# openGauss-container/buildDockerImage.sh
#
#-------------------------------------------------------------------------
usage() {
cat << EOF
Usage: buildDockerImage.sh -v [version] [-i] [Docker build option]
Builds a Docker Image for openGauss
Parameters:
-v: version to build
-i: ignores the SHA256 checksums
LICENSE MulanPSL2
EOF
}
# Validate packages
checksum_packages() {
if [ "${arch}" = "amd64" ]; then
sha256_file="sha256_file_amd64"
else
sha256_file="sha256_file_arm64"
fi
if hash sha256sum 2>/dev/null; then
echo "Checking if required packages are present and valid..."
if ! sha256sum -c "$sha256_file"; then
echo "SHA256 for required packages to build this image did not match!"
echo "Make sure to download missing files in folder $VERSION."
exit 1;
fi
else
echo "Ignored SHA256 sum, 'sha256sum' command not available.";
fi
}
# Check Docker version
check_docker_version() {
# Get Docker Server version
echo "Checking Docker version."
DOCKER_VERSION=$(docker version --format '{{.Server.Version | printf "%.5s" }}'|| exit 0)
# Remove dot in Docker version
docker_version_major=$(echo $DOCKER_VERSION | awk -F . '{print $1}')
if [ -z "$DOCKER_VERSION" ]; then
# docker could be aliased to podman and errored out (https://github.com/containers/libpod/pull/4608)
echo "Please check if docker is installed." && exit 1
elif [ "$docker_version_major" -lt "${MIN_DOCKER_VERSION_MAJOR}" ]; then
echo "Docker version is below the minimum required version $MIN_DOCKER_VERSION_MAJOR.$MIN_DOCKER_VERSION_MINOR"
echo "Please upgrade your Docker installation to proceed."
exit 1;
fi
}
##############
#### MAIN ####
##############
# Parameters
VERSION="3.0.0"
SKIPCHECKSUM=0
DOCKEROPS=""
MIN_DOCKER_VERSION_MAJOR="17"
MIN_DOCKER_VERSION_MINOR="09"
arch=$(case $(uname -m) in i386) echo "386" ;; i686) echo "386" ;; x86_64) echo "amd64";; aarch64)echo "arm64";; esac)
if [ "${arch}" = "amd64" ]; then
DOCKERFILE="dockerfile_amd"
else
DOCKERFILE="dockerfile_arm"
fi
if [ "$#" -eq 0 ]; then
usage;
exit 1;
fi
while getopts "hesxiv:o:" optname; do
case "$optname" in
"h")
usage
exit 0;
;;
"i")
SKIPCHECKSUM=1
;;
"v")
VERSION="$OPTARG"
;;
"o")
DOCKEROPS="$OPTARG"
;;
"?")
usage;
exit 1;
;;
*)
# Should not occur
echo "Unknown error while processing options inside buildDockerImage.sh"
;;
esac
done
check_docker_version
# openGauss Database Image Name
IMAGE_NAME="opengauss:$VERSION"
# check package exist
if [ "`ls dockerfiles/ |grep openGauss-All-${VERSION}`" == "" ]; then
echo "Could not find openGauss $VERSION package.";
exit 1;
fi
cd dockerfiles/
if [ ! "$SKIPCHECKSUM" -eq 1 ]; then
checksum_packages
else
echo "Ignored SHA256 checksum."
fi
echo "=========================="
echo "DOCKER info:"
docker info
echo "=========================="
# Proxy settings
PROXY_SETTINGS=""
if [ "${http_proxy}" != "" ]; then
PROXY_SETTINGS="$PROXY_SETTINGS --build-arg http_proxy=${http_proxy}"
fi
if [ "${https_proxy}" != "" ]; then
PROXY_SETTINGS="$PROXY_SETTINGS --build-arg https_proxy=${https_proxy}"
fi
if [ "${ftp_proxy}" != "" ]; then
PROXY_SETTINGS="$PROXY_SETTINGS --build-arg ftp_proxy=${ftp_proxy}"
fi
if [ "${no_proxy}" != "" ]; then
PROXY_SETTINGS="$PROXY_SETTINGS --build-arg no_proxy=${no_proxy}"
fi
if [ "$PROXY_SETTINGS" != "" ]; then
echo "Proxy settings were found and will be used during the build."
fi
# ################## #
# BUILDING THE IMAGE #
# ################## #
echo "Building image '$IMAGE_NAME' ..."
# BUILD THE IMAGE (replace all environment variables)
BUILD_START=$(date '+%s')
docker build --force-rm=true --no-cache=true \
$DOCKEROPS $PROXY_SETTINGS \
-t $IMAGE_NAME -f $DOCKERFILE . || {
echo ""
echo "ERROR: openGauss Database Docker Image was NOT successfully created."
echo "ERROR: Check the output and correct any reported problems with the docker build operation."
exit 1
}
# Remove dangling images (intermitten images with tag <none>)
yes | docker image prune > /dev/null
BUILD_END=$(date '+%s')
BUILD_ELAPSED=$(expr $BUILD_END - $BUILD_START)
echo ""
echo ""
cat << EOF
openGauss Docker Image $VERSION is ready to be extended:
--> $IMAGE_NAME
Build completed in $BUILD_ELAPSED seconds.
EOF
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。