From a73b4ae7fd1ecdf9d51a06a466b5cda3c7986631 Mon Sep 17 00:00:00 2001
From: Florian <florian.gacon@inria.fr>
Date: Thu, 1 Oct 2020 14:54:37 +0200
Subject: [PATCH] Add docker build job

---
 .dockerignore  |  1 +
 .gitlab-ci.yml | 22 ++++++++++++++++++++++
 Dockerfile     | 40 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 63 insertions(+)
 create mode 100644 .dockerignore
 create mode 100644 Dockerfile

diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..11041c7
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1 @@
+*.egg-info
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 838d3e5..1b206dc 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -19,6 +19,7 @@ default:
 conda_build:
   stage: build
   before_script:
+    - echo skip before_script
   script:
   - conda update -n base -c defaults conda
   - conda install conda-build git anaconda-client conda-verify
@@ -54,6 +55,7 @@ coverage:
 anaconda_master :
   stage: deploy
   before_script:
+    - echo skip before_script
   script:
   - conda update -n base -c defaults conda
   - conda update --all
@@ -70,6 +72,7 @@ anaconda_master :
 anaconda_develop :
   stage: deploy
   before_script:
+    - echo skip before_script
   script:
   - conda update -n base -c defaults conda
   - conda update --all
@@ -101,3 +104,22 @@ pages:
   only:
   - develop
   - master
+
+
+docker_build_deploy:
+  image: docker:latest
+  stage: deploy
+  services:
+    - docker:dind
+  variables:
+    IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
+  script:
+    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
+    - docker build -t $IMAGE_TAG .
+    - docker push $IMAGE_TAG
+  retry:
+    max: 2
+    when: runner_system_failure
+  only:
+  - develop
+  - master
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..62774ce
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,40 @@
+# To build:
+# docker build -t bvpy .
+
+# To run:
+# docker run -it bvpy
+
+# To purge build:
+# docker rm $(docker ps -a -q)
+
+# To purge images:
+# docker images -a | grep "pattern" | awk '{print $3}' | xargs docker rmi
+
+FROM continuumio/miniconda3
+
+MAINTAINER Florian Gacon <florian.gacon@inria.fr>
+
+USER root
+
+SHELL ["/bin/bash","--login", "-c"]
+
+COPY src /opt/bvpy/src
+COPY setup.py /opt/bvpy
+COPY README.rst /opt/bvpy
+COPY HISTORY.rst /opt/bvpy
+COPY conda/env.yaml /opt/bvpy
+
+WORKDIR /home/bvpy
+
+ENV CONDA_DIR=/opt/conda
+ENV PATH /opt/conda/envs/bvpy/bin:$PATH
+
+RUN conda init bash && \
+    conda update -n base -c defaults conda && \
+    conda env create -f /opt/bvpy/env.yaml && \
+    echo "source activate bvpy" > ~/.bashrc && \
+    source /root/.bashrc && \
+    cd /opt/bvpy && python setup.py install && \
+    conda clean -afy
+
+CMD ["/bin/bash", "-c""]
-- 
GitLab