Add Jenkisfile

This commit is contained in:
2026-01-07 16:18:10 +01:00
parent e11e0df5eb
commit 4a12b1a17a

40
Jenkinsfile vendored Normal file
View File

@@ -0,0 +1,40 @@
pipeline {
agent any
environment {
IMAGE_NAME = "astro-portfolio"
CONTAINER_NAME = "portfolio"
DOCKER_NETWORK = "reverse-proxy"
}
stage('Checkout') {
steps {
checkout scm
}
}
stage('Docker Build') {
steps {
sh "docker build -t ${IMAGE_NAME} ."
}
}
stage('Deploy') {
steps {
sh "docker stop ${CONTAINER_NAME} || true"
sh "docker rm ${CONTAINER_NAME} || true"
sh "docker run -d --name ${CONTAINER_NAME} --network ${DOCKER_NETWORK} ${IMAGE_NAME}"
}
}
stage('Cleanup') {
steps {
sh "docker image prune -f"
}
}
post {
success { echo "Le site est en ligne !" }
failure { echo "Le déploiement a échoué." }
}
}