Skip to content
Snippets Groups Projects
Commit f9d31311 authored by WITTMANN Gregory's avatar WITTMANN Gregory
Browse files

Modification docker et pipline

parent b94a7369
No related branches found
No related tags found
No related merge requests found
Pipeline #16648 failed
stages: stages:
- lint - lint
- test - test
- build - deploy
variables: variables:
PYTEST_FLAGS: "-v" IMAGE_NAME: imagesphere # Remplacez par le nom réel de votre image Docker
lint: lint:
stage: lint stage: lint
script: script:
- pip install flake8 - apt-get update -qy
- flake8 calculVolumeSphere.py - apt-get install -y python3-pip
- pip3 install flake8
- flake8 sphère.py
test: test:
stage: test stage: test
script: script:
- pip install -r requirements.txt - apt-get update -qy
- pip install pytest - apt-get install -y python3-pip
- pytest test_sphère.py - pip3 install -r requirements.txt
- python3 -m pytest test_sphère.py
build: deploy:
stage: build stage: deploy
only:
- master
script: script:
- docker build -t EvalSpherePython . - echo echo "Les étapes de déploiement seront définies ultérieurement."
\ No newline at end of file \ No newline at end of file
# sphère.py import os
import math import math
def calculer_volume_sphere(rayon): def calculer_volume_sphere(rayon):
...@@ -12,13 +11,16 @@ def calculer_volume_sphere(rayon): ...@@ -12,13 +11,16 @@ def calculer_volume_sphere(rayon):
def enregistrer_resultat_fichier(volume, fichier): def enregistrer_resultat_fichier(volume, fichier):
with open(fichier, 'w') as f: with open(fichier, 'w') as f:
f.write(f"{volume}") f.write(f"{volume}")
def main(): def main():
rayon = float(input("Rayon de la sphère en cm : ")) # Obtenez le rayon à partir de la variable d'environnement
volume = calculer_volume_sphere(rayon) 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") enregistrer_resultat_fichier(volume, "volume.txt")
if __name__ == '__main__': if __name__ == '__main__':
main() main()
\ No newline at end of file
...@@ -5,10 +5,10 @@ FROM python:3.8 ...@@ -5,10 +5,10 @@ FROM python:3.8
RUN apt-get update -y && apt-get install -y python3-pip RUN apt-get update -y && apt-get install -y python3-pip
# Copiez les fichiers nécessaires dans le conteneur # Copiez les fichiers nécessaires dans le conteneur
COPY calculVolumeSphere.py requirements.txt ./ COPY calculVolumeSphere.py ./
# Installez les dépendances # Installez les dépendances
RUN pip3 install -r requirements.txt RUN pip3 install Flask
# Exposez le port 9090 # Exposez le port 9090
EXPOSE 9090 EXPOSE 9090
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment