From ed6aad8df62d330cf4800af8b76392a42b86be50 Mon Sep 17 00:00:00 2001
From: Tru Huynh <tru@pasteur.fr>
Date: Wed, 1 Mar 2023 16:43:17 +0100
Subject: [PATCH] CI with singularity image

---
 .gitlab-ci.yml | 26 +++++++++++++-------------
 README.md      | 12 ++++++++++++
 Singularity    | 22 ++++++++++++++++++++++
 3 files changed, 47 insertions(+), 13 deletions(-)
 create mode 100644 Singularity

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ea38b8a..d76b6a2 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -10,18 +10,18 @@ docker:
   script:
     - docker login -u gitlab-ci-token -p "$CI_BUILD_TOKEN" registry-gitlab.pasteur.fr
     - export  MY_TIME=`date +"%F-%H%M"`
-    - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_BUILD_REF_NAME" -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA" -t "$CI_REGISTRY_IMAGE:latest" -t "$CI_REGISTRY_IMAGE:$MY_TIME" .  -f Dockerfile
+    - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_BUILD_REF_NAME" -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA"  -t "$CI_REGISTRY_IMAGE:$MY_TIME" .  -f Dockerfile
     - docker push "$CI_REGISTRY_IMAGE"
 
-#singularity:
-#  stage: build
-#  image:
-#    name: quay.io/singularity/singularity:v3.11.0
-#    entrypoint: [""]
-#  script:
-#    - singularity build singularity.sif Singularity
-#    - ls -lh singularity.sif
-#    - singularity push --docker-username "${CI_REGISTRY_USER}" --docker-password "${CI_REGISTRY_PASSWORD}" singularity.sif oras://"$CI_REGISTRY_IMAGE":latest
-#  artifacts:
-#    paths:
-#    - singularity.sif
+singularity:
+  stage: build
+  image:
+    name: quay.io/singularity/singularity:v3.11.0
+    entrypoint: [""]
+  script:
+    - singularity build singularity.sif Singularity
+    - ls -lh singularity.sif
+    - singularity push --docker-username "${CI_REGISTRY_USER}" --docker-password "${CI_REGISTRY_PASSWORD}" singularity.sif oras://"$CI_REGISTRY_IMAGE":latest
+  artifacts:
+    paths:
+    - singularity.sif
diff --git a/README.md b/README.md
index 4561cf6..1823728 100644
--- a/README.md
+++ b/README.md
@@ -15,3 +15,15 @@
 - cuda-nsight-compute
 - nsight-compute
 - cuda-demo-suite
+
+ # usage
+
+docker:
+```
+docker run -ti docker://registry-gitlab.pasteur.fr/tru/miniconda3-python310-pytorch-cuda11.7:main
+```
+
+singularity/apptainer:
+```
+singularity build miniconda3-python310-pytorch-cuda11.7.sif oras://registry-gitlab.pasteur.fr/tru/miniconda3-python310-pytorch-cuda11.7:latest
+```
diff --git a/Singularity b/Singularity
new file mode 100644
index 0000000..d2fffe0
--- /dev/null
+++ b/Singularity
@@ -0,0 +1,22 @@
+Bootstrap: docker
+From: continuumio/miniconda3
+
+# update conda and the OS
+conda update conda && \
+conda upgrade --all -y && \
+apt-get update && \
+apt-get -y install curl && \
+DEBIAN_FRONTEND=noninteractive apt-get -y upgrade && \
+DEBIAN_FRONTEND=noninteractive apt-get -y autoremove && \
+DEBIAN_FRONTEND=noninteractive apt-get -y clean autoclean
+
+# download the yml file
+curl https://gitlab.pasteur.fr/tru/miniconda3-python310-pytorch-cuda11.7/-/raw/main/conda-env-export.yml > conda-env-export.yml && \
+conda create --name py310-pytorch --file conda-env-export.yml && \
+eval "$(conda shell.bash hook)"  && \
+conda activate py310-pytorch  && \
+conda list --explicit > /tmp/conda-list--explicit.yml
+
+
+
+
-- 
GitLab