github container repo (#3034)

update dockerfiles to include required label for github container repo reference
tags are generated for both locations using build-docker-image
push to ghcr.io using module for login in and push
This commit is contained in:
Russel Waters 2020-11-03 13:16:29 -08:00 committed by GitHub
commit abba607428
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 112 additions and 46 deletions

View file

@ -73,7 +73,15 @@ jobs:
run: TRAVIS_TAG=${TAG} ci/actions/linux/deploy-docker.sh
env:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to ghcr.io
uses: docker/login-action@adb7347
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR_PAT }}
- name: Deploy Docker (ghcr.io)
run: ci/actions/linux/ghcr_push.sh
windows_job:
runs-on: windows-latest
steps:

View file

@ -13,6 +13,14 @@ jobs:
run: git submodule update --init --recursive
- name: Fetch Deps
run: ci/actions/linux/install_deps.sh
- name: Login to ghcr.io
uses: docker/login-action@adb7347
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR_PAT }}
- name: Deploy Docker (ghcr.io)
run: ci/actions/linux/ghcr_push.sh
- name: Deploy Docker (nanocurrency/nano-env)
run: ci/actions/linux/deploy-docker.sh
env:

View file

@ -72,6 +72,14 @@ jobs:
run: TRAVIS_TAG=${TAG} ci/actions/linux/deploy-docker.sh
env:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to ghcr.io
uses: docker/login-action@adb7347
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR_PAT }}
- name: Deploy Docker (ghcr.io
run: ci/actions/linux/ghcr_push.sh
windows_job:
runs-on: windows-latest

View file

@ -72,7 +72,15 @@ jobs:
run: TRAVIS_TAG=${TAG} ci/actions/linux/deploy-docker.sh
env:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to ghcr.io
uses: docker/login-action@adb7347
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR_PAT }}
- name: Deploy Docker (ghcr.io)
run: ci/actions/linux/ghcr_push.sh
windows_job:
runs-on: windows-latest
steps:

View file

@ -2,11 +2,49 @@
set -e
scripts="$PWD/ci"
TRAVIS_BRANCH=`git branch| cut -f2 -d' '`
tags=()
if [ -n "$TRAVIS_TAG" ]; then
tags+=("$TRAVIS_TAG" latest)
if [[ "$GITHUB_WORKFLOW" = "Beta" || "$GITHUB_WORKFLOW" = "TestNetwork" ]]; then
tags+=(latest-including-rc)
fi
elif [ -n "$TRAVIS_BRANCH" ]; then
TRAVIS_TAG=$TRAVIS_BRANCH
tags+=("$TRAVIS_BRANCH")
fi
if [[ "$GITHUB_WORKFLOW" = "Live" ]]; then
echo "Live"
network_tag_suffix=''
network="live"
elif [[ "$GITHUB_WORKFLOW" = "Beta" ]]; then
echo "Beta"
network_tag_suffix="-beta"
network="beta"
elif [[ "$GITHUB_WORKFLOW" = "TestNetwork" ]]; then
echo "Test"
network_tag_suffix="-test"
network="test"
fi
if [[ "$GITHUB_WORKFLOW" != "Develop" ]]; then
docker_image_name="nanocurrency/nano${network_tag_suffix}"
ghcr_image_name="ghcr.io/${GITHUB_REPOSITORY}/nano${network_tag_suffix}"
"$scripts"/build-docker-image.sh docker/node/Dockerfile "$docker_image_name" --build-arg NETWORK="$network" --build-arg CI_BUILD=true --build-arg TRAVIS_TAG="$TRAVIS_TAG"
for tag in "${tags[@]}"; do
# Sanitize docker tag
# https://docs.docker.com/engine/reference/commandline/tag/
tag="$(printf '%s' "$tag" | tr -c '[a-z][A-Z][0-9]_.-' -)"
if [ "$tag" != "latest" ]; then
docker tag "$docker_image_name" "${docker_image_name}:$tag"
docker tag "$ghcr_image_name" "${ghcr_image_name}:$tag"
fi
done
fi
if [ -n "$DOCKER_PASSWORD" ]; then
echo "$DOCKER_PASSWORD" | docker login -u nanoreleaseteam --password-stdin
scripts="$PWD/ci"
TRAVIS_BRANCH=`git branch| cut -f2 -d' '`
if [[ "$GITHUB_WORKFLOW" = "Develop" ]]; then
"$scripts"/custom-timeout.sh 30 docker push "nanocurrency/nano-env:base"
"$scripts"/custom-timeout.sh 30 docker push "nanocurrency/nano-env:gcc"
@ -14,46 +52,13 @@ if [ -n "$DOCKER_PASSWORD" ]; then
echo "Deployed nano-env"
exit 0
else
tags=()
if [ -n "$TRAVIS_TAG" ]; then
tags+=("$TRAVIS_TAG" latest)
if [[ "$GITHUB_WORKFLOW" = "Beta" || "$GITHUB_WORKFLOW" = "TestNetwork" ]]; then
tags+=(latest-including-rc)
fi
elif [ -n "$TRAVIS_BRANCH" ]; then
TRAVIS_TAG=$TRAVIS_BRANCH
tags+=("$TRAVIS_BRANCH")
fi
if [[ "$GITHUB_WORKFLOW" = "Live" ]]; then
echo "Live"
network_tag_suffix=''
network="live"
elif [[ "$GITHUB_WORKFLOW" = "Beta" ]]; then
echo "Beta"
network_tag_suffix="-beta"
network="beta"
elif [[ "$GITHUB_WORKFLOW" = "TestNetwork" ]]; then
echo "Test"
network_tag_suffix="-test"
network="test"
else
echo "Nothing to deploy"
exit 1
fi
docker_image_name="nanocurrency/nano${network_tag_suffix}"
"$scripts"/custom-timeout.sh 30 docker build --build-arg NETWORK="$network" --build-arg CI_BUILD=true --build-arg TRAVIS_TAG="$TRAVIS_TAG" -f docker/node/Dockerfile -t "$docker_image_name" .
for tag in "${tags[@]}"; do
# Sanitize docker tag
# https://docs.docker.com/engine/reference/commandline/tag/
tag="$(printf '%s' "$tag" | tr -c '[a-z][A-Z][0-9]_.-' -)"
if [ "$tag" != "latest" ]; then
docker tag "$docker_image_name" "${docker_image_name}:$tag"
fi
"$scripts"/custom-timeout.sh 30 docker push "${docker_image_name}:$tag"
tags=`docker images --format '{{.Repository}}:{{.Tag }}'| grep nanocurrency |grep -vE "env|ghcr.io|none"`
for a in $tags; do
"$scripts"/custom-timeout.sh 30 docker push "$a"
done
echo "$docker_image_name with tags ${tags//$'\n'/' '} deployed"
fi
echo "$docker_image_name with tags ${tags[*]} deployed"
else
echo "\$DOCKER_PASSWORD environment variable required"
exit 1
exit 0
fi

15
ci/actions/linux/ghcr_push.sh Executable file
View file

@ -0,0 +1,15 @@
#!/bin/bash
set -e
scripts="$PWD/ci"
if [[ "$GITHUB_WORKFLOW" = "Develop" ]]; then
"$scripts"/custom-timeout.sh 30 docker push "ghcr.io/${GITHUB_REPOSITORY}/nano-env:base"
"$scripts"/custom-timeout.sh 30 docker push "ghcr.io/${GITHUB_REPOSITORY}/nano-env:gcc"
"$scripts"/custom-timeout.sh 30 docker push "ghcr.io/${GITHUB_REPOSITORY}/nano-env:clang-6"
else
tags=`docker images --format '{{.Repository}}:{{.Tag }}'| grep "ghcr.io" | grep -vE "env|none"`
for a in $tags; do
"$scripts"/custom-timeout.sh 30 docker push "$a"
done
fi

View file

@ -8,10 +8,13 @@ fi
dockerFile="$1"
dockerTag="$2"
githubTag="ghcr.io/${GITHUB_REPOSITORY}/${dockerTag#*/}"
shift; shift
scripts="$(dirname "$0")"
"$scripts"/custom-timeout.sh 20 docker pull "${dockerTag}" || true
echo "Building $dockerTag"
"$scripts"/custom-timeout.sh 30 docker build "$@" -f "${dockerFile}" -t "${dockerTag}" --cache-from "${dockerTag}" .
"$scripts"/custom-timeout.sh 20 docker pull "${githubTag}" || true
echo "Building $githubTag"
"$scripts"/custom-timeout.sh 30 docker build "$@" --build-arg REPOSITORY=${GITHUB_REPOSITORY} -f "${dockerFile}" -t "${githubTag}" --cache-from "${githubTag}" .
echo "Tagging ${dockerTag} from ${githubTag}"
docker tag $githubTag $dockerTag

View file

@ -17,3 +17,6 @@ RUN apt-get update -qq && apt-get install -yqq \
qt5-default \
valgrind \
xorg xvfb xauth xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic
ARG REPOSITORY=nanocurrency/nano-node
LABEL org.opencontainers.image.source https://github.com/$REPOSITORY

View file

@ -19,3 +19,5 @@ RUN ./fetch_boost.sh
# see https://www.boost.org/doc/libs/1_70_0/doc/html/stacktrace/configuration_and_build.html#stacktrace.configuration_and_build.f3
RUN ln -s /usr/lib/gcc/x86_64-linux-gnu/5/include/backtrace.h /tmp/backtrace.h
ARG REPOSITORY=nanocurrency/nano-node
LABEL org.opencontainers.image.source https://github.com/$REPOSITORY

View file

@ -25,3 +25,5 @@ RUN COMPILER=clang-6 ./fetch_boost.sh
# see https://www.boost.org/doc/libs/1_70_0/doc/html/stacktrace/configuration_and_build.html#stacktrace.configuration_and_build.f3
RUN ln -s /usr/lib/gcc/x86_64-linux-gnu/5/include/backtrace.h /tmp/backtrace.h
ARG REPOSITORY=nanocurrency/nano-node
LABEL org.opencontainers.image.source https://github.com/$REPOSITORY

View file

@ -7,3 +7,5 @@ ENV BOOST_ROOT=/tmp/boost
ADD util/build_prep/fetch_boost.sh fetch_boost.sh
RUN COMPILER=gcc ./fetch_boost.sh
ARG REPOSITORY=nanocurrency/nano-node
LABEL org.opencontainers.image.source https://github.com/$REPOSITORY

View file

@ -40,3 +40,5 @@ USER root
ENV PATH="${PATH}:/usr/bin"
ENTRYPOINT ["/usr/bin/entry.sh"]
CMD ["nano_node", "daemon", "-l"]
ARG REPOSITORY=nanocurrency/nano-node
LABEL org.opencontainers.image.source https://github.com/$REPOSITORY