2018-01-28 23:03:31 +04:00
|
|
|
#! /bin/sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
ci_dir="$(cd "$(dirname "$0")" && echo "$(pwd -P)/")"
|
|
|
|
script_dir="$(dirname "$ci_dir")"
|
|
|
|
src_dir="$(dirname "$script_dir")"
|
|
|
|
cd "$src_dir"
|
|
|
|
|
|
|
|
. "$script_dir"/version.sh
|
|
|
|
|
|
|
|
tmp_dir=$(mktemp -dt tezos.opam.tezos.XXXXXXXX)
|
|
|
|
|
|
|
|
image_name="${1:-tezos}"
|
|
|
|
image_version="${2:-latest}"
|
2018-07-05 01:08:20 +04:00
|
|
|
build_image="${3:-registry.gitlab.com/tezos/opam-repository:${opam_repository_tag}}"
|
|
|
|
base_image="${4-registry.gitlab.com/tezos/opam-repository:minimal--${opam_repository_tag}}"
|
2018-01-28 23:03:31 +04:00
|
|
|
|
|
|
|
cleanup () {
|
|
|
|
set +e
|
|
|
|
echo Cleaning up...
|
|
|
|
rm -rf "$tmp_dir"
|
|
|
|
if ! [ -z "$container" ]; then docker rm $container; fi
|
|
|
|
}
|
|
|
|
trap cleanup EXIT INT
|
|
|
|
|
|
|
|
mkdir -p "$tmp_dir"/bin
|
2018-01-29 21:26:27 +04:00
|
|
|
mkdir -p "$tmp_dir"/scripts
|
2018-07-05 01:08:20 +04:00
|
|
|
container=$(docker create $build_image)
|
2018-07-19 01:42:31 +04:00
|
|
|
versioned_daemons="$(sed "s/^\(.*\)$/tezos-baker-\1 tezos-endorser-\1 tezos-accuser-\1/g" "active_protocol_versions")"
|
2018-07-18 22:27:06 +04:00
|
|
|
for bin in tezos-client tezos-admin-client tezos-node $versioned_daemons tezos-signer; do
|
2018-07-05 01:08:20 +04:00
|
|
|
docker cp -L $container:/home/tezos/tezos/$bin "$tmp_dir"/bin
|
2018-01-28 23:03:31 +04:00
|
|
|
done
|
2018-03-07 15:02:33 +04:00
|
|
|
cp -a "$script_dir"/docker/entrypoint.sh "$tmp_dir"/bin/
|
|
|
|
cp -a "$script_dir"/docker/entrypoint.inc.sh "$tmp_dir"/bin/
|
2018-01-29 21:26:27 +04:00
|
|
|
cp "$script_dir"/alphanet.sh "$tmp_dir"/scripts/
|
|
|
|
cp "$script_dir"/alphanet_version "$tmp_dir"/scripts/
|
2018-03-07 15:02:33 +04:00
|
|
|
cp "$src_dir"/src/bin_client/bash-completion.sh "$tmp_dir"/scripts/
|
2018-07-18 22:27:06 +04:00
|
|
|
cp "$src_dir"/active_protocol_versions "$tmp_dir"/scripts/
|
2018-01-28 23:03:31 +04:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo "### Building minimal docker image..."
|
|
|
|
echo
|
|
|
|
|
|
|
|
cat > "$tmp_dir"/Dockerfile <<EOF
|
2018-07-05 01:08:20 +04:00
|
|
|
FROM $base_image
|
2018-01-28 23:03:31 +04:00
|
|
|
|
2018-07-05 01:08:20 +04:00
|
|
|
RUN sudo apk --no-cache add vim
|
|
|
|
ENV EDITOR=/usr/bin/vi
|
2018-01-28 23:03:31 +04:00
|
|
|
|
2018-07-05 01:08:20 +04:00
|
|
|
RUN sudo mkdir -p /var/run/tezos/node /var/run/tezos/client && \
|
|
|
|
sudo chown -R tezos /var/run/tezos
|
2018-01-28 23:03:31 +04:00
|
|
|
|
2018-03-07 15:02:33 +04:00
|
|
|
COPY bin/* /usr/local/bin/
|
2018-01-28 23:03:31 +04:00
|
|
|
|
2018-03-07 15:02:33 +04:00
|
|
|
COPY scripts/* /usr/local/share/tezos/
|
2018-01-28 23:03:31 +04:00
|
|
|
|
2018-01-29 21:26:27 +04:00
|
|
|
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
2018-01-28 23:03:31 +04:00
|
|
|
EOF
|
|
|
|
|
|
|
|
docker build -t "$image_name:$image_version" "$tmp_dir"
|
|
|
|
|
|
|
|
echo
|
2018-12-01 10:57:40 +04:00
|
|
|
echo "### Successfully build docker image: $image_name:$image_version"
|
2018-01-28 23:03:31 +04:00
|
|
|
echo
|