Update CI
This commit is contained in:
parent
974d4ddd9e
commit
eed9e7581d
303
.gitlab-ci.yml
303
.gitlab-ci.yml
@ -1,266 +1,169 @@
|
||||
variables:
|
||||
public_docker_image: docker.io/tezos/tezos
|
||||
|
||||
image: ${CI_REGISTRY_IMAGE}:${CI_BUILD_REF}_build_deps
|
||||
|
||||
stages:
|
||||
- build_deps
|
||||
- build
|
||||
- test
|
||||
- build_docker
|
||||
- publish
|
||||
- deploy
|
||||
- cleanup
|
||||
|
||||
build_deps:
|
||||
stage: build_deps
|
||||
## Template for `docker_in_docker` jobs
|
||||
|
||||
.dind_template: &dind_definition
|
||||
image: docker:latest
|
||||
variables:
|
||||
DOCKER_DRIVER: overlay2
|
||||
services:
|
||||
- docker:dind
|
||||
before_script:
|
||||
- docker info
|
||||
- docker login -u gitlab-ci-token -p "$CI_BUILD_TOKEN" "${CI_REGISTRY}"
|
||||
tags:
|
||||
- docker_builder
|
||||
script:
|
||||
- ./scripts/create_build_deps_docker_image.sh
|
||||
${CI_REGISTRY_IMAGE} ${CI_BUILD_REF}_build_deps
|
||||
- docker
|
||||
|
||||
## Tezos
|
||||
|
||||
build:
|
||||
<<: *dind_definition
|
||||
stage: build
|
||||
tags:
|
||||
- tezos_builder
|
||||
script:
|
||||
- echo "PRODUCTION=yes" > src/Makefile.local
|
||||
- make -C src -j4
|
||||
- make -C test build
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
untracked: true
|
||||
## Building dependencies...
|
||||
- ./scripts/create_docker_image.build_deps.sh
|
||||
"build_deps" "${CI_BUILD_REF}"
|
||||
"${CI_REGISTRY_IMAGE}/build_deps:${CI_BUILD_REF_NAME}"
|
||||
"${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...
|
||||
- if [ "${CI_PROJECT_PATH}" = "tezos/tezos" ] ; then
|
||||
./scripts/apply_patch.sh "${CI_BUILD_REF_NAME}" ;
|
||||
fi
|
||||
## Building...
|
||||
- ./scripts/create_docker_image.build.sh
|
||||
"${CI_REGISTRY_IMAGE}/build" "${CI_BUILD_REF}"
|
||||
"build_deps:${CI_BUILD_REF}"
|
||||
## Saving the docker image...
|
||||
- docker push "${CI_REGISTRY_IMAGE}/build:${CI_BUILD_REF}"
|
||||
|
||||
## Basic tests
|
||||
|
||||
.test_template: &test_definition
|
||||
stage: test
|
||||
image: ${CI_REGISTRY_IMAGE}/build:${CI_BUILD_REF}
|
||||
before_script:
|
||||
- cd /home/opam/tezos
|
||||
dependencies:
|
||||
- build
|
||||
|
||||
test:utils:data-encoding:
|
||||
stage: test
|
||||
tags:
|
||||
- tezos_builder
|
||||
<<: *test_definition
|
||||
script:
|
||||
- make -C test/utils run-test-data-encoding
|
||||
dependencies:
|
||||
- build
|
||||
|
||||
test:utils:merkle:
|
||||
stage: test
|
||||
tags:
|
||||
- tezos_builder
|
||||
<<: *test_definition
|
||||
script:
|
||||
- make -C test/utils run-test-merkle
|
||||
dependencies:
|
||||
- build
|
||||
|
||||
test:shell:store:
|
||||
stage: test
|
||||
tags:
|
||||
- tezos_builder
|
||||
<<: *test_definition
|
||||
script:
|
||||
- make -C test/shell run-test-store
|
||||
dependencies:
|
||||
- build
|
||||
|
||||
test:shell:context:
|
||||
stage: test
|
||||
tags:
|
||||
- tezos_builder
|
||||
<<: *test_definition
|
||||
script:
|
||||
- make -C test/shell run-test-context
|
||||
dependencies:
|
||||
- build
|
||||
|
||||
test:shell:state:
|
||||
stage: test
|
||||
tags:
|
||||
- tezos_builder
|
||||
<<: *test_definition
|
||||
script:
|
||||
- make -C test/shell run-test-state
|
||||
dependencies:
|
||||
- build
|
||||
|
||||
test:p2p:io-scheduler:
|
||||
stage: test
|
||||
tags:
|
||||
- tezos_builder
|
||||
<<: *test_definition
|
||||
script:
|
||||
- make -C test/p2p run-test-p2p-io-scheduler
|
||||
dependencies:
|
||||
- build
|
||||
|
||||
test:p2p:connection:
|
||||
stage: test
|
||||
tags:
|
||||
- tezos_builder
|
||||
<<: *test_definition
|
||||
script:
|
||||
- make -C test/p2p run-test-p2p-connection
|
||||
dependencies:
|
||||
- build
|
||||
|
||||
test:p2p:connection-pool:
|
||||
stage: test
|
||||
tags:
|
||||
- tezos_builder
|
||||
<<: *test_definition
|
||||
script:
|
||||
- make -C test/p2p run-test-p2p-connection-pool
|
||||
dependencies:
|
||||
- build
|
||||
|
||||
test:proto_alpha:transactions:
|
||||
stage: test
|
||||
tags:
|
||||
- tezos_builder
|
||||
<<: *test_definition
|
||||
script:
|
||||
- make -C test/proto_alpha run-test-transaction
|
||||
dependencies:
|
||||
- build
|
||||
|
||||
test:proto_alpha:origination:
|
||||
stage: test
|
||||
tags:
|
||||
- tezos_builder
|
||||
<<: *test_definition
|
||||
script:
|
||||
- make -C test/proto_alpha run-test-origination
|
||||
dependencies:
|
||||
- build
|
||||
|
||||
test:proto_alpha:endorsement:
|
||||
stage: test
|
||||
tags:
|
||||
- tezos_builder
|
||||
<<: *test_definition
|
||||
script:
|
||||
- make -C test/proto_alpha run-test-endorsement
|
||||
dependencies:
|
||||
- build
|
||||
|
||||
test:proto_alpha:vote:
|
||||
stage: test
|
||||
tags:
|
||||
- tezos_builder
|
||||
<<: *test_definition
|
||||
script:
|
||||
- make -C test/proto_alpha run-test-vote
|
||||
dependencies:
|
||||
- build
|
||||
|
||||
test:basic.sh:
|
||||
stage: test
|
||||
tags:
|
||||
- tezos_builder
|
||||
<<: *test_definition
|
||||
script:
|
||||
- make -C test run-basic.sh
|
||||
dependencies:
|
||||
- build
|
||||
|
||||
test:contracts.sh:
|
||||
stage: test
|
||||
tags:
|
||||
- tezos_builder
|
||||
<<: *test_definition
|
||||
script:
|
||||
- make -C test run-contracts.sh
|
||||
dependencies:
|
||||
- build
|
||||
|
||||
build:docker:
|
||||
stage: build_docker
|
||||
image: docker:latest
|
||||
tags:
|
||||
- public_docker_builder
|
||||
script:
|
||||
- ./scripts/create_docker_image.sh
|
||||
"${CI_REGISTRY_IMAGE}" "${CI_BUILD_REF}" .
|
||||
- docker login -u gitlab-ci-token -p "$CI_BUILD_TOKEN" "${CI_REGISTRY}"
|
||||
- docker tag "${CI_REGISTRY_IMAGE}:${CI_BUILD_REF}"
|
||||
"${CI_REGISTRY_IMAGE}:${CI_BUILD_REF_NAME}"
|
||||
- docker push "${CI_REGISTRY_IMAGE}:${CI_BUILD_REF_NAME}"
|
||||
- docker rmi "${CI_REGISTRY_IMAGE}:${CI_BUILD_REF_NAME}"
|
||||
## Publishing (small) docker images with tezos binaries
|
||||
|
||||
build:docker:alphanet:
|
||||
stage: build_docker
|
||||
image: docker:latest
|
||||
tags:
|
||||
- public_docker_builder
|
||||
only:
|
||||
- alphanet@tezos/tezos
|
||||
script:
|
||||
- sed -i s/TEZOS/TEZOS_ALPHANET/ src/node/shell/distributed_db_message.ml
|
||||
- patch -p1 < scripts/alphanet_constants.patch
|
||||
- ./scripts/create_docker_image.sh
|
||||
"${CI_REGISTRY_IMAGE}" "${CI_BUILD_REF}.patched" .
|
||||
|
||||
build:docker:alphanet_next:
|
||||
stage: build_docker
|
||||
image: docker:latest
|
||||
tags:
|
||||
- public_docker_builder
|
||||
only:
|
||||
- master@tezos/tezos
|
||||
script:
|
||||
- sed -i s/TEZOS/TEZOS_ALPHANET_NEXT/ src/node/shell/distributed_db_message.ml
|
||||
- patch -p1 < scripts/alphanet_constants.patch
|
||||
- patch -p1 < scripts/alphanet_next.patch
|
||||
- ./scripts/create_docker_image.sh
|
||||
"${CI_REGISTRY_IMAGE}" "${CI_BUILD_REF}.patched" .
|
||||
|
||||
publish:docker:
|
||||
publish:docker:minimal:
|
||||
<<: *dind_definition
|
||||
stage: publish
|
||||
image: docker:latest
|
||||
tags:
|
||||
- public_docker_builder
|
||||
only:
|
||||
- master@tezos/tezos
|
||||
- alphanet@tezos/tezos
|
||||
- zeronet@tezos/tezos
|
||||
script:
|
||||
- mkdir -p ~/.docker ;
|
||||
- docker pull "${CI_REGISTRY_IMAGE}/build:${CI_BUILD_REF}"
|
||||
- ./scripts/create_docker_image.minimal.sh
|
||||
"${public_docker_image}" "${CI_BUILD_REF_NAME}"
|
||||
"${CI_REGISTRY_IMAGE}/build:${CI_BUILD_REF}"
|
||||
- echo "$CI_DOCKER_AUTH" > ~/.docker/config.json ;
|
||||
- docker tag "${CI_REGISTRY_IMAGE}:${CI_BUILD_REF}"
|
||||
"${public_docker_image}:${CI_BUILD_REF_NAME}"
|
||||
- docker push "${public_docker_image}:${CI_BUILD_REF_NAME}"
|
||||
- docker rmi "${public_docker_image}:${CI_BUILD_REF_NAME}"
|
||||
|
||||
publish:docker:alphanet:
|
||||
stage: publish
|
||||
image: docker:latest
|
||||
tags:
|
||||
- public_docker_builder
|
||||
only:
|
||||
- alphanet@tezos/tezos
|
||||
script:
|
||||
- mkdir -p ~/.docker ;
|
||||
- echo "$CI_DOCKER_AUTH" > ~/.docker/config.json ;
|
||||
- docker tag "${CI_REGISTRY_IMAGE}:${CI_BUILD_REF}.patched"
|
||||
"${public_docker_image}:alphanet"
|
||||
- docker push "${public_docker_image}:alphanet"
|
||||
- docker rmi "${public_docker_image}:alphanet"
|
||||
- docker rmi "${CI_REGISTRY_IMAGE}:${CI_BUILD_REF}.patched"
|
||||
|
||||
publish:docker:alphanet_next:
|
||||
stage: publish
|
||||
image: docker:latest
|
||||
tags:
|
||||
- public_docker_builder
|
||||
only:
|
||||
- master@tezos/tezos
|
||||
script:
|
||||
- mkdir -p ~/.docker ;
|
||||
- echo "$CI_DOCKER_AUTH" > ~/.docker/config.json ;
|
||||
- docker tag "${CI_REGISTRY_IMAGE}:${CI_BUILD_REF}.patched"
|
||||
"${public_docker_image}:alphanet_next"
|
||||
- docker push "${public_docker_image}:alphanet_next"
|
||||
- docker rmi "${public_docker_image}:alphanet_next"
|
||||
- docker rmi "${CI_REGISTRY_IMAGE}:${CI_BUILD_REF}.patched"
|
||||
|
||||
## Publish to github...
|
||||
|
||||
publish:github:
|
||||
image: ocaml/opam
|
||||
stage: publish
|
||||
tags:
|
||||
- tezos_builder
|
||||
only:
|
||||
- master@tezos/tezos
|
||||
- alphanet@tezos/tezos
|
||||
script:
|
||||
- echo "${CI_KH}" > ~/.ssh/known_hosts
|
||||
- echo "${CI_PK_GITHUB}" > ~/.ssh/id_rsa
|
||||
- chmod 400 ~/.ssh/id_rsa
|
||||
- rm -fr .git/refs/original
|
||||
- if [ "${CI_PROJECT_PATH}" = "tezos/tezos" ] ; then
|
||||
./scripts/apply_patch.sh "${CI_BUILD_REF_NAME}" ;
|
||||
fi
|
||||
- git filter-branch --prune-empty --index-filter
|
||||
'git rm -r --cached --ignore-unmatch
|
||||
.gitlab-ci.yml
|
||||
@ -268,7 +171,9 @@ publish:github:
|
||||
src/client/embedded/bootstrap/mining/
|
||||
scripts/alphanet.sh
|
||||
scripts/alphanet_constants.patch
|
||||
scripts/alphanet_next.patch'
|
||||
scripts/alphanet_next.patch
|
||||
scripts/zeronet.patch
|
||||
scripts/delete_ci_image.sh'
|
||||
--env-filter
|
||||
'if [ $GIT_COMMIT != "f42e9d12ac75d2876a4cf600d44976b7090d4533" ] ; then
|
||||
export GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME" ;
|
||||
@ -278,59 +183,51 @@ publish:github:
|
||||
export GIT_AUTHOR_EMAIL="contact@tezos.com" ;
|
||||
fi'
|
||||
HEAD
|
||||
- git push git@github.com:tezos/tezos.git -f HEAD:master
|
||||
- git push git@github.com:tezos/tezos.git -f HEAD:${CI_BUILD_REF_NAME}
|
||||
|
||||
deploy:alphanet:
|
||||
image: ocaml/opam
|
||||
stage: deploy
|
||||
tags:
|
||||
- tezos_builder
|
||||
only:
|
||||
- alphanet@tezos/tezos
|
||||
script:
|
||||
- echo "${CI_KH}" > ~/.ssh/known_hosts
|
||||
- echo "${CI_PK_ALPHANET}" | tr -d "\r" > ~/.ssh/id_ed25519
|
||||
- echo "${CI_SSH_CONFIG}" | tr -d "\r" > ~/.ssh/ssh_config
|
||||
- chmod 600 ~/.ssh/id_ed25519
|
||||
- ssh -t tezos@35.167.138.212
|
||||
- ssh -t tezos@35.165.227.4
|
||||
- ssh -t bootstrap1
|
||||
- ssh -t bootstrap2
|
||||
- ssh -t bootstrap3
|
||||
- ssh -t bootstrap4
|
||||
- ssh -t bootstrap5
|
||||
- ssh -t bootstrap6
|
||||
allow_failure: true
|
||||
|
||||
deploy:alphanet_next:
|
||||
deploy:zeronet:
|
||||
image: ocaml/opam
|
||||
stage: deploy
|
||||
tags:
|
||||
- tezos_builder
|
||||
only:
|
||||
- master@tezos/tezos
|
||||
- zeronet@tezos/tezos
|
||||
script:
|
||||
- echo "${CI_KH}" > ~/.ssh/known_hosts
|
||||
- echo "${CI_PK_ALPHANET_NEXT}" | tr -d "\r" > ~/.ssh/id_ed25519
|
||||
- echo "${CI_PK_ZERONET}" | tr -d "\r" > ~/.ssh/id_ed25519
|
||||
- echo "${CI_SSH_CONFIG}" | tr -d "\r" > ~/.ssh/ssh_config
|
||||
- chmod 600 ~/.ssh/id_ed25519
|
||||
- ssh -t tezos@35.167.138.212
|
||||
- ssh -t tezos@35.165.227.4
|
||||
- ssh -t bootstrap1
|
||||
- ssh -t bootstrap2
|
||||
- ssh -t bootstrap3
|
||||
- ssh -t bootstrap4
|
||||
- ssh -t bootstrap5
|
||||
- ssh -t bootstrap6
|
||||
allow_failure: true
|
||||
|
||||
cleanup:
|
||||
<<: *dind_definition
|
||||
stage: cleanup
|
||||
image: docker:latest
|
||||
tags:
|
||||
- docker_builder
|
||||
script:
|
||||
- docker tag "${CI_REGISTRY_IMAGE}:${CI_BUILD_REF}_build_deps"
|
||||
"${CI_REGISTRY_IMAGE}:${CI_BUILD_REF_NAME}_build_deps"
|
||||
- docker rmi "${CI_REGISTRY_IMAGE}:${CI_BUILD_REF}_build_deps"
|
||||
when: always
|
||||
allow_failure: true
|
||||
|
||||
cleanup:public:
|
||||
stage: cleanup
|
||||
image: docker:latest
|
||||
tags:
|
||||
- public_docker_builder
|
||||
only:
|
||||
- master@tezos/tezos
|
||||
- alphanet@tezos/tezos
|
||||
script:
|
||||
- docker rmi "${CI_REGISTRY_IMAGE}:${CI_BUILD_REF}"
|
||||
when: always
|
||||
- ./scripts/delete_ci_image.sh gitlab-ci-token "${CI_BUILD_TOKEN}"
|
||||
"${CI_PROJECT_PATH_SLUG}/build"
|
||||
"${CI_BUILD_REF}"
|
||||
## Temporary allowed failure until image deletion is allowed on gitlab
|
||||
## https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/13248
|
||||
allow_failure: true
|
||||
|
12
scripts/Dockerfile.build.in
Normal file
12
scripts/Dockerfile.build.in
Normal file
@ -0,0 +1,12 @@
|
||||
FROM $base_image
|
||||
|
||||
COPY src /home/opam/tezos/src
|
||||
|
||||
RUN sudo chown -R opam /home/opam/tezos && \
|
||||
echo "PRODUCTION=yes" > /home/opam/tezos/src/Makefile.local && \
|
||||
opam config exec -- make -C tezos/src -j4
|
||||
|
||||
COPY test /home/opam/tezos/test
|
||||
|
||||
RUN sudo chown -R opam /home/opam/tezos/test && \
|
||||
opam config exec -- make -C tezos/test -j4 build
|
@ -1,8 +0,0 @@
|
||||
FROM $base_name:$base_version
|
||||
|
||||
COPY src /home/opam/tezos/src
|
||||
|
||||
RUN sudo chown -R opam /home/opam/tezos && \
|
||||
opam config exec -- make -C tezos/src -j4 && \
|
||||
mkdir bin && \
|
||||
cp tezos/tezos-* bin
|
@ -1,7 +1,8 @@
|
||||
FROM ocaml/opam:alpine-$alpine_version_ocaml-$ocaml_version
|
||||
FROM $base_image
|
||||
|
||||
COPY scripts/install_build_deps.sh scripts/version.sh scripts/
|
||||
COPY src/tezos-deps.opam src/
|
||||
COPY Dockerfile Dockerfile
|
||||
RUN sudo apk add libsodium-dev snappy-dev && \
|
||||
sudo apk add leveldb-dev \
|
||||
--update-cache \
|
||||
@ -9,4 +10,4 @@ RUN sudo apk add libsodium-dev snappy-dev && \
|
||||
opam switch $ocaml_version && \
|
||||
opam config exec -- ./scripts/install_build_deps.sh all \
|
||||
rm -fr ~/.opam/log/ \
|
||||
"$(opam config exec -- ocamlfind query stdlib)"/topdirs.cmi
|
||||
"$(opam config exec -- ocamlfind query compiler-libs)"/../topdirs.cmi
|
||||
|
35
scripts/apply_patch.sh
Executable file
35
scripts/apply_patch.sh
Executable file
@ -0,0 +1,35 @@
|
||||
#! /bin/sh
|
||||
|
||||
script_dir="$(cd "$(dirname "$0")" && echo "$(pwd -P)/")"
|
||||
cd "$script_dir"/..
|
||||
|
||||
branch=$1
|
||||
has_git() {
|
||||
which git && [ -d .git ]
|
||||
}
|
||||
|
||||
if has_git && ! [ -z "$(git status -s)" ] ; then
|
||||
echo "This script cannot be applied within a dirty git directory,"
|
||||
echo "you need 'stash' or 'commit' your changes before."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set -e
|
||||
|
||||
case "$branch" in
|
||||
zeronet)
|
||||
sed -i s/TEZOS/TEZOS_ZERONET/ src/node/shell/distributed_db_message.ml
|
||||
patch -p1 < scripts/alphanet_constants.patch
|
||||
patch -p1 < scripts/zeronet.patch
|
||||
if has_git; then git commit -a -m "Zeronet: DO NOT MERGE" --author "Tezos CI <null@tezos.com>"; fi
|
||||
echo "Done"
|
||||
;;
|
||||
alphanet)
|
||||
sed -i s/TEZOS/TEZOS_ALPHANET/ src/node/shell/distributed_db_message.ml
|
||||
patch -p1 < scripts/alphanet_constants.patch
|
||||
if has_git; then git commit -a -m "Alphanet: DO NOT MERGE" --author "Tezos CI <null@tezos.com>"; fi
|
||||
echo "Done"
|
||||
;;
|
||||
*)
|
||||
echo "Noop"
|
||||
esac
|
@ -1,19 +0,0 @@
|
||||
#! /bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
script_dir="$(cd "$(dirname "$0")" && echo "$(pwd -P)/")"
|
||||
src_dir="$(dirname "$script_dir")"
|
||||
cd "$src_dir"
|
||||
|
||||
. scripts/version.sh
|
||||
image_name="${1:-tezos_build_deps}"
|
||||
image_version="${2:-latest}"
|
||||
|
||||
sed scripts/Dockerfile.build_deps.in \
|
||||
-e 's|$alpine_version|'"$alpine_version"'|g' \
|
||||
-e 's|$ocaml_version|'"$ocaml_version"'|g' > Dockerfile
|
||||
|
||||
docker build --pull -t "$image_name:$image_version" .
|
||||
|
||||
rm Dockerfile
|
34
scripts/create_docker_image.build.sh
Executable file
34
scripts/create_docker_image.build.sh
Executable file
@ -0,0 +1,34 @@
|
||||
#! /bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
script_dir="$(cd "$(dirname "$0")" && echo "$(pwd -P)/")"
|
||||
src_dir="$(dirname "$script_dir")"
|
||||
cd "$src_dir"
|
||||
|
||||
. scripts/version.sh
|
||||
image_name="${1:-tezos_build}"
|
||||
image_version="${2:-latest}"
|
||||
build_deps_image_name="${3-${image_name}_deps:${image_version}}"
|
||||
|
||||
cleanup () {
|
||||
set +e
|
||||
echo Cleaning up...
|
||||
rm -rf Dockerfile
|
||||
}
|
||||
trap cleanup EXIT INT
|
||||
|
||||
sed scripts/Dockerfile.build.in \
|
||||
-e 's|$base_image|'"$build_deps_image_name"'|g' > Dockerfile
|
||||
|
||||
echo
|
||||
echo "### Building tezos..."
|
||||
echo
|
||||
|
||||
docker build -t "$image_name:$image_version" .
|
||||
|
||||
rm Dockerfile
|
||||
|
||||
echo
|
||||
echo "### Succesfully build docker image: $image_name:$image_version"
|
||||
echo
|
54
scripts/create_docker_image.build_deps.sh
Executable file
54
scripts/create_docker_image.build_deps.sh
Executable file
@ -0,0 +1,54 @@
|
||||
#! /bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
script_dir="$(cd "$(dirname "$0")" && echo "$(pwd -P)/")"
|
||||
src_dir="$(dirname "$script_dir")"
|
||||
cd "$src_dir"
|
||||
|
||||
. scripts/version.sh
|
||||
image_name="${1:-tezos_build_deps}"
|
||||
image_version="${2:-latest}"
|
||||
shift 2
|
||||
|
||||
base_image="ocaml/opam:alpine-${alpine_version}_ocaml-${ocaml_version}"
|
||||
docker pull "$base_image"
|
||||
|
||||
cleanup () {
|
||||
set +e
|
||||
echo Cleaning up...
|
||||
rm -rf Dockerfile
|
||||
}
|
||||
trap cleanup EXIT INT
|
||||
|
||||
sed scripts/Dockerfile.build_deps.in \
|
||||
-e 's|$base_image|'"$base_image"'|g' \
|
||||
-e 's|$ocaml_version|'"$ocaml_version"'|g' > Dockerfile
|
||||
|
||||
## Lookup for for prebuilt dependencies...
|
||||
base_layers=$(docker inspect --format="{{ .RootFS.Layers }}" --type=image $base_image | tr -d '[]')
|
||||
same() {
|
||||
docker run --rm "$1" cat /home/opam/$2 | diff -wq $2 -
|
||||
}
|
||||
for cached_image in "$@"; do
|
||||
if ! docker pull $cached_image; then continue; fi
|
||||
cached_base_layers=$(docker inspect --format="{{ .RootFS.Layers }}" --type=image $cached_image | tr -d '[]')
|
||||
if [ "${cached_base_layers##$base_layers}" = "$cached_base_layers" ]; then continue; fi
|
||||
if ! same "$cached_image" scripts/install_build_deps.sh ; then continue ; fi
|
||||
if ! same "$cached_image" src/tezos-deps.opam ; then continue ; fi
|
||||
if ! same "$cached_image" Dockerfile ; then continue ; fi
|
||||
docker tag "$cached_image" "$image_name:$image_version"
|
||||
exit 0
|
||||
done
|
||||
|
||||
echo
|
||||
echo "### Building tezos dependencies..."
|
||||
echo
|
||||
|
||||
docker build -t "$image_name:$image_version" .
|
||||
|
||||
rm Dockerfile
|
||||
|
||||
echo
|
||||
echo "### Succesfully build docker image: $image_name:$image_version"
|
||||
echo
|
39
scripts/create_docker_image.minimal.sh
Executable file
39
scripts/create_docker_image.minimal.sh
Executable file
@ -0,0 +1,39 @@
|
||||
#! /bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
script_dir="$(cd "$(dirname "$0")" && echo "$(pwd -P)/")"
|
||||
src_dir="$(dirname "$script_dir")"
|
||||
cd "$src_dir"
|
||||
|
||||
. scripts/version.sh
|
||||
image_name="${1:-tezos}"
|
||||
image_version="${2:-latest}"
|
||||
build_image_name="${3:-${image_name}_build:${image_version}}"
|
||||
|
||||
cleanup () {
|
||||
set +e
|
||||
echo Cleaning up...
|
||||
[ -z "$tmp_container" ] || docker rm -f "$tmp_container"
|
||||
rm -rf Dockerfile bin
|
||||
}
|
||||
trap cleanup EXIT INT
|
||||
|
||||
tmp_container="$(docker run -dit "$build_image_name" /bin/sh -c "mkdir /home/opam/bin && cp /home/opam/tezos/tezos-* /home/opam/bin")"
|
||||
|
||||
ret=$(docker wait "$tmp_container")
|
||||
if [ "$ret" -ne 0 ]; then exit $ret; fi
|
||||
|
||||
docker cp "$tmp_container":/home/opam/bin/ bin
|
||||
|
||||
echo
|
||||
echo "### Building minimal docker image..."
|
||||
echo
|
||||
|
||||
sed scripts/Dockerfile.minimal.in \
|
||||
-e 's|$alpine_version|'"$alpine_version"'|g' > Dockerfile
|
||||
docker build -t "$image_name:$image_version" .
|
||||
|
||||
echo
|
||||
echo "### Succesfully build docker image: $image_name:$image_version"
|
||||
echo
|
@ -9,32 +9,14 @@ cd "$src_dir"
|
||||
. scripts/version.sh
|
||||
image_name="${1:-tezos}"
|
||||
image_version="${2:-latest}"
|
||||
build_deps_image_name="$image_name"_build_deps
|
||||
build_image_name="${image_name}_build"
|
||||
build_deps_image_name="${image_name}_build_deps"
|
||||
|
||||
echo Building dependencies...
|
||||
./scripts/create_build_deps_docker_image.sh \
|
||||
./scripts/create_docker_image.build_deps.sh \
|
||||
"$build_deps_image_name" "$image_version"
|
||||
|
||||
cleanup () {
|
||||
set +e
|
||||
echo Cleaning up...
|
||||
[ -z "$tmp_container" ] || docker rm "$tmp_container"
|
||||
[ -z "$tmp_image" ] || docker rmi "$tmp_image"
|
||||
rm -rf Dockerfile bin
|
||||
}
|
||||
trap cleanup EXIT INT
|
||||
./scripts/create_docker_image.build.sh \
|
||||
"$build_image_name" "$image_version" "$build_deps_image_name"
|
||||
|
||||
sed scripts/Dockerfile.build_bin.in \
|
||||
-e 's|$base_name|'"$build_deps_image_name"'|g' \
|
||||
-e 's|$base_version|'"$image_version"'|g' > Dockerfile
|
||||
|
||||
echo Building tezos...
|
||||
tmp_image="$(docker build -q .)"
|
||||
tmp_container="$(docker run -dit "$tmp_image" true)"
|
||||
|
||||
docker cp "$tmp_container":/home/opam/bin/ bin
|
||||
|
||||
echo Building minimal docker image...
|
||||
sed scripts/Dockerfile.binaries.in \
|
||||
-e 's|$alpine_version|'"$alpine_version"'|g' > Dockerfile
|
||||
docker build -q -t "$image_name:$image_version" .
|
||||
./scripts/create_docker_image.minimal.sh \
|
||||
"$image_name" "$image_version" "$build_image_name"
|
||||
|
66
scripts/delete_ci_image.sh
Executable file
66
scripts/delete_ci_image.sh
Executable file
@ -0,0 +1,66 @@
|
||||
#! /bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
registry_uri="https://registry.gitlab.com/v2"
|
||||
auth_uri="https://gitlab.com/jwt/auth"
|
||||
|
||||
getBearerToken() {
|
||||
local headers
|
||||
local username
|
||||
local reponame
|
||||
local basic_token
|
||||
username="$1"
|
||||
password="$2"
|
||||
reponame="$3"
|
||||
basic_token=$(echo -n "${username}:${password}" | base64)
|
||||
headers="Authorization: Basic ${basic_token}"
|
||||
curl -s -H "${headers}" "${auth_uri}?service=container_registry&scope=repository:${reponame}:*" | jq '.token' -r
|
||||
}
|
||||
|
||||
getTagDigest() {
|
||||
local token=$1
|
||||
local reponame=$2
|
||||
local tag=$3
|
||||
local id=$(curl -s -H "Authorization: Bearer ${token}" \
|
||||
-D - -o /dev/null \
|
||||
"${registry_uri}/${reponame}/manifests/${tag}" | \
|
||||
grep Docker-Content-Digest | tr -d '\r')
|
||||
echo -n "${id##Docker-Content-Digest: }"
|
||||
}
|
||||
|
||||
deleteDigest() {
|
||||
local token=$1
|
||||
local reponame=$2
|
||||
local digest=$3
|
||||
curl -s -H "Authorization: Bearer ${token}" \
|
||||
-D - -o - -X DELETE \
|
||||
"${registry_uri}/${reponame}/manifests/${digest}"
|
||||
}
|
||||
|
||||
deleteTag() {
|
||||
local token=$1
|
||||
local reponame=$2
|
||||
local tag=$3
|
||||
local digest="$(getTagDigest "${token}" "${reponame}" "${tag}")"
|
||||
if [ -z "$digest" ]; then
|
||||
echo "Failed to locate the ${reponame}:${tag}"
|
||||
exit 1
|
||||
fi
|
||||
deleteDigest "${token}" "${reponame}" "${digest}"
|
||||
}
|
||||
|
||||
username="$1"
|
||||
password="$2"
|
||||
reponame="$3"
|
||||
tags="${4:-latest}"
|
||||
|
||||
token="$(getBearerToken "${username}" "${password}" "${reponame}")"
|
||||
if [ -z "$token" ]; then
|
||||
echo "Failed to fetch the Bearer token"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for tag in $tags; do
|
||||
deleteTag "${token}" "${reponame}" "${tag}"
|
||||
done
|
@ -11,14 +11,14 @@ diff --git a/scripts/alphanet.sh b/scripts/alphanet.sh
|
||||
|
||||
-docker_image=docker.io/tezos/tezos:alphanet
|
||||
-docker_volume=tezos-alphanet-data$suffix
|
||||
+docker_image=docker.io/tezos/tezos:alphanet_next
|
||||
+docker_volume=tezos-alphanet-next-data$suffix
|
||||
+docker_image=docker.io/tezos/tezos:zeronet
|
||||
+docker_volume=tezos-zeronet-data$suffix
|
||||
suffix=
|
||||
|
||||
-data_dir="$HOME/.tezos-alphanet$suffix"
|
||||
-docker_container="tezos-alphanet$suffix"
|
||||
+data_dir="$HOME/.tezos-alphanet-next$suffix"
|
||||
+docker_container="tezos-alphanet-next$suffix"
|
||||
+data_dir="$HOME/.tezos-zeronet$suffix"
|
||||
+docker_container="tezos-zeronet$suffix"
|
||||
|
||||
|
||||
## Saving state ############################################################
|
Loading…
Reference in New Issue
Block a user