CI: fix the 'deploy' rules of alphanet/zeronet

This commit is contained in:
Grégoire Henry 2017-08-08 17:04:11 +02:00
parent 866b316993
commit 58b53d79c5
4 changed files with 72 additions and 50 deletions

View File

@ -31,15 +31,7 @@ build:
## Building dependencies... ## Building dependencies...
- ./scripts/create_docker_image.build_deps.sh - ./scripts/create_docker_image.build_deps.sh
"build_deps" "${CI_BUILD_REF}" "build_deps" "${CI_BUILD_REF}"
"${CI_REGISTRY_IMAGE}/build_deps:${CI_BUILD_REF_NAME}" "${CI_REGISTRY_IMAGE}/build_deps"
"${CI_REGISTRY_IMAGE}/build_deps:master"
## Saving the docker image...
- if [ "${CI_PROJECT_PATH}" = "tezos/tezos" ] &&
[ "${CI_BUILD_REF_NAME}" = "master" ] ; then
docker tag "build_deps:${CI_BUILD_REF}"
"${CI_REGISTRY_IMAGE}/build_deps:master" ;
docker push "${CI_REGISTRY_IMAGE}/build_deps:master" ;
fi
## Preparing sources for the alphanet or the zeronet... ## Preparing sources for the alphanet or the zeronet...
- if [ "${CI_PROJECT_PATH}" = "tezos/tezos" ] ; then - if [ "${CI_PROJECT_PATH}" = "tezos/tezos" ] ; then
./scripts/apply_patch.sh "${CI_BUILD_REF_NAME}" ; ./scripts/apply_patch.sh "${CI_BUILD_REF_NAME}" ;
@ -142,6 +134,9 @@ publish:docker:minimal:
- zeronet@tezos/tezos - zeronet@tezos/tezos
script: script:
- docker pull "${CI_REGISTRY_IMAGE}/build:${CI_BUILD_REF}" - docker pull "${CI_REGISTRY_IMAGE}/build:${CI_BUILD_REF}"
- if [ "${CI_PROJECT_PATH}" = "tezos/tezos" ] ; then
./scripts/apply_patch.sh "${CI_BUILD_REF_NAME}" ;
fi
- ./scripts/create_docker_image.minimal.sh - ./scripts/create_docker_image.minimal.sh
"${public_docker_image}" "${CI_BUILD_REF_NAME}" "${public_docker_image}" "${CI_BUILD_REF_NAME}"
"${CI_REGISTRY_IMAGE}/build:${CI_BUILD_REF}" "${CI_REGISTRY_IMAGE}/build:${CI_BUILD_REF}"
@ -185,41 +180,57 @@ publish:github:
HEAD HEAD
- git push git@github.com:tezos/tezos.git -f HEAD:${CI_BUILD_REF_NAME} - git push git@github.com:tezos/tezos.git -f HEAD:${CI_BUILD_REF_NAME}
deploy:alphanet:
## Relaunching the bootstrap servers of the alphanet.zeronet
.bootstrap_template: &bootstrap_definition
image: ocaml/opam image: ocaml/opam
stage: deploy stage: deploy
only: only:
- alphanet@tezos/tezos - alphanet@tezos/tezos
script: - zeronet@tezos/tezos
before_script:
- echo "${CI_KH}" > ~/.ssh/known_hosts - echo "${CI_KH}" > ~/.ssh/known_hosts
- echo "${CI_PK_ALPHANET}" | tr -d "\r" > ~/.ssh/id_ed25519 - if [ "${CI_BUILD_REF_NAME}" = "alphanet" ]; then
- echo "${CI_SSH_CONFIG}" | tr -d "\r" > ~/.ssh/ssh_config echo "${CI_PK_ALPHANET}" | tr -d "\r" > ~/.ssh/id_ed25519 ;
else
echo "${CI_PK_ZERONET}" | tr -d "\r" > ~/.ssh/id_ed25519 ;
fi
- echo "${CI_SSH_CONFIG}" | tr -d "\r" > ~/.ssh/config
- chmod 600 ~/.ssh/id_ed25519 - chmod 600 ~/.ssh/id_ed25519
- ssh -t bootstrap1
- ssh -t bootstrap2
- ssh -t bootstrap3
- ssh -t bootstrap4
- ssh -t bootstrap5
- ssh -t bootstrap6
allow_failure: true allow_failure: true
deploy:zeronet: deploy:bootstrap1:
image: ocaml/opam <<: *bootstrap_definition
stage: deploy
only:
- zeronet@tezos/tezos
script: script:
- echo "${CI_KH}" > ~/.ssh/known_hosts - ssh bootstrap1
- echo "${CI_PK_ZERONET}" | tr -d "\r" > ~/.ssh/id_ed25519
- echo "${CI_SSH_CONFIG}" | tr -d "\r" > ~/.ssh/ssh_config deploy:bootstrap2:
- chmod 600 ~/.ssh/id_ed25519 <<: *bootstrap_definition
- ssh -t bootstrap1 script:
- ssh -t bootstrap2 - ssh bootstrap2
- ssh -t bootstrap3
- ssh -t bootstrap4 deploy:bootstrap3:
- ssh -t bootstrap5 <<: *bootstrap_definition
- ssh -t bootstrap6 script:
allow_failure: true - ssh bootstrap3
deploy:bootstrap4:
<<: *bootstrap_definition
script:
- ssh bootstrap4
deploy:bootstrap5:
<<: *bootstrap_definition
script:
- ssh bootstrap5
deploy:bootstrap6:
<<: *bootstrap_definition
script:
- ssh bootstrap6
## Cleanup...
cleanup: cleanup:
<<: *dind_definition <<: *dind_definition

View File

@ -432,7 +432,7 @@ assert_uptodate() {
update_script() { update_script() {
pull_image pull_image
tmp="$(docker run --rm -dit --entrypoint /bin/true "$docker_image")" tmp="$(docker run --rm -dit --entrypoint /bin/sleep "$docker_image" 20)"
docker cp "$tmp:home/tezos/scripts/alphanet.sh" ".alphanet.sh.new" docker cp "$tmp:home/tezos/scripts/alphanet.sh" ".alphanet.sh.new"
docker stop "$tmp" > /dev/null docker stop "$tmp" > /dev/null
if ! diff .alphanet.sh.new "$0" >/dev/null 2>&1 ; then if ! diff .alphanet.sh.new "$0" >/dev/null 2>&1 ; then

View File

@ -26,19 +26,21 @@ sed scripts/Dockerfile.build_deps.in \
-e 's|$ocaml_version|'"$ocaml_version"'|g' > Dockerfile -e 's|$ocaml_version|'"$ocaml_version"'|g' > Dockerfile
## Lookup for for prebuilt dependencies... ## Lookup for for prebuilt dependencies...
base_layers=$(docker inspect --format="{{ .RootFS.Layers }}" --type=image $base_image | tr -d '[]') dependencies="scripts/install_build_deps.sh src/tezos-deps.opam Dockerfile"
same() { dependencies_sha1=$(docker inspect --format="{{ .RootFS.Layers }}" --type=image $base_image | sha1sum - $dependencies | sha1sum | tr -d ' -')
docker run --rm "$1" cat /home/opam/$2 | diff -wq $2 -
}
for cached_image in "$@"; do for cached_image in "$@"; do
if ! docker pull $cached_image; then continue; fi echo
cached_base_layers=$(docker inspect --format="{{ .RootFS.Layers }}" --type=image $cached_image | tr -d '[]') echo "### Looking for prebuilt dependencies ($cached_image)..."
if [ "${cached_base_layers##$base_layers}" = "$cached_base_layers" ]; then continue; fi if docker pull "$cached_image:$dependencies_sha1"; then
if ! same "$cached_image" scripts/install_build_deps.sh ; then continue ; fi echo
if ! same "$cached_image" src/tezos-deps.opam ; then continue ; fi echo "### Found $cached_image:$dependencies_sha1"
if ! same "$cached_image" Dockerfile ; then continue ; fi echo
docker tag "$cached_image" "$image_name:$image_version" docker tag "$cached_image:$dependencies_sha1" \
exit 0 "$image_name:$image_version"
exit 0
fi
echo "### Missing..."
echo
done done
echo echo
@ -52,3 +54,12 @@ rm Dockerfile
echo echo
echo "### Succesfully build docker image: $image_name:$image_version" echo "### Succesfully build docker image: $image_name:$image_version"
echo echo
for cached_image in "$@"; do
echo
echo "### Saving socker image ($cached_image)..."
echo
docker tag "$image_name:$image_version" \
"$cached_image:$dependencies_sha1"
docker push "$cached_image:$dependencies_sha1"
done

View File

@ -20,8 +20,8 @@ diff --git a/scripts/alphanet.sh b/scripts/alphanet.sh
+data_dir="$HOME/.tezos-zeronet$suffix" +data_dir="$HOME/.tezos-zeronet$suffix"
+docker_container="tezos-zeronet$suffix" +docker_container="tezos-zeronet$suffix"
if [ $ALPHANET_EMACS ]; then
## Saving state ############################################################ interactive_flags="-t"
diff --git a/src/node/main/node_config_file.ml b/src/node/main/node_config_file.ml diff --git a/src/node/main/node_config_file.ml b/src/node/main/node_config_file.ml
--- a/src/node/main/node_config_file.ml --- a/src/node/main/node_config_file.ml
+++ b/src/node/main/node_config_file.ml +++ b/src/node/main/node_config_file.ml