diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e09942c6bb32bebd9a112d3b407af3d5fb6563ed..c76f0864d934c3218f967d12b750230ef163c227 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 22437ecc4898135583f8947fa9f88bdcdf976c0f..a8a29d882c55537412e43843aaa2d0533100215e 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 8fb561860c3dffd8f832e9f2eaa1a757026de04b..c5e8fd14e52d48b04cb2391ce0855af0beb29e27 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