Skip to content
This repository was archived by the owner on Mar 22, 2023. It is now read-only.

Commit 05ee1ab

Browse files
authored
Merge pull request #945 from lukaszstolarczuk/publish-docker-images-to-GHP
docker: use GH Container Registry instead of Docker Hub
2 parents d3bc47d + 55295fe commit 05ee1ab

7 files changed

Lines changed: 39 additions & 33 deletions

File tree

.github/workflows/coverity.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11

22
name: CPP-coverity
3-
43
on:
54
schedule:
65
# run this job at 00:00 UTC everyday
@@ -9,7 +8,7 @@ on:
98
env:
109
REPO: libpmemobj-cpp
1110
GITHUB_REPO: pmem/libpmemobj-cpp
12-
DOCKERHUB_REPO: pmem/libpmemobj-cpp
11+
CONTAINER_REG: ghcr.io/pmem/libpmemobj-cpp
1312

1413
jobs:
1514
linux:

.github/workflows/gha.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ on: [push, pull_request]
44
env:
55
REPO: libpmemobj-cpp
66
GITHUB_REPO: pmem/libpmemobj-cpp
7-
DOCKERHUB_REPO: pmem/libpmemobj-cpp
87

98
jobs:
109
linux:
1110
name: Linux
1211
runs-on: ubuntu-latest
1312
env:
14-
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
15-
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
13+
CONTAINER_REG: ghcr.io/pmem/libpmemobj-cpp
14+
# use org's Private Access Token to log in to GitHub Container Registry
15+
CONTAINER_REG_USER: ${{ secrets.GH_CR_USER }}
16+
CONTAINER_REG_PASS: ${{ secrets.GH_CR_PAT }}
1617
HOST_WORKDIR: /home/runner/work/libpmemobj-cpp/libpmemobj-cpp
1718
WORKDIR: utils/docker
1819
strategy:

.github/workflows/other_OSes.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
env:
1010
REPO: libpmemobj-cpp
1111
GITHUB_REPO: pmem/libpmemobj-cpp
12-
DOCKERHUB_REPO: pmem/libpmemobj-cpp
12+
CONTAINER_REG: ghcr.io/pmem/libpmemobj-cpp
1313

1414
jobs:
1515
linux:

utils/docker/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ if [[ -z "$HOST_WORKDIR" ]]; then
3535
exit 1
3636
fi
3737

38-
imageName=${DOCKERHUB_REPO}:1.12-${OS}-${OS_VER}
38+
imageName=${CONTAINER_REG}:1.12-${OS}-${OS_VER}
3939
containerName=libpmemobj-cpp-${OS}-${OS_VER}
4040

4141
if [[ "$command" == "" ]]; then

utils/docker/images/build-image.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ if [[ -z "${OS__OS_VER}" ]]; then
2929
exit 1
3030
fi
3131

32-
if [[ -z "${DOCKERHUB_REPO}" ]]; then
33-
echo "DOCKERHUB_REPO environment variable is not set"
32+
if [[ -z "${CONTAINER_REG}" ]]; then
33+
echo "CONTAINER_REG environment variable is not set"
3434
exit 1
3535
fi
3636

@@ -41,8 +41,8 @@ if [[ ! -f "Dockerfile.${OS__OS_VER}" ]]; then
4141
exit 1
4242
fi
4343

44-
echo "Build a Docker image tagged with ${DOCKERHUB_REPO}:1.12-${OS__OS_VER}"
45-
docker build -t ${DOCKERHUB_REPO}:1.12-${OS__OS_VER} \
44+
echo "Build a Docker image tagged with ${CONTAINER_REG}:1.12-${OS__OS_VER}"
45+
docker build -t ${CONTAINER_REG}:1.12-${OS__OS_VER} \
4646
--build-arg http_proxy=$http_proxy \
4747
--build-arg https_proxy=$https_proxy \
4848
-f Dockerfile.${OS__OS_VER} .

utils/docker/images/push-image.sh

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
# Copyright 2016-2020, Intel Corporation
44

55
#
6-
# push-image.sh - pushes the Docker image tagged with OS-VER to the Docker Hub.
6+
# push-image.sh - pushes the Docker image tagged with OS-VER to the ${CONTAINER_REG}.
77
#
8-
# The script utilizes $DOCKERHUB_USER and $DOCKERHUB_PASSWORD variables to
9-
# log in to the Docker Hub. The variables can be set in the CI's configuration
8+
# The script utilizes ${CONTAINER_REG_USER} and ${DOCKERHUB_PASSWORD} variables to
9+
# log in to the ${CONTAINER_REG}. The variables can be set in the CI's configuration
1010
# for automated builds.
1111
#
1212

@@ -22,23 +22,29 @@ if [[ -z "${OS_VER}" ]]; then
2222
exit 1
2323
fi
2424

25-
if [[ -z "${DOCKERHUB_REPO}" ]]; then
26-
echo "DOCKERHUB_REPO environment variable is not set"
25+
if [[ -z "${CONTAINER_REG}" ]]; then
26+
echo "CONTAINER_REG environment variable is not set"
27+
exit 1
28+
fi
29+
30+
if [[ -z "${CONTAINER_REG_USER}" || -z "${CONTAINER_REG_PASS}" ]]; then
31+
echo "ERROR: variables CONTAINER_REG_USER=\"${CONTAINER_REG_USER}\" and CONTAINER_REG_PASS=\"${CONTAINER_REG_PASS}\"" \
32+
"have to be set properly to allow login to the Container Registry."
2733
exit 1
2834
fi
2935

3036
TAG="1.12-${OS}-${OS_VER}"
3137

32-
echo "Check if the image tagged with ${DOCKERHUB_REPO}:${TAG} exists locally"
33-
if [[ ! $(docker images -a | awk -v pattern="^${DOCKERHUB_REPO}:${TAG}\$" \
38+
echo "Check if the image tagged with ${CONTAINER_REG}:${TAG} exists locally"
39+
if [[ ! $(docker images -a | awk -v pattern="^${CONTAINER_REG}:${TAG}\$" \
3440
'$1":"$2 ~ pattern') ]]
3541
then
36-
echo "ERROR: Docker image tagged ${DOCKERHUB_REPO}:${TAG} does not exist locally."
42+
echo "ERROR: Docker image tagged ${CONTAINER_REG}:${TAG} does not exist locally."
3743
exit 1
3844
fi
3945

40-
echo "Log in to the Docker Hub"
41-
docker login -u="${DOCKERHUB_USER}" -p="${DOCKERHUB_PASSWORD}"
46+
echo "Log in to the container registry"
47+
echo "${CONTAINER_REG_PASS}" | docker login ghcr.io -u="${CONTAINER_REG_USER}" --password-stdin
4248

43-
echo "Push the image to the repository"
44-
docker push ${DOCKERHUB_REPO}:${TAG}
49+
echo "Push the image to the container registry"
50+
docker push ${CONTAINER_REG}:${TAG}

utils/docker/pull-or-rebuild-image.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44

55
#
66
# pull-or-rebuild-image.sh - rebuilds the Docker image used in the
7-
# current Travis build if necessary.
7+
# current build if necessary.
88
#
99
# The script rebuilds the Docker image if:
1010
# 1. the Dockerfile for the current OS version (Dockerfile.${OS}-${OS_VER})
1111
# or any .sh script in the Dockerfiles directory were modified and committed, or
1212
# 2. "rebuild" param was passed as a first argument to this script.
1313
#
14-
# If the Travis build is not of the "pull_request" type (i.e. in case of
15-
# merge after pull_request) and it succeed, the Docker image should be pushed
16-
# to the Docker Hub repository. An empty file is created to signal that to
17-
# further scripts.
14+
# If the CI build is not of the "pull_request" type (i.e. in case of
15+
# a pull request merge or any other "push" event) and it succeeds, the Docker image
16+
# should be pushed to the ${CONTAINER_REG} repository.
17+
# An empty file is created to signal that to next scripts.
1818
#
1919
# If the Docker image does not have to be rebuilt, it will be pulled from
20-
# the Docker Hub.
20+
# the ${CONTAINER_REG}.
2121
#
2222

2323
set -e
@@ -87,16 +87,16 @@ for file in $files; do
8787
&& $CI_EVENT_TYPE != "pull_request" \
8888
&& $PUSH_IMAGE == "1" ]]
8989
then
90-
echo "The image will be pushed to Docker Hub"
90+
echo "The image will be pushed to the Container Registry"
9191
touch $CI_FILE_PUSH_IMAGE_TO_REPO
9292
else
93-
echo "Skip pushing the image to Docker Hub"
93+
echo "Skip pushing the image to the Container Registry"
9494
fi
9595

9696
exit 0
9797
fi
9898
done
9999

100100
# Getting here means rebuilding the Docker image is not required.
101-
# Pull the image from Docker Hub.
102-
docker pull ${DOCKERHUB_REPO}:1.12-${OS}-${OS_VER}
101+
# Pull the image from the Container Registry.
102+
docker pull ${CONTAINER_REG}:1.12-${OS}-${OS_VER}

0 commit comments

Comments
 (0)