diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..a2cb38cb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +# Utiliser l'image Apache officielle +FROM httpd:2.4 + +# Supprimer le contenu par défaut d'Apache (optionnel) +RUN rm -rf /usr/local/apache2/htdocs/* + +# Copier tout ton site dans le dossier d’Apache +COPY . /usr/local/apache2/htdocs/ + +# Exposer le port 80 +EXPOSE 80 + # coucou \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000..796e6d07 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,47 @@ +pipeline { + agent any + +stages{ + //------------------------------------------------ + stage('Generate Local Tag') { + steps { + script { + def shortHash = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim() + def timestamp = new Date().format('yyyyMMddHHmmss') + env.LOCAL_TAG = "v${timestamp}-${shortHash}" + + echo "Generated Local Tag: ${env.LOCAL_TAG}" + } + } + } + + //------------------------------------------------ + + stage('Docker Build & Push') { + steps { + withCredentials([string(credentialsId: 'Bolverkr14', variable: 'bolverkr_pw')]) { + echo "print tag : $LOCAL_TAG" + sh 'docker login -u attilaisnotdead -p $bolverkr_pw' + sh 'docker build -t attilaisnotdead/websiteyann:$LOCAL_TAG .' + sh 'docker push attilaisnotdead/websiteyann:$LOCAL_TAG' + } + } + } + + //------------------------------------------------ + + stage(' Deployment docker ') { + steps { + + script { + sh 'sudo docker ps -a --filter "name=attilaisnotdead" --format "{{.ID}}" |sudo xargs -r docker stop' + sh 'sudo docker ps -a --filter "name=attilaisnotdead" --format "{{.ID}}" |sudo xargs -r docker rm' + sh 'docker run -d -p 9999:80 --name attilaisnotdead$LOCAL_TAG attilaisnotdead/websiteyann:$LOCAL_TAG' + } + + } + } +//------------------------------------------------ +} + +} \ No newline at end of file diff --git a/index.html b/index.html index 1a429961..e86fd148 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@ -