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
|
|
|
|
|
|
|
|
export build_dir=${build_dir:-_docker_build}
|
|
|
|
tmp_dir=$(mktemp -dt tezos.opam.tezos.XXXXXXXX)
|
|
|
|
|
|
|
|
image_name="${1:-tezos}"
|
|
|
|
image_version="${2:-latest}"
|
|
|
|
build_image_name="${3:-${image_name}_build:${image_version}}"
|
|
|
|
|
|
|
|
cleanup () {
|
|
|
|
set +e
|
|
|
|
echo Cleaning up...
|
|
|
|
rm -rf "$tmp_dir"
|
|
|
|
if ! [ -z "$container" ]; then docker rm $container; fi
|
|
|
|
}
|
|
|
|
trap cleanup EXIT INT
|
|
|
|
|
|
|
|
"$ci_dir"/create_apk.leveldb.sh
|
2018-06-05 19:57:03 +04:00
|
|
|
"$ci_dir"/create_apk.hidapi.sh
|
2018-01-28 23:03:31 +04:00
|
|
|
|
|
|
|
cp -a "$build_dir"/leveldb-$leveldb_version-r0.apk \
|
|
|
|
"$build_dir"/keys/ \
|
|
|
|
"$tmp_dir"
|
|
|
|
|
2018-06-05 19:57:03 +04:00
|
|
|
cp -a "$build_dir"/hidapi-$hidapi_version-r0.apk \
|
|
|
|
"$build_dir"/keys/ \
|
|
|
|
"$tmp_dir"
|
|
|
|
|
2018-01-28 23:03:31 +04:00
|
|
|
mkdir -p "$tmp_dir"/bin
|
2018-01-29 21:26:27 +04:00
|
|
|
mkdir -p "$tmp_dir"/scripts
|
2018-01-28 23:03:31 +04:00
|
|
|
container=$(docker create $build_image_name)
|
2018-03-07 15:02:33 +04:00
|
|
|
for bin in tezos-client tezos-admin-client tezos-node; do
|
2018-01-28 23:03:31 +04:00
|
|
|
docker cp -L $container:/home/opam/tezos/$bin "$tmp_dir"/bin
|
|
|
|
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-01-28 23:03:31 +04:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo "### Building minimal docker image..."
|
|
|
|
echo
|
|
|
|
|
|
|
|
cat > "$tmp_dir"/Dockerfile <<EOF
|
|
|
|
FROM alpine:$alpine_version
|
|
|
|
|
|
|
|
LABEL distro_style="apk" distro="alpine" distro_long="alpine-$alpine_version" arch="x86_64" operatingsystem="linux"
|
|
|
|
|
|
|
|
COPY keys /etc/apk/keys/
|
|
|
|
COPY leveldb-$leveldb_version-r0.apk .
|
2018-06-05 19:57:03 +04:00
|
|
|
COPY hidapi-$hidapi_version-r0.apk .
|
2018-01-28 23:03:31 +04:00
|
|
|
|
2018-01-29 21:26:27 +04:00
|
|
|
RUN apk --no-cache add \
|
2018-06-05 19:57:03 +04:00
|
|
|
libev gmp vim leveldb-$leveldb_version-r0.apk hidapi-$hidapi_version-r0.apk && \
|
|
|
|
rm leveldb-$leveldb_version-r0.apk && \
|
|
|
|
rm hidapi-$hidapi_version-r0.apk
|
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
|
|
|
RUN adduser -S tezos && \
|
|
|
|
mkdir -p /var/run/tezos/node /var/run/tezos/client && \
|
|
|
|
chown -R tezos /var/run/tezos
|
2018-01-28 23:03:31 +04:00
|
|
|
|
2018-01-29 21:26:27 +04:00
|
|
|
USER tezos
|
2018-01-28 23:03:31 +04:00
|
|
|
|
2018-03-22 17:04:51 +04:00
|
|
|
ENV EDITOR=/usr/bin/vi
|
|
|
|
|
2018-01-29 21:26:27 +04:00
|
|
|
VOLUME /var/run/tezos/node
|
|
|
|
VOLUME /var/run/tezos/client
|
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
|
|
|
|
echo "### Succesfully build docker image: $image_name:$image_version"
|
|
|
|
echo
|