Skip to content
Snippets Groups Projects
Verified Commit 751efa68 authored by Konrad Botor's avatar Konrad Botor
Browse files

Rewrote the scripts to match those from Hive and HAF - ref. hive#434

parent 9c69fc27
No related branches found
No related tags found
2 merge requests!827Merge develop changes to master,!588CI job that builds and pushes an official Hivemind image
...@@ -183,13 +183,6 @@ prepare_haf_image: ...@@ -183,13 +183,6 @@ prepare_haf_image:
- git config --global --add safe.directory $CI_PROJECT_DIR/haf - git config --global --add safe.directory $CI_PROJECT_DIR/haf
tags: *shared_tags tags: *shared_tags
prepare_hivemind_image:
stage: build
extends: .docker_image_builder_job_template
script:
- *instance-build-script
tags: *shared_tags
prepare_haf_data: prepare_haf_data:
extends: .prepare_haf_data_5m extends: .prepare_haf_data_5m
needs: needs:
...@@ -295,7 +288,9 @@ publish_instance_image: ...@@ -295,7 +288,9 @@ publish_instance_image:
stage: publish stage: publish
extends: .publish_docker_image_template extends: .publish_docker_image_template
script: script:
- scripts/ci/build_and_publish_instance.sh - |
TAG=$(echo "$CI_COMMIT_TAG" | sed 's/[!+]/-/g')
scripts/ci-helpers/build_and_publish_instance.sh --image-tag=$TAG
tags: *shared_tags tags: *shared_tags
Trigger benchmark-results-collector: Trigger benchmark-results-collector:
......
...@@ -110,14 +110,14 @@ $ pip install --no-cache-dir --verbose --user . 2>&1 | tee pip_install.log ...@@ -110,14 +110,14 @@ $ pip install --no-cache-dir --verbose --user . 2>&1 | tee pip_install.log
## Dockerized setup ## Dockerized setup
### Building ### Building
To build image holding Hivemind instance, please use [build_instance.sh](scripts/ci/build_instance.sh). This script requires several parameters: To build image holding Hivemind instance, please use [build_instance.sh](scripts/ci-helpers/build_instance.sh). This script requires several parameters:
- a tag identifier to be set on the built image - a tag identifier to be set on the built image
- directory where Hivemind source code is located - directory where Hivemind source code is located
- docker registry url to produce fully qualified image name and allow to correctly resolve its dependencies - docker registry url to produce fully qualified image name and allow to correctly resolve its dependencies
```bash ```bash
$ # Assuming you are in workdir directory, to perform out of source build $ # Assuming you are in workdir directory, to perform out of source build
$ ../hivemind/scripts/ci/build_instance.sh local ../hivemind registry.gitlab.syncad.com/hive/hivemind/ $ ../hivemind/scripts/ci-helpers/build_instance.sh local ../hivemind registry.gitlab.syncad.com/hive/hivemind
``` ```
### Running HAF instance container ### Running HAF instance container
......
#! /bin/bash #! /bin/bash
SCRIPT_DIR=$(dirname "$(realpath "$0")") SCRIPT_DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 || exit 1; pwd -P )"
SRC_DIR="$SCRIPT_DIR/../.." SRC_DIR="$SCRIPT_DIR/../.."
print_help () { print_help () {
echo "Usage: $0 OPTION[=VALUE]..." echo "Usage: $0 OPTION[=VALUE]..."
echo echo
echo "Script for building Docker image of Hivemin instance and pushing it to GitLab registry and to Docker Hub" echo "Script for building Docker image of Hive instance and pushingit to GitLab registry and to Docker Hub"
echo "All options (except '--help') are required" echo "All options (except '--help') are required"
echo "OPTIONS:" echo "OPTIONS:"
echo " --registry-user=USERNAME Docker registry user" echo " --registry-user=USERNAME Docker registry user"
echo " --registry-password=PASS Docker registry user" echo " --registry-password=PASS Docker registry user"
echo " --registry=URL Docker registry URL, eg. 'registry.gitlab.syncad.com'" echo " --registry=URL Docker registry URL, eg. 'registry.gitlab.syncad.com'"
echo " --image-tag=TAG Docker image tag, in CI the same as Git tag" echo " --image-tag=TAG Docker image tag, in CI the same as Git tag"
echo " --image-name-prefix=PREFIX Docker image name prefix, eg. 'registry.gitlab.syncad.com/hive/hivemind'" echo " --image-name-prefix=PREFIX Docker image name prefix, eg. 'registry.gitlab.syncad.com/hive/hive'"
echo " --docker-hub-user=USERNAME Docker Hub username" echo " --docker-hub-user=USERNAME Docker Hub username"
echo " --docker-hub-password=PASS Docker Hub password" echo " --docker-hub-password=PASS Docker Hub password"
echo " -?/--help Display this help screen and exit" echo " -?/--help Display this help screen and exit"
...@@ -85,19 +85,13 @@ docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY" ...@@ -85,19 +85,13 @@ docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
docker login -u "$DOCKER_HUB_USER" -p "$DOCKER_HUB_PASSWORD" docker login -u "$DOCKER_HUB_USER" -p "$DOCKER_HUB_PASSWORD"
echo "Building an instance image in the source directory $SRC_DIR" echo "Building an instance image in the source directory $SRC_DIR"
# Turn PEP 440-compliant version number into a Docker-compliant tag "$SRC_DIR/scripts/ci-helpers/build_instance.sh" "$CI_COMMIT_TAG" "$SRC_DIR" "$CI_REGISTRY_IMAGE"
#shellcheck disable=SC2001
TAG=$(echo "$CI_COMMIT_TAG" | sed 's/[!+]/-/g')
"$SRC_DIR/scripts/ci/build_instance.sh" \
"instance-$TAG" \
"$SRC_DIR" \
"$CI_REGISTRY_IMAGE/"
echo "Tagging the image built in the previous step as hiveio/$CI_PROJECT_NAME:$TAG" echo "Tagging the image built in the previous step as hiveio/$CI_PROJECT_NAME:$CI_COMMIT_TAG"
docker tag "$CI_REGISTRY_IMAGE/instance:instance-$TAG" "hiveio/$CI_PROJECT_NAME:$TAG" docker tag "$CI_REGISTRY_IMAGE/instance:instance-$CI_COMMIT_TAG" "hiveio/$CI_PROJECT_NAME:$CI_COMMIT_TAG"
docker images docker images
echo "Pushing the instance image to the Docker Hub and GitLab registries" echo "Pushing instance images"
docker push "$CI_REGISTRY_IMAGE/instance:instance-$TAG" docker push "$CI_REGISTRY_IMAGE/instance:instance-$CI_COMMIT_TAG"
docker push "hiveio/$CI_PROJECT_NAME:$TAG" docker push "hiveio/$CI_PROJECT_NAME:$CI_COMMIT_TAG"
\ No newline at end of file
...@@ -10,14 +10,14 @@ BUILD_IMAGE_TAG="" ...@@ -10,14 +10,14 @@ BUILD_IMAGE_TAG=""
REGISTRY="" REGISTRY=""
SRCROOTDIR="" SRCROOTDIR=""
print_help () { print_help () {
echo "Usage: $0 <image_tag> <src_dir> <registry_url> [OPTION[=VALUE]]..." cat <<EOF
echo Usage: $0 <image_tag> <src_dir> <registry_url> [OPTION[=VALUE]]...
echo "Allows to build docker image containing Hivemind installation" Allows to build docker image containing Hivemind installation
echo "OPTIONS:" OPTIONS:
echo " --help Display this help screen and exit" --help Display this help screen and exit
echo
EOF
} }
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
...@@ -25,7 +25,7 @@ while [ $# -gt 0 ]; do ...@@ -25,7 +25,7 @@ while [ $# -gt 0 ]; do
*) *)
if [ -z "$BUILD_IMAGE_TAG" ]; if [ -z "$BUILD_IMAGE_TAG" ];
then then
BUILD_IMAGE_TAG=:"${1}" BUILD_IMAGE_TAG="${1}"
elif [ -z "$SRCROOTDIR" ]; elif [ -z "$SRCROOTDIR" ];
then then
SRCROOTDIR="${1}" SRCROOTDIR="${1}"
...@@ -43,11 +43,11 @@ while [ $# -gt 0 ]; do ...@@ -43,11 +43,11 @@ while [ $# -gt 0 ]; do
shift shift
done done
[[ -z "$BUILD_IMAGE_TAG" ]] && echo "Variable BUILD_IMAGE_TAG must be set" && exit 1 [[ -z "$BUILD_IMAGE_TAG" ]] && printf "Variable BUILD_IMAGE_TAG must be set\n\n" && print_help && exit 1
[[ -z "$SRCROOTDIR" ]] && echo "Variable SRCROOTDIR must be set" && exit 1 [[ -z "$SRCROOTDIR" ]] && printf "Variable SRCROOTDIR must be set\n\n" && print_help && exit 1
[[ -z "$REGISTRY" ]] && echo "Variable REGISTRY must be set" && exit 1 [[ -z "$REGISTRY" ]] && printf "Variable REGISTRY must be set\n\n" && print_help && exit 1
echo "Moving into source root directory: ${SRCROOTDIR}" printf "Moving into source root directory: %s\n" "$SRCROOTDIR"
pushd "$SRCROOTDIR" || exit 1 pushd "$SRCROOTDIR" || exit 1
pwd pwd
...@@ -57,8 +57,8 @@ pwd ...@@ -57,8 +57,8 @@ pwd
BUILD_OPTIONS=("--platform=amd64" "--target=instance" "--progress=plain") BUILD_OPTIONS=("--platform=amd64" "--target=instance" "--progress=plain")
docker buildx build "${BUILD_OPTIONS[@]}" \ docker buildx build "${BUILD_OPTIONS[@]}" \
--build-arg CI_REGISTRY_IMAGE="$REGISTRY" \ --build-arg CI_REGISTRY_IMAGE="$REGISTRY/" \
--tag "${REGISTRY}instance${BUILD_IMAGE_TAG}" \ --tag "$REGISTRY/instance:instance-$BUILD_IMAGE_TAG" \
--file Dockerfile . --file Dockerfile .
popd || exit 1 popd || exit 1
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment