ligo/scripts/create_docker_image.build_deps.sh

68 lines
1.7 KiB
Bash
Raw Normal View History

2017-08-04 20:32:52 +04:00
#! /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}"
2017-08-10 12:05:44 +04:00
cached_image="${3:-}"
2017-08-04 20:32:52 +04:00
2017-08-10 12:05:44 +04:00
base_image="tezos/opam:alpine-${alpine_version}_ocaml-${ocaml_version}"
if ! docker pull "$base_image" ; then
2017-08-16 16:18:34 +04:00
./scripts/create_docker_image.alpine.sh
2017-08-10 12:05:44 +04:00
fi
2017-08-04 20:32:52 +04:00
cleanup () {
set +e
echo Cleaning up...
rm -rf Dockerfile
}
trap cleanup EXIT INT
2017-08-22 16:09:21 +04:00
sed -e 's|$base_image|'"$base_image"'|g' \
-e 's|$ocaml_version|'"$ocaml_version"'|g' \
scripts/Dockerfile.build_deps.in > Dockerfile
2017-08-04 20:32:52 +04:00
## Lookup for for prebuilt dependencies...
dependencies="scripts/install_build_deps.sh src/tezos-deps.opam Dockerfile"
dependencies_sha1=$(docker inspect --format="{{ .RootFS.Layers }}" --type=image $base_image | sha1sum - $dependencies | sha1sum | tr -d ' -')
2017-08-10 12:05:44 +04:00
if [ ! -z "$cached_image" ]; then
echo
echo "### Looking for prebuilt dependencies ($cached_image)..."
if docker pull "$cached_image:$dependencies_sha1"; then
echo
echo "### Found $cached_image:$dependencies_sha1"
echo
docker tag "$cached_image:$dependencies_sha1" \
"$image_name:$image_version"
exit 0
fi
echo "### Missing..."
echo
2017-08-10 12:05:44 +04:00
fi
2017-08-04 20:32:52 +04:00
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
2017-08-10 12:05:44 +04:00
if [ ! -z "$cached_image" ]; then
echo
2017-08-16 16:18:34 +04:00
echo "### Saving docker image ($cached_image)..."
echo
docker tag "$image_name:$image_version" \
"$cached_image:$dependencies_sha1"
docker push "$cached_image:$dependencies_sha1"
2017-08-10 12:05:44 +04:00
fi