diff options
Diffstat (limited to 'redhat/docker/build.sh')
-rwxr-xr-x | redhat/docker/build.sh | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/redhat/docker/build.sh b/redhat/docker/build.sh index 9aeb60f5a..af06b3a6e 100755 --- a/redhat/docker/build.sh +++ b/redhat/docker/build.sh @@ -8,6 +8,18 @@ ARCH="$3" [ -z "${ARCH}" ] && ARCH="x86_64" IMAGE="trinity.${DISTRIB}.${ARCH}:${TDE_VERSION}" +FILE="${HOME}/tde/docker/${IMAGE}.tar.gz" #docker rmi -f "${IMAGE}" -docker build -t "${IMAGE}" -f "${DISTRIB}/Dockerfile.${ARCH}" --build-arg TDE_VERSION="${TDE_VERSION}" --build-arg ARCH="${ARCH}" "${DISTRIB}" + +if [ $(docker images -q "${IMAGE}") ]; then + echo "Docker image '${IMAGE}' already exists." +elif [ -r "${FILE}" ]; then + echo "Importing existing docker image '${FILE}'." + zcat "${FILE}" | docker import - "${IMAGE}" +else + echo "Building new Docker image '${IMAGE}'." + docker build -t "${IMAGE}" -f "${DISTRIB}/Dockerfile.${ARCH}" --build-arg TDE_VERSION="${TDE_VERSION}" --build-arg ARCH="${ARCH}" "${DISTRIB}" + echo "Saving image to '${FILE}'" + docker save "${IMAGE}" | pigz >"${FILE}" +fi |