From f9d31311d892953755fcd02827135a33d6f16cd9 Mon Sep 17 00:00:00 2001
From: Wittmann Gregory <gregory.wittmann4@etu.univ-lorraine.fr>
Date: Mon, 8 Jan 2024 17:29:29 +0100
Subject: [PATCH] Modification docker et pipline

---
 .gitlab-ci.yml        | 25 +++++++++++++++----------
 calculVolumeSphere.py | 16 +++++++++-------
 dockerfile            |  4 ++--
 3 files changed, 26 insertions(+), 19 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index e09942c..c76f086 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,25 +1,30 @@
 stages:
   - lint
   - test
-  - build
+  - deploy
 
 variables:
-  PYTEST_FLAGS: "-v"
+  IMAGE_NAME: imagesphere  # Remplacez par le nom réel de votre image Docker
 
 lint:
   stage: lint
   script:
-    - pip install flake8
-    - flake8 calculVolumeSphere.py
+    - apt-get update -qy
+    - apt-get install -y python3-pip
+    - pip3 install flake8
+    - flake8 sphère.py
 
 test:
   stage: test
   script:
-    - pip install -r requirements.txt
-    - pip install pytest
-    - pytest test_sphère.py
+    - apt-get update -qy
+    - apt-get install -y python3-pip
+    - pip3 install -r requirements.txt
+    - python3 -m pytest test_sphère.py
 
-build:
-  stage: build
+deploy:
+  stage: deploy
+  only:
+    - master
   script:
-    - docker build -t EvalSpherePython .
\ No newline at end of file
+    - echo echo "Les étapes de déploiement seront définies ultérieurement."
\ No newline at end of file
diff --git a/calculVolumeSphere.py b/calculVolumeSphere.py
index 22437ec..a8a29d8 100644
--- a/calculVolumeSphere.py
+++ b/calculVolumeSphere.py
@@ -1,5 +1,4 @@
-# sphère.py
-
+import os
 import math
 
 def calculer_volume_sphere(rayon):
@@ -12,13 +11,16 @@ def calculer_volume_sphere(rayon):
 def enregistrer_resultat_fichier(volume, fichier):
     with open(fichier, 'w') as f:
         f.write(f"{volume}")
-
+        
 def main():
-    rayon = float(input("Rayon de la sphère en cm : "))
-    volume = calculer_volume_sphere(rayon)
+    # Obtenez le rayon à partir de la variable d'environnement
+    rayon_str = os.environ.get("RAYON_SPHERE")
+    if rayon_str is None:
+        raise ValueError("La variable d'environnement RAYON_SPHERE n'est pas définie.")
     
-    # Enregistrement du résultat dans un fichier texte
+    rayon = float(rayon_str)
+    volume = calculer_volume_sphere(rayon)
     enregistrer_resultat_fichier(volume, "volume.txt")
 
 if __name__ == '__main__':
-    main()
\ No newline at end of file
+    main()
diff --git a/dockerfile b/dockerfile
index 8fb5618..c5e8fd1 100644
--- a/dockerfile
+++ b/dockerfile
@@ -5,10 +5,10 @@ FROM python:3.8
 RUN apt-get update -y && apt-get install -y python3-pip
 
 # Copiez les fichiers nécessaires dans le conteneur
-COPY calculVolumeSphere.py requirements.txt ./
+COPY calculVolumeSphere.py ./
 
 # Installez les dépendances
-RUN pip3 install -r requirements.txt
+RUN pip3 install Flask
 
 # Exposez le port 9090
 EXPOSE 9090
-- 
GitLab