Project1
This commit is contained in:
16
project1/checker.py
Normal file
16
project1/checker.py
Normal file
@@ -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/")
|
||||
16
project1/dockerfile
Normal file
16
project1/dockerfile
Normal file
@@ -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"]
|
||||
|
||||
30
project1/jenkinsfile
Normal file
30
project1/jenkinsfile
Normal file
@@ -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'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
1
project1/requirements.txt
Normal file
1
project1/requirements.txt
Normal file
@@ -0,0 +1 @@
|
||||
requests==2.31.0
|
||||
Reference in New Issue
Block a user