From c9703bdceb23fccb96167b24bb96b47a2c0eb65e Mon Sep 17 00:00:00 2001 From: Matej Sima Date: Thu, 23 May 2019 23:06:15 +0200 Subject: [PATCH 1/6] Add a Dockerfile, installer.sh and ligo.sh for easy ligo usage with Docker --- Makefile | 2 ++ docker/Dockerfile | 31 +++++++++++++++++++++++++++++++ docker/installer.sh | 16 ++++++++++++++++ docker/ligo.sh | 2 ++ 4 files changed, 51 insertions(+) create mode 100644 Makefile create mode 100644 docker/Dockerfile create mode 100644 docker/installer.sh create mode 100644 docker/ligo.sh diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..b8952598b --- /dev/null +++ b/Makefile @@ -0,0 +1,2 @@ +build-image: + docker build -t marigold/ligo ./docker \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 000000000..ca1d6bbf4 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,31 @@ +# We could use one of the nomadiclab's docker images as a base instead +# We're using 4.06 instead of 4.06.1, if this causes problems built a custom 4.06.1 image instead +FROM ocaml/opam2:4.06 + +USER root + +# Setup a custom opam repository where ligo is published +RUN git clone https://gitlab.com/gabriel.alfour/ligo-opam-repository +RUN opam repo add ligo-opam-repository ./ligo-opam-repository +RUN opam update ligo-opam-repository + +# Install required native dependencies +RUN apt-get -y install \ + libev-dev \ + perl \ + pkg-config \ + libgmp-dev \ + libhidapi-dev \ + m4 + +# Install ligo +RUN git clone https://gitlab.com/gabriel.alfour/ligo +RUN opam update + +RUN cd ligo/src && \ + opam install . --yes + +RUN eval $(opam env) + +# Use the ligo binary as a default command +ENTRYPOINT [ "/home/opam/.opam/4.06/bin/ligo" ] \ No newline at end of file diff --git a/docker/installer.sh b/docker/installer.sh new file mode 100644 index 000000000..698207b94 --- /dev/null +++ b/docker/installer.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# You can run this installer like this: +# curl https://gitlab.com/gabriel.alfour/ligo/blob/master/docker/installer.sh | bash +# Make sure the marigold/ligo image is published at docker hub first +echo "Installing LIGO" + +# Install the ligo.sh from master +wget https://gitlab.com/gabriel.alfour/ligo/blob/master/docker/ligo.sh + +# Copy the exucutable to the appropriate directory +sudo cp ligo.sh /usr/local/bin/ligo +sudo chmod +x /usr/local/bin/ligo +rm ligo.sh + +# Installation finished, try running 'ligo' from your CLI +echo "Installation successfull, try running 'ligo' now. \n" \ No newline at end of file diff --git a/docker/ligo.sh b/docker/ligo.sh new file mode 100644 index 000000000..246a2f08d --- /dev/null +++ b/docker/ligo.sh @@ -0,0 +1,2 @@ +#!/bin/bash +docker run -it -v $PWD:$PWD -w $PWD marigold/ligo $@ \ No newline at end of file From c1910629e940a15b64e83c7f6bbfdef0d84610d7 Mon Sep 17 00:00:00 2001 From: Matej Sima Date: Fri, 24 May 2019 00:13:31 +0200 Subject: [PATCH 2/6] Remove Makefile, Add docker build command to the CI config --- .gitlab-ci.yml | 4 ++++ Makefile | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) delete mode 100644 Makefile diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 366da11c4..31fa34e78 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -57,3 +57,7 @@ remote-repo-job: #- opam install -y merlin #- opam install -y ocp-indent #- opam user-setup install + +build-docker-image: + script: + - docker build -t marigold/ligo ./docker \ No newline at end of file diff --git a/Makefile b/Makefile deleted file mode 100644 index b8952598b..000000000 --- a/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -build-image: - docker build -t marigold/ligo ./docker \ No newline at end of file From 7c747b72e1b37497413259c8ae72bbc5d4b079b9 Mon Sep 17 00:00:00 2001 From: Matej Sima Date: Fri, 24 May 2019 00:25:48 +0200 Subject: [PATCH 3/6] Configure docker-in-docker for CI --- .gitlab-ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 31fa34e78..4f8e6d8fe 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,3 +1,9 @@ +image: docker:latest + +services: + - docker:dind + + variables: GIT_SUBMODULE_STRATEGY: recursive From 98d0d3ef4ac775a698f22bc883d93165011c99af Mon Sep 17 00:00:00 2001 From: Matej Sima Date: Fri, 24 May 2019 00:28:54 +0200 Subject: [PATCH 4/6] Remove the base docker:latest image from CI --- .gitlab-ci.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4f8e6d8fe..d6344f483 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,9 +1,6 @@ -image: docker:latest - services: - docker:dind - variables: GIT_SUBMODULE_STRATEGY: recursive From c7130e592bb234fe11a918f36bc35376d41c27b1 Mon Sep 17 00:00:00 2001 From: Matej Sima Date: Fri, 24 May 2019 00:40:04 +0200 Subject: [PATCH 5/6] Update docker configuration for CI --- .gitlab-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d6344f483..352ab8b39 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,3 @@ -services: - - docker:dind - variables: GIT_SUBMODULE_STRATEGY: recursive @@ -62,5 +59,8 @@ remote-repo-job: #- opam user-setup install build-docker-image: + image: docker:1.11 + services: + - docker:dind script: - docker build -t marigold/ligo ./docker \ No newline at end of file From a3e9af0e20493a1c25b5357ed003856607004294 Mon Sep 17 00:00:00 2001 From: Matej Sima Date: Fri, 24 May 2019 00:48:11 +0200 Subject: [PATCH 6/6] Extract before_script into a template that's not used for the docker build job --- .gitlab-ci.yml | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 352ab8b39..6ae3f1db7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,32 +1,33 @@ variables: GIT_SUBMODULE_STRATEGY: recursive -before_script: +.before_script: &before_script + before_script: + # Install dependencies + # rsync is needed by opam to sync a package installed from a local directory with the copy in ~/.opam + - apt-get update -qq + - apt-get -y -qq install rsync libhidapi-dev libcap-dev libev-dev bubblewrap + - wget https://github.com/ocaml/opam/releases/download/2.0.1/opam-2.0.1-x86_64-linux -O opam-2.0.1-x86_64-linux + - cp opam-2.0.1-x86_64-linux /usr/local/bin/opam + - chmod +x /usr/local/bin/opam + - export PATH="/usr/local/bin${PATH:+:}${PATH:-}" - # Install dependencies - # rsync is needed by opam to sync a package installed from a local directory with the copy in ~/.opam - - apt-get update -qq - - apt-get -y -qq install rsync libhidapi-dev libcap-dev libev-dev bubblewrap - - wget https://github.com/ocaml/opam/releases/download/2.0.1/opam-2.0.1-x86_64-linux -O opam-2.0.1-x86_64-linux - - cp opam-2.0.1-x86_64-linux /usr/local/bin/opam - - chmod +x /usr/local/bin/opam - - export PATH="/usr/local/bin${PATH:+:}${PATH:-}" + # Initialise opam + - printf '' | opam init --bare + - eval $(opam config env) - # Initialise opam - - printf '' | opam init --bare - - eval $(opam config env) + # Create switch + - printf '' | opam switch create toto ocaml-base-compiler.4.06.1 + - eval $(opam config env) - # Create switch - - printf '' | opam switch create toto ocaml-base-compiler.4.06.1 - - eval $(opam config env) - - # Show versions and current switch - - echo "$PATH" - - opam --version - - printf '' | ocaml - - opam switch + # Show versions and current switch + - echo "$PATH" + - opam --version + - printf '' | ocaml + - opam switch local-dune-job: + <<: *before_script script: - vendors/ligo-opam-repository/rewrite-local-opam-repository.sh - opam repository add localrepo "file://$PWD/vendors/ligo-opam-repository-local/" @@ -40,6 +41,7 @@ local-dune-job: # - src/ligo/bin/cli.ml local-repo-job: + <<: *before_script script: - vendors/ligo-opam-repository/rewrite-local-opam-repository.sh - opam repository add localrepo "file://$PWD/vendors/ligo-opam-repository-local/" @@ -47,6 +49,7 @@ local-repo-job: - opam install -y ligo remote-repo-job: + <<: *before_script script: # Add repository - opam repository add ligo-repository https://gitlab.com/gabriel.alfour/ligo-opam-repository.git