Refactor docker image structure & CI
This commit is contained in:
parent
80c693a5af
commit
5feba725cb
@ -1,6 +1,16 @@
|
|||||||
variables:
|
variables:
|
||||||
GIT_SUBMODULE_STRATEGY: recursive
|
GIT_SUBMODULE_STRATEGY: recursive
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- test
|
||||||
|
- build
|
||||||
|
- deploy
|
||||||
|
|
||||||
|
.docker: &docker
|
||||||
|
image: docker:1.11
|
||||||
|
services:
|
||||||
|
- docker:dind
|
||||||
|
|
||||||
.before_script: &before_script
|
.before_script: &before_script
|
||||||
before_script:
|
before_script:
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
@ -28,6 +38,7 @@ variables:
|
|||||||
|
|
||||||
local-dune-job:
|
local-dune-job:
|
||||||
<<: *before_script
|
<<: *before_script
|
||||||
|
stage: test
|
||||||
script:
|
script:
|
||||||
- vendors/opam-repository-tools/rewrite-local-opam-repository.sh
|
- vendors/opam-repository-tools/rewrite-local-opam-repository.sh
|
||||||
- opam repository add localrepo "file://$PWD/vendors/ligo-opam-repository-local-generated/"
|
- opam repository add localrepo "file://$PWD/vendors/ligo-opam-repository-local-generated/"
|
||||||
@ -42,6 +53,7 @@ local-dune-job:
|
|||||||
|
|
||||||
local-repo-job:
|
local-repo-job:
|
||||||
<<: *before_script
|
<<: *before_script
|
||||||
|
stage: test
|
||||||
script:
|
script:
|
||||||
- vendors/opam-repository-tools/rewrite-local-opam-repository.sh
|
- vendors/opam-repository-tools/rewrite-local-opam-repository.sh
|
||||||
- opam repository add localrepo "file://$PWD/vendors/ligo-opam-repository-local-generated/"
|
- opam repository add localrepo "file://$PWD/vendors/ligo-opam-repository-local-generated/"
|
||||||
@ -50,6 +62,7 @@ local-repo-job:
|
|||||||
|
|
||||||
remote-repo-job:
|
remote-repo-job:
|
||||||
<<: *before_script
|
<<: *before_script
|
||||||
|
stage: test
|
||||||
script:
|
script:
|
||||||
# Add repository
|
# Add repository
|
||||||
- opam repository add ligo-repository https://gitlab.com/ligolang/ligo.git
|
- opam repository add ligo-repository https://gitlab.com/ligolang/ligo.git
|
||||||
@ -61,9 +74,24 @@ remote-repo-job:
|
|||||||
#- opam install -y ocp-indent
|
#- opam install -y ocp-indent
|
||||||
#- opam user-setup install
|
#- opam user-setup install
|
||||||
|
|
||||||
build-docker-image:
|
# Run a docker build on the ligo image, to see if the current
|
||||||
image: docker:1.11
|
# commit does not break it
|
||||||
services:
|
build-current-docker-image:
|
||||||
- docker:dind
|
stage: build
|
||||||
|
<<: *docker
|
||||||
script:
|
script:
|
||||||
- docker build -t marigold/ligo ./docker
|
- docker build -t $CI_REGISTRY_IMAGE -f ./docker/Dockerfile .
|
||||||
|
|
||||||
|
# When a MR/PR is merged to master
|
||||||
|
# take the previous build and publish it to Docker Hub
|
||||||
|
build-and-publish-latest-docker-image:
|
||||||
|
stage: deploy
|
||||||
|
<<: *docker
|
||||||
|
dependencies:
|
||||||
|
- build-current-docker-image
|
||||||
|
before_script:
|
||||||
|
- docker login -u $CI_REGISTRY_USER -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
||||||
|
script:
|
||||||
|
- docker push $CI_REGISTRY_IMAGE:latest
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
@ -1,31 +1,31 @@
|
|||||||
# We could use one of the nomadiclab's docker images as a base instead
|
# 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
|
# We're using 4.06 instead of 4.06.1, if this causes problems build a custom 4.06.1 image instead
|
||||||
FROM ocaml/opam2:4.06
|
FROM ocaml/opam2:4.06
|
||||||
|
|
||||||
USER root
|
USER root
|
||||||
|
|
||||||
|
# Add contents of the current directory to /ligo where it can be
|
||||||
|
# accessed when building the image.
|
||||||
|
#
|
||||||
|
# This is useful when building either locally, or on the CI
|
||||||
|
# because the currently checkout out version (from git) will be used
|
||||||
|
# to build the image
|
||||||
|
ADD . /ligo
|
||||||
|
|
||||||
|
# Set the current working directory to /ligo for
|
||||||
|
# the upcoming scripts
|
||||||
|
WORKDIR /ligo
|
||||||
|
|
||||||
# Setup a custom opam repository where ligo is published
|
# Setup a custom opam repository where ligo is published
|
||||||
RUN git clone https://gitlab.com/ligolang/ligo.git
|
RUN sh scripts/setup_ligo_opam_repository.sh
|
||||||
RUN (cd ligo; vendors/opam-repository-tools/rewrite-local-opam-repository.sh)
|
|
||||||
RUN opam repo add ligo-opam-repository ./ligo/vendors/ligo-opam-repository-local-generated/
|
|
||||||
RUN opam update ligo-opam-repository
|
|
||||||
|
|
||||||
# Install required native dependencies
|
# Install required native dependencies
|
||||||
RUN apt-get -y install \
|
RUN sh scripts/install_native_dependencies.sh
|
||||||
libev-dev \
|
|
||||||
perl \
|
|
||||||
pkg-config \
|
|
||||||
libgmp-dev \
|
|
||||||
libhidapi-dev \
|
|
||||||
m4
|
|
||||||
|
|
||||||
# Install ligo
|
|
||||||
RUN opam update
|
RUN opam update
|
||||||
|
|
||||||
RUN cd ligo/src && \
|
# Install ligo
|
||||||
opam install . --yes
|
RUN sh scripts/install_ligo_with_dependencies.sh
|
||||||
|
|
||||||
RUN eval $(opam env)
|
|
||||||
|
|
||||||
# Use the ligo binary as a default command
|
# Use the ligo binary as a default command
|
||||||
ENTRYPOINT [ "/home/opam/.opam/4.06/bin/ligo" ]
|
ENTRYPOINT [ "/home/opam/.opam/4.06/bin/ligo" ]
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker run -it -v $PWD:$PWD -w $PWD marigold/ligo $@
|
|
1
scripts/build_docker_image.sh
Executable file
1
scripts/build_docker_image.sh
Executable file
@ -0,0 +1 @@
|
|||||||
|
docker build -t ligolang/ligo -f docker/Dockerfile .
|
1
scripts/install_ligo_with_dependencies.sh
Executable file
1
scripts/install_ligo_with_dependencies.sh
Executable file
@ -0,0 +1 @@
|
|||||||
|
cd src && opam install . --yes
|
7
scripts/install_native_dependencies.sh
Executable file
7
scripts/install_native_dependencies.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
apt-get -y install \
|
||||||
|
libev-dev \
|
||||||
|
perl \
|
||||||
|
pkg-config \
|
||||||
|
libgmp-dev \
|
||||||
|
libhidapi-dev \
|
||||||
|
m4
|
9
docker/installer.sh → scripts/installer.sh
Normal file → Executable file
9
docker/installer.sh → scripts/installer.sh
Normal file → Executable file
@ -1,11 +1,12 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# You can run this installer like this:
|
# You can run this installer like this:
|
||||||
# curl https://gitlab.com/gabriel.alfour/ligo/blob/master/docker/installer.sh | bash
|
# curl https://gitlab.com/gabriel.alfour/ligo/blob/master/scripts/installer.sh | bash
|
||||||
# Make sure the marigold/ligo image is published at docker hub first
|
# Make sure the marigold/ligo image is published at docker hub first
|
||||||
|
set -euET -o pipefail
|
||||||
echo "Installing LIGO"
|
echo "Installing LIGO"
|
||||||
|
|
||||||
# Install the ligo.sh from master
|
# Install the ligo.sh from master
|
||||||
wget https://gitlab.com/gabriel.alfour/ligo/blob/master/docker/ligo.sh
|
wget https://gitlab.com/gabriel.alfour/ligo/blob/master/scripts/ligo.sh
|
||||||
|
|
||||||
# Copy the exucutable to the appropriate directory
|
# Copy the exucutable to the appropriate directory
|
||||||
sudo cp ligo.sh /usr/local/bin/ligo
|
sudo cp ligo.sh /usr/local/bin/ligo
|
||||||
@ -13,4 +14,4 @@ sudo chmod +x /usr/local/bin/ligo
|
|||||||
rm ligo.sh
|
rm ligo.sh
|
||||||
|
|
||||||
# Installation finished, try running 'ligo' from your CLI
|
# Installation finished, try running 'ligo' from your CLI
|
||||||
echo "Installation successfull, try running 'ligo' now. \n"
|
echo "Installation successful, try running 'ligo' now. \n"
|
2
scripts/ligo.sh
Executable file
2
scripts/ligo.sh
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
docker run -it -v "$PWD":"$PWD" -w "$PWD" ligolang/ligo "$@"
|
3
scripts/setup_ligo_opam_repository.sh
Executable file
3
scripts/setup_ligo_opam_repository.sh
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
vendors/opam-repository-tools/rewrite-local-opam-repository.sh
|
||||||
|
opam repo add ligo-opam-repository ./vendors/ligo-opam-repository-local-generated
|
||||||
|
opam update ligo-opam-repository
|
Loading…
Reference in New Issue
Block a user