Merge pull request #3820 from nanocurrency/docker_build_deploy_split
Splits the deploy-docker.sh to have build/deploy parts
This commit is contained in:
commit
1885e9cb0e
8 changed files with 101 additions and 68 deletions
4
.github/workflows/beta_artifacts.yml
vendored
4
.github/workflows/beta_artifacts.yml
vendored
|
|
@ -81,8 +81,10 @@ jobs:
|
||||||
env:
|
env:
|
||||||
COMPILER: gcc
|
COMPILER: gcc
|
||||||
run: ci/actions/linux/install_deps.sh
|
run: ci/actions/linux/install_deps.sh
|
||||||
|
- name: Build Docker (nanocurrency/nano-beta)
|
||||||
|
run: TRAVIS_TAG=${TAG} ci/actions/linux/docker-build.sh
|
||||||
- name: Deploy Docker (nanocurrency/nano-beta)
|
- name: Deploy Docker (nanocurrency/nano-beta)
|
||||||
run: TRAVIS_TAG=${TAG} ci/actions/linux/deploy-docker.sh
|
run: TRAVIS_TAG=${TAG} ci/actions/linux/docker-deploy.sh
|
||||||
env:
|
env:
|
||||||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
- name: Login to ghcr.io
|
- name: Login to ghcr.io
|
||||||
|
|
|
||||||
2
.github/workflows/develop.yml
vendored
2
.github/workflows/develop.yml
vendored
|
|
@ -22,6 +22,6 @@ jobs:
|
||||||
- name: Deploy Docker (ghcr.io)
|
- name: Deploy Docker (ghcr.io)
|
||||||
run: ci/actions/linux/ghcr_push.sh
|
run: ci/actions/linux/ghcr_push.sh
|
||||||
- name: Deploy Docker (nanocurrency/nano-env)
|
- name: Deploy Docker (nanocurrency/nano-env)
|
||||||
run: ci/actions/linux/deploy-docker.sh
|
run: ci/actions/linux/docker-deploy.sh
|
||||||
env:
|
env:
|
||||||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
|
||||||
4
.github/workflows/live_artifacts.yml
vendored
4
.github/workflows/live_artifacts.yml
vendored
|
|
@ -80,8 +80,10 @@ jobs:
|
||||||
env:
|
env:
|
||||||
COMPILER: gcc
|
COMPILER: gcc
|
||||||
run: ci/actions/linux/install_deps.sh
|
run: ci/actions/linux/install_deps.sh
|
||||||
|
- name: Build Docker (nanocurrency/nano)
|
||||||
|
run: TRAVIS_TAG=${TAG} ci/actions/linux/docker-build.sh
|
||||||
- name: Deploy Docker (nanocurrency/nano)
|
- name: Deploy Docker (nanocurrency/nano)
|
||||||
run: TRAVIS_TAG=${TAG} ci/actions/linux/deploy-docker.sh
|
run: TRAVIS_TAG=${TAG} ci/actions/linux/docker-deploy.sh
|
||||||
env:
|
env:
|
||||||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
- name: Login to ghcr.io
|
- name: Login to ghcr.io
|
||||||
|
|
|
||||||
4
.github/workflows/test_network_artifacts.yml
vendored
4
.github/workflows/test_network_artifacts.yml
vendored
|
|
@ -81,8 +81,10 @@ jobs:
|
||||||
env:
|
env:
|
||||||
COMPILER: gcc
|
COMPILER: gcc
|
||||||
run: ci/actions/linux/install_deps.sh
|
run: ci/actions/linux/install_deps.sh
|
||||||
|
- name: Build Docker (nanocurrency/nano)
|
||||||
|
run: TRAVIS_TAG=${TAG} ci/actions/linux/docker-build.sh
|
||||||
- name: Deploy Docker (nanocurrency/nano)
|
- name: Deploy Docker (nanocurrency/nano)
|
||||||
run: TRAVIS_TAG=${TAG} ci/actions/linux/deploy-docker.sh
|
run: TRAVIS_TAG=${TAG} ci/actions/linux/docker-deploy.sh
|
||||||
env:
|
env:
|
||||||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
- name: Login to ghcr.io
|
- name: Login to ghcr.io
|
||||||
|
|
|
||||||
|
|
@ -1,64 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
scripts="$PWD/ci"
|
|
||||||
TRAVIS_BRANCH=$(git branch | cut -f2 -d' ')
|
|
||||||
tags=()
|
|
||||||
if [ -n "$TRAVIS_TAG" ]; then
|
|
||||||
tags+=("$TRAVIS_TAG")
|
|
||||||
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" = "Test" ]]; 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
|
|
||||||
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"
|
|
||||||
"$scripts"/custom-timeout.sh 30 docker push "nanocurrency/nano-env:clang-6"
|
|
||||||
echo "Deployed nano-env"
|
|
||||||
exit 0
|
|
||||||
else
|
|
||||||
if [[ "$GITHUB_WORKFLOW" = "Live" ]]; then
|
|
||||||
tags=$(docker images --format '{{.Repository}}:{{.Tag }}' | grep nanocurrency | grep -vE "env|ghcr.io|none|latest")
|
|
||||||
else
|
|
||||||
tags=$(docker images --format '{{.Repository}}:{{.Tag }}' | grep nanocurrency | grep -vE "env|ghcr.io|none")
|
|
||||||
fi
|
|
||||||
for a in $tags; do
|
|
||||||
"$scripts"/custom-timeout.sh 30 docker push "$a"
|
|
||||||
done
|
|
||||||
echo "$docker_image_name with tags ${tags//$'\n'/' '} deployed"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "\$DOCKER_PASSWORD environment variable required"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
8
ci/actions/linux/docker-build.sh
Executable file
8
ci/actions/linux/docker-build.sh
Executable file
|
|
@ -0,0 +1,8 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
set -x
|
||||||
|
|
||||||
|
source "$(dirname "$BASH_SOURCE")/docker-impl/docker-common.sh"
|
||||||
|
|
||||||
|
docker_build
|
||||||
8
ci/actions/linux/docker-deploy.sh
Executable file
8
ci/actions/linux/docker-deploy.sh
Executable file
|
|
@ -0,0 +1,8 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
set -x
|
||||||
|
|
||||||
|
source "$(dirname "$BASH_SOURCE")/docker-impl/docker-common.sh"
|
||||||
|
|
||||||
|
docker_deploy
|
||||||
75
ci/actions/linux/docker-impl/docker-common.sh
Executable file
75
ci/actions/linux/docker-impl/docker-common.sh
Executable file
|
|
@ -0,0 +1,75 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
set -a
|
||||||
|
|
||||||
|
scripts="$PWD/ci"
|
||||||
|
TRAVIS_BRANCH=$(git branch | cut -f2 -d' ')
|
||||||
|
tags=()
|
||||||
|
if [ -n "$TRAVIS_TAG" ]; then
|
||||||
|
tags+=("$TRAVIS_TAG")
|
||||||
|
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" = "Test" ]]; then
|
||||||
|
echo "Test"
|
||||||
|
network_tag_suffix="-test"
|
||||||
|
network="test"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$GITHUB_WORKFLOW" != "Develop" ]]; then
|
||||||
|
docker_image_name="nanocurrency/nano${network_tag_suffix}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
docker_build()
|
||||||
|
{
|
||||||
|
if [[ "$GITHUB_WORKFLOW" != "Develop" ]]; then
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
docker_deploy()
|
||||||
|
{
|
||||||
|
if [ -n "$DOCKER_PASSWORD" ]; then
|
||||||
|
echo "$DOCKER_PASSWORD" | docker login -u nanoreleaseteam --password-stdin
|
||||||
|
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"
|
||||||
|
"$scripts"/custom-timeout.sh 30 docker push "nanocurrency/nano-env:clang-6"
|
||||||
|
echo "Deployed nano-env"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
if [[ "$GITHUB_WORKFLOW" = "Live" ]]; then
|
||||||
|
tags=$(docker images --format '{{.Repository}}:{{.Tag }}' | grep nanocurrency | grep -vE "env|ghcr.io|none|latest")
|
||||||
|
else
|
||||||
|
tags=$(docker images --format '{{.Repository}}:{{.Tag }}' | grep nanocurrency | grep -vE "env|ghcr.io|none")
|
||||||
|
fi
|
||||||
|
for a in $tags; do
|
||||||
|
"$scripts"/custom-timeout.sh 30 docker push "$a"
|
||||||
|
done
|
||||||
|
echo "$docker_image_name with tags ${tags//$'\n'/' '} deployed"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "\$DOCKER_PASSWORD environment variable required"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue