!29 update docker feature

Merge pull request !29 from lihongda/master
This commit is contained in:
opengauss-bot 2020-07-27 10:52:58 +08:00 committed by Gitee
commit 0c06c55ea6
6 changed files with 194 additions and 36 deletions

View File

@ -1,34 +1,5 @@
# Architecture And Os Version
# openGauss on Docker
Sample Docker build files to facilitate installation, configuration, and environment setup for DevOps users. For more information about openGasuss please see the [openGauss Online Documentation](https://opengauss.org/zh/docs/1.0.0/docs/Quickstart/Quickstart.html).
x86-64 CentOS7.6
ARM64 openEuler 20.03 LTS
# Build Image
```console
docker build -t opengauss:1.0 .
```
# Start Instance
```console
$ docker run --name opengauss --privileged=true -d -e GS_PASSWORD=secretpassword@123 opengauss:1.0
```
# Connect To The Container Database From Os
```console
$ docker run name opengauss privileged=true d e GSPASSWORD=secretpassword@123 \
p8888:5432 opengauss:1.0 gsql -d postgres -U gaussdb -W'secretpassword@123' \
-h your-host-ip -p8888
```
# Persist Data
```console
$ docker run --name opengauss --privileged=true -d -e GS_PASSWORD=secretpassword@123 \
-v /opengauss:/var/lib/opengauss opengauss:1.0
```
# Todo
primary standby install
## SingleInstance
Provides Docker build files to create an openGasuss Single Instance Docker image. For more details, see [SingleInstance/README.md](./SingleInstance/README.md).

View File

@ -0,0 +1,8 @@
# About Opengauss
openGauss is an open source relational database management system that is released with the Mulan PSL v2. with the kernel derived from PostgreSQL, openGauss is built on Huawei's years of experience in the database field and continuously provides competitive features tailored to enterprise-class scenarios. In addition, openGauss is an open source database platform that encourages community contribution and collaboration.
# How To Run Opengauss On Docker
You may read the English installation guide [openGauss-in-Docker-container-installation-guide.md](https://gitee.com/lee1002/docs/blob/master/content/en/docs/installation/openGauss-in-Docker-container-installation-guide.md
), and [中文安装指南](https://gitee.com/lee1002/docs/blob/master/content/zh/docs/installation/openGauss容器版本安装指南.md) for details.

View File

@ -0,0 +1 @@
369bbc8229d0526b8df454f76d244397 openGauss-1.0.0-CentOS-64bit.tar.bz2

View File

@ -35,10 +35,10 @@ RUN mkdir /docker-entrypoint-initdb.d
ENV PGDATA /var/lib/opengauss/data
COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh;ln -s /usr/local/bin/docker-entrypoint.sh / # backwards compat
COPY entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/entrypoint.sh;ln -s /usr/local/bin/entrypoint.sh / # backwards compat
ENTRYPOINT ["docker-entrypoint.sh"]
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 5432
CMD ["gaussdb"]

View File

@ -0,0 +1,178 @@
#!/bin/bash -e
usage() {
cat << EOF
Usage: buildDockerImage.sh -v [version] [-i] [Docker build option]
Builds a Docker Image for openGauss
Parameters:
-v: version to build
Choose one of: $(for i in $(ls -d */); do echo -n "${i%%/} "; done)
-i: ignores the MD5 checksums
LICENSE UPL 1.0
EOF
}
# Validate packages
checksumPackages() {
if hash md5sum 2>/dev/null; then
echo "Checking if required packages are present and valid..."
if ! md5sum -c "Checksum"; then
echo "MD5 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 MD5 sum, 'md5sum' command not available.";
fi
}
# Check Docker version
checkDockerVersion() {
# 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=${DOCKER_VERSION//./}
if [ -z "$DOCKER_VERSION" ]; then
# docker could be aliased to podman and errored out (https://github.com/containers/libpod/pull/4608)
checkPodmanVersion
elif [ "$DOCKER_VERSION" -lt "${MIN_DOCKER_VERSION//./}" ]; then
echo "Docker version is below the minimum required version $MIN_DOCKER_VERSION"
echo "Please upgrade your Docker installation to proceed."
exit 1;
fi;
}
##############
#### MAIN ####
##############
# Parameters
VERSION="1.0.0"
SKIPMD5=0
DOCKEROPS=""
MIN_DOCKER_VERSION="17.09"
DOCKERFILE="Dockerfile"
if [ "$#" -eq 0 ]; then
usage;
exit 1;
fi
while getopts "hesxiv:o:" optname; do
case "$optname" in
"h")
usage
exit 0;
;;
"i")
SKIPMD5=1
;;
"v")
VERSION="$OPTARG"
;;
"o")
DOCKEROPS="$OPTARG"
;;
"?")
usage;
exit 1;
;;
*)
# Should not occur
echo "Unknown error while processing options inside buildDockerImage.sh"
;;
esac
done
checkDockerVersion
# Which Dockerfile should be used?
if [ "$VERSION" == "12.1.0.2" ] || [ "$VERSION" == "11.2.0.2" ] || [ "$VERSION" == "18.4.0" ]; then
DOCKERFILE="$DOCKERFILE"
fi;
# Oracle Database Image Name
IMAGE_NAME="opengauss:$VERSION"
# Go into version folder
cd "$VERSION" || {
echo "Could not find version directory '$VERSION'";
exit 1;
}
if [ ! "$SKIPMD5" -eq 1 ]; then
checksumPackages
else
echo "Ignored MD5 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: Oracle 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