Added Dockerfiles for building and running tezos binaries
This commit is contained in:
parent
6efa84fa37
commit
87254788b9
20
scripts/Dockerfile.binaries.in
Normal file
20
scripts/Dockerfile.binaries.in
Normal file
@ -0,0 +1,20 @@
|
||||
FROM alpine:3.4
|
||||
# FIXME: I'm currently guessing the version of alpine that the opam image we've
|
||||
# built the tezos binaries on is based on. if that becomes newer (e.g. alpine
|
||||
# 3.5), the binaries built on that version of alpine could (will) depend on
|
||||
# library symbols that won't be in alpine 3.4
|
||||
|
||||
LABEL distro_style="apk" distro="alpine" distro_long="alpine-3.4" arch="x86_64" operatingsystem="linux"
|
||||
|
||||
RUN apk update && \
|
||||
apk upgrade && \
|
||||
apk add sudo bash libsodium gmp && \
|
||||
adduser -S tezos && \
|
||||
echo 'tezos ALL=(ALL:ALL) NOPASSWD:ALL' > /etc/sudoers.d/tezos && \
|
||||
chmod 440 /etc/sudoers.d/tezos && \
|
||||
chown root:root /etc/sudoers.d/tezos && \
|
||||
sed -i.bak 's/^Defaults.*requiretty//g' /etc/sudoers
|
||||
USER tezos
|
||||
|
||||
ADD built-bin /usr/local/bin
|
||||
WORKDIR /home/tezos
|
13
scripts/Dockerfile.build_bin.in
Normal file
13
scripts/Dockerfile.build_bin.in
Normal file
@ -0,0 +1,13 @@
|
||||
FROM tezos_build:$base_image
|
||||
|
||||
ADD tezos /home/opam/tezos
|
||||
ENV HOME /home/opam
|
||||
WORKDIR $HOME/tezos
|
||||
RUN sudo HOME="$HOME" opam config exec -- make clean && \
|
||||
sudo rm -fr ~/.opam/log && \
|
||||
sudo chown -R opam /home/opam
|
||||
RUN opam config exec -- make
|
||||
RUN mkdir -p ~/bin && \
|
||||
(cp tezos-client tezos-node tezos-protocol-compiler tezos-webclient ~/bin || true)
|
||||
|
||||
WORKDIR $HOME/bin
|
11
scripts/Dockerfile.build_deps.in
Normal file
11
scripts/Dockerfile.build_deps.in
Normal file
@ -0,0 +1,11 @@
|
||||
FROM ocaml/opam:$base_image
|
||||
COPY install_build_deps.sh /tmp
|
||||
COPY tezos-deps.opam /tmp/src/tezos-deps.opam
|
||||
WORKDIR /tmp
|
||||
RUN opam config exec -- ./install_build_deps.sh pin && rm -fr ~/.opam/log/
|
||||
USER root
|
||||
ENV HOME /home/opam
|
||||
RUN opam config exec -- ./install_build_deps.sh depext && rm -fr ~/.opam/log/
|
||||
RUN apk add libsodium-dev
|
||||
USER opam
|
||||
RUN opam config exec -- ./install_build_deps.sh all && rm -fr ~/.opam/log/
|
@ -1,32 +1,23 @@
|
||||
#! /bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
dir=$(mktemp -d)
|
||||
cur_dir="$(dirname "$(readlink -f "$0")")"
|
||||
dir="$(mktemp -d)"
|
||||
src_dir="$(dirname "$(readlink -f "$0")")"
|
||||
|
||||
image_name=${1:=tezos_build}
|
||||
ocaml_version=${2:=alpine_ocaml-4.03.0}
|
||||
image_version=$3
|
||||
image_name="${1:-tezos_build}"
|
||||
base_image="${2:-alpine_ocaml-4.03.0}"
|
||||
image_version="$3"
|
||||
|
||||
docker pull ocaml/opam:${ocaml_version}
|
||||
docker pull ocaml/opam:"$base_image"
|
||||
|
||||
cp ${cur_dir}/install_build_deps.sh ${dir}
|
||||
cp ${cur_dir}/../src/tezos-deps.opam ${dir}
|
||||
cat > ${dir}/Dockerfile <<EOF
|
||||
FROM ocaml/opam:${ocaml_version}
|
||||
COPY install_build_deps.sh /tmp
|
||||
COPY tezos-deps.opam /tmp/src/tezos-deps.opam
|
||||
RUN cd /tmp && opam config exec -- ./install_build_deps.sh pin \
|
||||
&& rm -fr ~/.opam/log/
|
||||
USER root
|
||||
ENV HOME /home/opam
|
||||
RUN cd /tmp && opam config exec -- ./install_build_deps.sh depext \
|
||||
&& rm -fr ~/.opam/log/
|
||||
RUN apk add libsodium-dev
|
||||
USER opam
|
||||
RUN cd /tmp && opam config exec -- ./install_build_deps.sh install \
|
||||
&& rm -fr ~/.opam/log/
|
||||
EOF
|
||||
cd "$dir"
|
||||
|
||||
docker build -t ${image_name}:${ocaml_version}${image_version} ${dir}
|
||||
cp "$src_dir"/install_build_deps.sh "$dir"
|
||||
cp "$src_dir"/../src/tezos-deps.opam "$dir"
|
||||
|
||||
cp "$src_dir"/Dockerfile.build_deps.in "$dir"
|
||||
sed Dockerfile.build_deps.in -e 's/$base_image/'"$base_image"'/g' > Dockerfile.build_deps
|
||||
|
||||
docker build -f Dockerfile.build_deps -t "$image_name:$base_image$image_version" "$dir"
|
||||
|
41
scripts/create_docker_with_binaries.sh
Executable file
41
scripts/create_docker_with_binaries.sh
Executable file
@ -0,0 +1,41 @@
|
||||
#! /bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
dir="$(mktemp -d)"
|
||||
src_dir="$(dirname "$(readlink -f "$0")")"
|
||||
|
||||
image_name="${1:-tezos_build}"
|
||||
base_image="${2:-alpine_ocaml-4.03.0}"
|
||||
image_version="$3"
|
||||
|
||||
tezos_build_img="tezos_build:$base_image"
|
||||
|
||||
if ! (docker images | grep -- "^tezos_build \+$base_image "); then
|
||||
echo "Docker image not found: $tezos_build_img" >&2
|
||||
echo "Aborting" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "$dir"
|
||||
|
||||
git clone "$src_dir"/.. "$dir"/tezos
|
||||
rm -fr "$dir"/tezos/.git
|
||||
|
||||
cp "$src_dir"/Dockerfile.build_bin.in "$dir"
|
||||
sed Dockerfile.build_bin.in -e 's/$base_image/'"$base_image"'/g' > Dockerfile.build_bin
|
||||
|
||||
docker build -f Dockerfile.build_bin -t "tezos_build_bin:$base_image$image_version" "$dir"
|
||||
|
||||
mkdir -p "$dir"/built-bin
|
||||
docker run -i --rm -v "$dir"/built-bin:/built-bin "tezos_build_bin:$base_image$image_version" /bin/bash << EOF
|
||||
sudo cp -v /home/opam/bin/tezos-* /built-bin/
|
||||
sudo chown opam:nogroup /built-bin/tezos-*
|
||||
sudo chmod a+rwx /built-bin/tezos-*
|
||||
EOF
|
||||
|
||||
cp "$src_dir"/Dockerfile.binaries.in "$dir"
|
||||
sed Dockerfile.binaries.in -e 's/$base_image/'"$base_image"'/g' > Dockerfile.binaries
|
||||
|
||||
docker build -f Dockerfile.binaries -t "tezos_binaries:$base_image$image_version" "$dir"
|
@ -1,38 +1,35 @@
|
||||
#! /bin/sh
|
||||
|
||||
if ! [ -f 'src/tezos-deps.opam' ]; then
|
||||
echo
|
||||
echo " Please run from the project's root directory. Aborting."
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ocaml_version=4.03.0
|
||||
if [ "$(ocaml -vnum)" != "$ocaml_version" ]; then
|
||||
echo
|
||||
echo " Unexpected compiler version ($(ocaml -vnum))"
|
||||
echo " You should use ocaml-$ocaml_version."
|
||||
echo
|
||||
exit 1
|
||||
OCAML_VERSION=4.03.0
|
||||
if [ "$(ocaml -vnum)" != "$OCAML_VERSION" ]; then
|
||||
echo ;
|
||||
echo " Unexpected compiler version ($(ocaml -vnum))";
|
||||
echo " You should use ocaml-$OCAML_VERSION.";
|
||||
echo ;
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
cmd="$1"
|
||||
if [ -z "$cmd" ]; then cmd=all; fi
|
||||
|
||||
case "$cmd" in
|
||||
pin=false
|
||||
depext=false
|
||||
install=false
|
||||
|
||||
case $cmd in
|
||||
pin)
|
||||
pin=yes
|
||||
pin=true
|
||||
;;
|
||||
depext)
|
||||
depext=yes
|
||||
depext=true
|
||||
;;
|
||||
install)
|
||||
install=yes
|
||||
install=true
|
||||
;;
|
||||
all)
|
||||
pin=yes
|
||||
depext=yes
|
||||
install=yes
|
||||
pin=true
|
||||
depext=true
|
||||
install=true
|
||||
;;
|
||||
*)
|
||||
echo "Unknown command '$cmd'."
|
||||
@ -43,7 +40,7 @@ esac
|
||||
set -e
|
||||
set -x
|
||||
|
||||
if ! [ -z "$pin" ]; then
|
||||
if "$pin"; then
|
||||
opam pin --yes remove --no-action --dev-repo ocplib-resto || true
|
||||
opam pin --yes add --no-action --dev-repo sodium
|
||||
opam pin --yes add --no-action --dev-repo ocp-ocamlres
|
||||
@ -56,15 +53,15 @@ if ! [ -z "$pin" ]; then
|
||||
opam pin --yes add --no-action tezos-deps src
|
||||
fi
|
||||
|
||||
if ! [ -z "$depext" ]; then
|
||||
## In our CI, this rule is executed as user 'root'
|
||||
## The other rules are executed as user 'opam'.
|
||||
if "$depext"; then
|
||||
opam list --installed depext || opam install depext
|
||||
opam depext tezos-deps
|
||||
opam depext $DEPEXTOPT tezos-deps
|
||||
fi
|
||||
|
||||
if ! [ -z "$install" ]; then
|
||||
if "$install"; then
|
||||
if opam list --installed tezos-deps ; then
|
||||
opam upgrade $(opam list -s --required-by tezos-deps | grep -ve '^ocaml *$')
|
||||
else
|
||||
opam install tezos-deps
|
||||
## This seems broken in the current opam-repo (2016-12-09)
|
||||
## opam install --build-test tezos-deps
|
||||
fi
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user