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)
|
|
|
|
|
|
|
|
cleanup () {
|
|
|
|
set +e
|
|
|
|
echo Cleaning up...
|
|
|
|
rm -rf "$tmp_dir"
|
|
|
|
}
|
|
|
|
trap cleanup EXIT INT
|
|
|
|
|
2018-06-05 19:57:03 +04:00
|
|
|
"$ci_dir"/create_apk.hidapi.sh
|
2018-01-28 23:03:31 +04:00
|
|
|
"$ci_dir"/create_binary.opam.sh
|
|
|
|
"$ci_dir"/create_opam_repository.tezos_deps.sh
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "### Building base image..."
|
|
|
|
echo
|
|
|
|
|
|
|
|
image_name="${1:-tezos_opam}"
|
|
|
|
image_version="${2:-alpine-${alpine_version}_ocaml-${ocaml_version}}"
|
|
|
|
|
2018-06-05 19:57:03 +04:00
|
|
|
cp -a "$build_dir"/hidapi-$hidapi_version-r0.apk \
|
|
|
|
"$build_dir"/hidapi-dev-$hidapi_version-r0.apk \
|
|
|
|
"$build_dir"/keys/ \
|
|
|
|
"$tmp_dir"
|
|
|
|
|
2018-01-28 23:03:31 +04:00
|
|
|
cp "$build_dir"/opam-$opam_tag "$tmp_dir/opam"
|
|
|
|
cp "$build_dir"/opam-installer-$opam_tag "$tmp_dir/opam-installer"
|
|
|
|
|
2018-06-27 14:58:06 +04:00
|
|
|
tar -C "$tmp_dir" -xzf "$build_dir"/opam_repository-tezos_deps-$ocaml_version-$opam_repository_tag.tgz
|
2018-01-28 23:03:31 +04:00
|
|
|
|
|
|
|
cat <<EOF > "$tmp_dir"/Dockerfile
|
|
|
|
FROM alpine:$alpine_version
|
|
|
|
|
|
|
|
COPY opam /usr/bin/opam
|
|
|
|
COPY opam-installer /usr/bin/opam-installer
|
|
|
|
|
|
|
|
COPY keys /etc/apk/keys/
|
2018-06-05 19:57:03 +04:00
|
|
|
COPY hidapi-$hidapi_version-r0.apk .
|
|
|
|
COPY hidapi-dev-$hidapi_version-r0.apk .
|
|
|
|
|
2018-01-28 23:03:31 +04:00
|
|
|
|
|
|
|
RUN apk --no-cache add \
|
|
|
|
build-base bash perl xz m4 git curl tar rsync patch sudo jq \
|
2018-04-27 11:43:29 +04:00
|
|
|
ncurses-dev gmp-dev libev-dev \
|
|
|
|
pcre-dev zlib-dev \
|
2018-01-28 23:03:31 +04:00
|
|
|
snappy snappy-dev \
|
2018-06-05 19:57:03 +04:00
|
|
|
hidapi-$hidapi_version-r0.apk \
|
|
|
|
hidapi-dev-$hidapi_version-r0.apk && \
|
2018-01-28 23:03:31 +04:00
|
|
|
adduser -S opam && \
|
|
|
|
echo 'opam ALL=(ALL:ALL) NOPASSWD:ALL' > /etc/sudoers.d/opam && \
|
|
|
|
chmod 440 /etc/sudoers.d/opam && \
|
|
|
|
chown root:root /etc/sudoers.d/opam && \
|
|
|
|
sed -i.bak 's/^Defaults.*requiretty//g' /etc/sudoers
|
|
|
|
USER opam
|
|
|
|
|
|
|
|
WORKDIR /home/opam
|
|
|
|
|
|
|
|
COPY opam_repository-tezos_deps opam-repository-tezos_deps
|
|
|
|
|
|
|
|
RUN mkdir ~/.ssh && \
|
|
|
|
chmod 700 ~/.ssh && \
|
|
|
|
git config --global user.email "ci@tezos.com" && \
|
|
|
|
git config --global user.name "Tezos CI" && \
|
2018-06-27 14:58:06 +04:00
|
|
|
opam init --disable-sandboxing --bare --no-setup --yes \
|
2018-01-28 23:03:31 +04:00
|
|
|
tezos_deps /home/opam/opam-repository-tezos_deps && \
|
2018-06-27 14:58:06 +04:00
|
|
|
opam switch create --yes /home/opam/tezos ocaml-base-compiler.${ocaml_version}
|
2018-01-28 23:03:31 +04:00
|
|
|
|
2018-06-27 14:58:06 +04:00
|
|
|
RUN opam install --switch=/home/opam/tezos --yes opam-depext
|
2018-01-28 23:03:31 +04:00
|
|
|
|
2018-06-28 01:49:57 +04:00
|
|
|
ENTRYPOINT [ "opam", "exec", "--set-switch", "--switch=/home/opam/tezos", "--" ]
|
2018-01-28 23:03:31 +04:00
|
|
|
CMD [ "/bin/bash" ]
|
|
|
|
EOF
|
|
|
|
|
|
|
|
docker build --pull -t "$image_name:$image_version" "$tmp_dir"
|