diff --git a/project1/checker.py b/project1/checker.py new file mode 100644 index 0000000..c22349d --- /dev/null +++ b/project1/checker.py @@ -0,0 +1,16 @@ +import requests +import sys + +def check_site(url): + try: + response = requests.get(url, timeout=5) + if response.status_code == 200: + print(f"✅ Succes! {url} este online.") + else: + print(f"⚠️ Atentie! {url} a raspuns cu status: {response.status_code}") + except Exception as e: + print(f"❌ Eroare: Nu am putut accesa {url}. Motiv: {e}") + sys.exit(1) + +if __name__ == "__main__": + check_site("https://www.youtube.com/") \ No newline at end of file diff --git a/project1/dockerfile b/project1/dockerfile new file mode 100644 index 0000000..c47c269 --- /dev/null +++ b/project1/dockerfile @@ -0,0 +1,16 @@ +# Folosesc o imagine oficiala de Python (Slim) +FROM python:3.11-slim + +# Setez directorul de lucru in container +WORKDIR /the/workdir/path + +# Copiez fisierul de requirements in container +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +# Copiez restul codului sursa in container +COPY checker.py . + +# Comanda de rulare a aplicatiei +CMD ["python", "checker.py"] + diff --git a/project1/jenkinsfile b/project1/jenkinsfile new file mode 100644 index 0000000..21e60fc --- /dev/null +++ b/project1/jenkinsfile @@ -0,0 +1,30 @@ +pipeline { + agent any + + stages { + stage('Checkout') { + steps { + // Jenkins va prelua codul sursă din depozitul Git + echo 'Se descarca codul...' + } + } + + stage('Build Docker Image') { + steps { + script { + // Construim imaginea și îi dăm un nume (tag) + sh 'docker build -t web-checker-app .' + } + } + } + + stage('Run Checker') { + steps { + script { + // Rulăm containerul + sh 'docker run --rm web-checker-app' + } + } + } + } +} \ No newline at end of file diff --git a/project1/requirements.txt b/project1/requirements.txt new file mode 100644 index 0000000..077c95d --- /dev/null +++ b/project1/requirements.txt @@ -0,0 +1 @@ +requests==2.31.0 \ No newline at end of file