From 98e1809d3382ffaa2553f1d5e6b0283d1004b89f Mon Sep 17 00:00:00 2001
From: Piotr Balcer <piotr.balcer@intel.com>
Date: Tue, 13 Oct 2020 12:02:46 +0200
Subject: [PATCH] Revert "common: migrate from Docker Hub to GitHub Container
 Registry"

---
 .github/workflows/coverity.yml        | 25 ++++++++++++-------------
 .github/workflows/gha.yml             |  8 ++++----
 .travis.yml                           |  2 +-
 utils/docker/README                   |  4 ++--
 utils/docker/build-CI.sh              |  2 +-
 utils/docker/build-local.sh           |  4 ++--
 utils/docker/images/build-image.sh    |  8 ++++----
 utils/docker/images/push-image.sh     | 24 ++++++++++++------------
 utils/docker/pull-or-rebuild-image.sh | 21 ++++++++-------------
 9 files changed, 46 insertions(+), 52 deletions(-)

diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml
index ca85df500..f69783b93 100644
--- a/.github/workflows/coverity.yml
+++ b/.github/workflows/coverity.yml
@@ -7,24 +7,23 @@ on:
     - cron:  '0 0 * * *'
 
 env:
-  GITHUB_REPO: pmem/pmdk
-  DOCKER_REPO: ghcr.io/pmem/pmdk
-  GH_CR_USER:  ${{ secrets.GH_CR_USER }}
-  GH_CR_PAT:   ${{ secrets.GH_CR_PAT }}
-  COVERITY_SCAN_NOTIFICATION_EMAIL:  ${{ secrets.COVERITY_SCAN_NOTIFICATION_EMAIL }}
-  COVERITY_SCAN_TOKEN:               ${{ secrets.COVERITY_SCAN_TOKEN }}
-  HOST_WORKDIR:   /home/runner/work/pmdk/pmdk
-  WORKDIR:        utils/docker
-  PMDK_CC:        gcc
-  PMDK_CXX:       g++
-  MAKE_PKG:       0
-  REMOTE_TESTS:   1
-  VALGRIND:       1
+  GITHUB_REPO:    pmem/pmdk
+  DOCKERHUB_REPO: pmem/pmdk
 
 jobs:
   linux:
     name: Linux
     runs-on: ubuntu-latest
+    env:
+      COVERITY_SCAN_NOTIFICATION_EMAIL:  ${{ secrets.COVERITY_SCAN_NOTIFICATION_EMAIL }}
+      COVERITY_SCAN_TOKEN:               ${{ secrets.COVERITY_SCAN_TOKEN }}
+      HOST_WORKDIR:   /home/runner/work/pmdk/pmdk
+      WORKDIR:        utils/docker
+      PMDK_CC:        gcc
+      PMDK_CXX:       g++
+      MAKE_PKG:       0
+      REMOTE_TESTS:   1
+      VALGRIND:       1
     strategy:
       matrix:
         CONFIG: ["COVERITY=1 OS=ubuntu OS_VER=19.10"]
diff --git a/.github/workflows/gha.yml b/.github/workflows/gha.yml
index e8861597e..402d4f878 100644
--- a/.github/workflows/gha.yml
+++ b/.github/workflows/gha.yml
@@ -3,16 +3,16 @@ name: PMDK
 on: [push, pull_request]
 
 env:
-    GITHUB_REPO: pmem/pmdk
-    DOCKER_REPO: ghcr.io/pmem/pmdk
-    GH_CR_USER:  ${{ secrets.GH_CR_USER }}
-    GH_CR_PAT:   ${{ secrets.GH_CR_PAT }}
+    GITHUB_REPO:    pmem/pmdk
+    DOCKERHUB_REPO: pmem/pmdk
 
 jobs:
   linux:
     name: Linux
     runs-on: ubuntu-latest
     env:
+      DOCKERHUB_USER:          ${{ secrets.DOCKERHUB_USER }}
+      DOCKERHUB_PASSWORD:      ${{ secrets.DOCKERHUB_PASSWORD }}
       DOC_UPDATE_GITHUB_TOKEN: ${{ secrets.DOC_UPDATE_GITHUB_TOKEN }}
       HOST_WORKDIR:   /home/runner/work/pmdk/pmdk
       WORKDIR:        utils/docker
diff --git a/.travis.yml b/.travis.yml
index d1af3b155..caa2313e2 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -11,7 +11,7 @@ services:
 env:
   global:
     - GITHUB_REPO=pmem/pmdk
-    - DOCKER_REPO=ghcr.io/pmem/pmdk
+    - DOCKERHUB_REPO=pmem/pmdk
     - OS=ubuntu
     - OS_VER=19.10
     - MAKE_PKG=0
diff --git a/utils/docker/README b/utils/docker/README
index 57c3a7d3e..b4a271359 100644
--- a/utils/docker/README
+++ b/utils/docker/README
@@ -15,5 +15,5 @@ subdirectory and then do git-rebase before pushing your commits to the
 repository, make sure that you do not squash the commit which is the head in
 your repository. This will let Travis and GitHub Actions CIs recreate
 Docker images used during the build before the build. Otherwise the not-updated
-Docker image will be pulled from GitHub Container Registry and used during
-the build on Travis and GitHub Actions CIs.
+Docker image will be pulled from the Docker Hub and used during the build on
+Travis and GitHub Actions CIs.
diff --git a/utils/docker/build-CI.sh b/utils/docker/build-CI.sh
index f0b2c56d2..1b75d3b94 100755
--- a/utils/docker/build-CI.sh
+++ b/utils/docker/build-CI.sh
@@ -45,7 +45,7 @@ if [[ -z "$TEST_BUILD" ]]; then
 	TEST_BUILD=all
 fi
 
-imageName=${DOCKER_REPO}:1.10-${OS}-${OS_VER}-${CI_CPU_ARCH}
+imageName=${DOCKERHUB_REPO}:1.10-${OS}-${OS_VER}-${CI_CPU_ARCH}
 containerName=pmdk-${OS}-${OS_VER}
 
 if [[ $MAKE_PKG -eq 0 ]] ; then command="./run-build.sh"; fi
diff --git a/utils/docker/build-local.sh b/utils/docker/build-local.sh
index fea48b014..0fa5b2107 100755
--- a/utils/docker/build-local.sh
+++ b/utils/docker/build-local.sh
@@ -34,7 +34,7 @@ export PMDK_CC=${PMDK_CC:-gcc}
 export PMDK_CXX=${PMDK_CXX:-g++}
 export EXPERIMENTAL=${EXPERIMENTAL:-n}
 export VALGRIND=${VALGRIND:-1}
-export DOCKER_REPO=${DOCKER_REPO:-ghcr.io/pmem/pmdk}
+export DOCKERHUB_REPO=${DOCKERHUB_REPO:-pmem/pmdk}
 export GITHUB_REPO=${GITHUB_REPO:-pmem/pmdk}
 
 if [[ -z "$OS" || -z "$OS_VER" ]]; then
@@ -51,7 +51,7 @@ if [[ "$KEEP_CONTAINER" != "1" ]]; then
 	RM_SETTING=" --rm"
 fi
 
-imageName=${DOCKER_REPO}:1.10-${OS}-${OS_VER}-${CI_CPU_ARCH}
+imageName=${DOCKERHUB_REPO}:1.10-${OS}-${OS_VER}-${CI_CPU_ARCH}
 containerName=pmdk-${OS}-${OS_VER}
 
 if [[ $MAKE_PKG -eq 1 ]] ; then
diff --git a/utils/docker/images/build-image.sh b/utils/docker/images/build-image.sh
index 5805d8f45..b9e7a2a4b 100755
--- a/utils/docker/images/build-image.sh
+++ b/utils/docker/images/build-image.sh
@@ -40,13 +40,13 @@ if [[ ! -f "Dockerfile.$OS_VER" ]]; then
 	exit 1
 fi
 
-if [[ -z "${DOCKER_REPO}" ]]; then
-	echo "Error: DOCKER_REPO environment variable is not set"
+if [[ -z "${DOCKERHUB_REPO}" ]]; then
+	echo "Error: DOCKERHUB_REPO environment variable is not set"
 	exit 1
 fi
 
-# Build a Docker image tagged with ${DOCKER_REPO}:OS-VER-ARCH
-tag=${DOCKER_REPO}:1.10-${OS_VER}-${CPU_ARCH}
+# Build a Docker image tagged with ${DOCKERHUB_REPO}:OS-VER-ARCH
+tag=${DOCKERHUB_REPO}:1.10-${OS_VER}-${CPU_ARCH}
 docker build -t $tag \
 	--build-arg http_proxy=$http_proxy \
 	--build-arg https_proxy=$https_proxy \
diff --git a/utils/docker/images/push-image.sh b/utils/docker/images/push-image.sh
index a7bd4cc7c..03b935213 100755
--- a/utils/docker/images/push-image.sh
+++ b/utils/docker/images/push-image.sh
@@ -3,11 +3,11 @@
 # Copyright 2016-2020, Intel Corporation
 
 #
-# push-image.sh - pushes the Docker image to GitHub Container Registry.
+# push-image.sh - pushes the Docker image to the Docker Hub.
 #
-# The script utilizes $GH_CR_USER and $GH_CR_PAT variables
-# to log in to GitHub Container Registry. The variables can be set
-# in the Travis project's configuration for automated builds.
+# The script utilizes $DOCKERHUB_USER and $DOCKERHUB_PASSWORD variables
+# to log in to Docker Hub. The variables can be set in the Travis project's
+# configuration for automated builds.
 #
 
 set -e
@@ -29,23 +29,23 @@ if [[ -z "$CI_CPU_ARCH" ]]; then
 	exit 1
 fi
 
-if [[ -z "${DOCKER_REPO}" ]]; then
-	echo "DOCKER_REPO environment variable is not set"
+if [[ -z "${DOCKERHUB_REPO}" ]]; then
+	echo "DOCKERHUB_REPO environment variable is not set"
 	exit 1
 fi
 
 TAG="1.10-${OS}-${OS_VER}-${CI_CPU_ARCH}"
 
 # Check if the image tagged with pmdk/OS-VER exists locally
-if [[ ! $(docker images -a | awk -v pattern="^${DOCKER_REPO}:${TAG}\$" \
+if [[ ! $(docker images -a | awk -v pattern="^${DOCKERHUB_REPO}:${TAG}\$" \
 	'$1":"$2 ~ pattern') ]]
 then
-	echo "ERROR: Docker image tagged ${DOCKER_REPO}:${TAG} does not exists locally."
+	echo "ERROR: Docker image tagged ${DOCKERHUB_REPO}:${TAG} does not exists locally."
 	exit 1
 fi
 
-# Log in to GitHub Container Registry
-docker login https://ghcr.io -u="$GH_CR_USER" -p="$GH_CR_PAT"
+# Log in to the Docker Hub
+docker login -u="$DOCKERHUB_USER" -p="$DOCKERHUB_PASSWORD"
 
-# Push the image to GitHub Container Registry
-docker push ${DOCKER_REPO}:${TAG}
+# Push the image to the repository
+docker push ${DOCKERHUB_REPO}:${TAG}
diff --git a/utils/docker/pull-or-rebuild-image.sh b/utils/docker/pull-or-rebuild-image.sh
index 8ce16ae4b..a3a23cdd1 100755
--- a/utils/docker/pull-or-rebuild-image.sh
+++ b/utils/docker/pull-or-rebuild-image.sh
@@ -12,11 +12,11 @@
 #
 # If the Travis build is not of the "pull_request" type (i.e. in case of
 # merge after pull_request) and it succeed, the Docker image should be pushed
-# to GitHub Container Registry repository. An empty file is created to signal
-# that to further scripts.
+# to the Docker Hub repository. An empty file is created to signal that to
+# further scripts.
 #
 # If the Docker image does not have to be rebuilt, it will be pulled from
-# GitHub Container Registry.
+# Docker Hub.
 #
 
 set -e
@@ -82,7 +82,7 @@ for file in $files; do
 		./build-image.sh ${OS}-${OS_VER} ${CI_CPU_ARCH}
 		popd
 
-		# Check if the image has to be pushed to GitHub Container Registry
+		# Check if the image has to be pushed to Docker Hub
 		# (i.e. the build is triggered by commits to the $GITHUB_REPO
 		# repository's stable-* or master branch, and the Travis build is not
 		# of the "pull_request" type). In that case, create the empty
@@ -92,10 +92,10 @@ for file in $files; do
 			&& $CI_EVENT_TYPE != "pull_request" \
 			&& $PUSH_IMAGE == "1" ]]
 		then
-			echo "The image will be pushed to GitHub Container Registry"
+			echo "The image will be pushed to Docker Hub"
 			touch $CI_FILE_PUSH_IMAGE_TO_REPO
 		else
-			echo "Skip pushing the image to GitHub Container Registry"
+			echo "Skip pushing the image to Docker Hub"
 		fi
 
 		if [[ $PUSH_IMAGE == "1" ]]
@@ -108,10 +108,5 @@ for file in $files; do
 done
 
 # Getting here means rebuilding the Docker image is not required.
-# The image will be pulled from GitHub Container Registry.
-
-# Log in to GitHub Container Registry
-docker login https://ghcr.io -u="$GH_CR_USER" -p="$GH_CR_PAT"
-
-# Pull the image from GitHub Container Registry.
-docker pull ${DOCKER_REPO}:1.10-${OS}-${OS_VER}-${CI_CPU_ARCH}
+# Pull the image from Docker Hub.
+docker pull ${DOCKERHUB_REPO}:1.10-${OS}-${OS_VER}-${CI_CPU_ARCH}
-- 
GitLab