From 3ee46c59bee293c322ed3679321d8a7e22d70dce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Wed, 6 Dec 2017 23:03:27 +0100 Subject: [PATCH] CI: add support for opam2-beta5 --- .gitlab-ci.yml | 18 ++++++- scripts/Dockerfile.alpine.opam2.in | 60 +++++++++++++++++++++ scripts/create_docker_image.alpine.opam2.sh | 33 ++++++++++++ 3 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 scripts/Dockerfile.alpine.opam2.in create mode 100755 scripts/create_docker_image.alpine.opam2.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cbc7101ec..86be2085d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -25,7 +25,7 @@ stages: ## Prepare docker image with precompiled OCaml/opam -prepare: +prepare:opam: <<: *dind_definition stage: prepare only: @@ -41,6 +41,22 @@ prepare: "tezos/opam:latest" - docker push "tezos/opam:latest" +prepare:opam2: + <<: *dind_definition + stage: prepare + only: + - schedules + before_script: + - . ./scripts/version.sh + script: + - ./scripts/create_docker_image.alpine.opam2.sh + - mkdir ~/.docker || true + - echo "$CI_DOCKER_AUTH" > ~/.docker/config.json ; + - docker push "tezos/opam2:alpine-${alpine_version}_ocaml-${ocaml_version}" + - docker tag "tezos/opam2:alpine-${alpine_version}_ocaml-${ocaml_version}" + "tezos/opam2:latest" + - docker push "tezos/opam2:latest" + ## Tezos build: diff --git a/scripts/Dockerfile.alpine.opam2.in b/scripts/Dockerfile.alpine.opam2.in new file mode 100644 index 000000000..3d8a92d86 --- /dev/null +++ b/scripts/Dockerfile.alpine.opam2.in @@ -0,0 +1,60 @@ +## Based on https://github.com/ocaml/opam-dockerfiles + +FROM alpine:$alpine_version + +RUN apk update && apk upgrade && \ + apk add build-base snappy-dev abuild alpine-sdk \ + openssh bash nano ncurses-dev rsync xz m4 \ + ocaml \ + gmp-dev libev-dev libressl-dev linux-headers pcre-dev perl zlib-dev \ + libsodium-dev && \ + rm -f /var/cache/apk/* && \ + adduser -S opam && \ + adduser opam abuild && \ + 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 + +RUN mkdir ~/.ssh && \ + chmod 700 ~/.ssh && \ + git config --global user.email "docker@example.com" && \ + git config --global user.name "Docker CI" && \ + cd /home/opam && \ + git clone -b "$opam_tag" git://github.com/ocaml/opam && \ + cd /home/opam/opam && \ + ./configure --prefix /usr && \ + make lib-ext && \ + make opam && \ + sudo cp -L opam /usr/bin/opam && \ + cd /home/opam && \ + sudo -u opam sh -c "git clone -b master git://github.com/ocaml/opam-repository" && \ + cd opam-repository && \ + sudo -u opam sh -c "cd /home/opam/opam-repository && opam admin upgrade && git checkout -b v2 && git add . && git commit -a -m 'opam admin upgrade'" && \ + sudo -u opam sh -c "opam init -a -y --comp $ocaml_version /home/opam/opam-repository" && \ + sudo -u opam sh -c "opam install -y depext travis-opam" && \ + cd /home/opam/opam && \ + make opam-installer && \ + sudo cp -L opam-installer /usr/bin/opam-installer && \ + rm -r /home/opam/opam + +COPY scripts/leveldb-1.18.APKBUILD /home/opam/leveldb-1.18/APKBUILD +RUN sudo chown -R opam leveldb-1.18 + +RUN sudo apk update && \ + abuild-keygen -ai && \ + cd leveldb-1.18 && \ + abuild checksum && abuild -r && \ + cd .. && \ + sudo apk add packages/opam/x86_64/leveldb-1.18-r0.apk && \ + sudo apk add packages/opam/x86_64/leveldb-dev-1.18-r0.apk && \ + rm -rf leveldb-1.18 packages && \ + sudo rm -f /var/cache/apk/* + +ENTRYPOINT [ "opam", "config", "exec", "--" ] + +CMD [ "sh" ] diff --git a/scripts/create_docker_image.alpine.opam2.sh b/scripts/create_docker_image.alpine.opam2.sh new file mode 100755 index 000000000..f73901f6c --- /dev/null +++ b/scripts/create_docker_image.alpine.opam2.sh @@ -0,0 +1,33 @@ +#! /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/opam2}" +image_version="${2:-alpine-${alpine_version}_ocaml-${ocaml_version}}" + +cleanup () { + set +e + echo Cleaning up... + rm -rf Dockerfile +} +trap cleanup EXIT INT + +opam_tag=2.0.0-beta5 + +sed scripts/Dockerfile.alpine.opam2.in \ + -e 's|$alpine_version|'"$alpine_version"'|g' \ + -e 's|$ocaml_version|'"$ocaml_version"'|g' \ + -e 's|$opam_tag|'"$opam_tag"'|g' > Dockerfile + +echo +echo "### Building base image..." +echo + +docker build --pull -t "$image_name:$image_version" . + +rm Dockerfile