diff --git a/.gitignore b/.gitignore index e7d9605..4c43d76 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.DS_Store _site .sass-cache .jekyll-metadata diff --git a/Dockerfile b/Dockerfile index d7ac8b9..45fe6c0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM docker-registry1.in.thelinuxpro.net:5000/tlp/tlp_jekyll:0.0.1 -LABEL version="0.0.4" +LABEL version="0.0.5" LABEL image.author.name="Kameron Kenny" LABEL image.author.email="kameron@localhost" LABEL description="A Jekyll site for kameronkenny.com." diff --git a/Jenkinsfile b/Jenkinsfile index 77700f5..3191763 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,7 +17,7 @@ pipeline { stage("Build Containers and push to registry") { steps { script { - sh 'docker build -t docker-registry1.in.thelinuxpro.net:5000/sites/kameronkenny.com:0.0.4 . --push' + sh 'docker build -t docker-registry1.in.thelinuxpro.net:5000/sites/kameronkenny.com:0.0.5 . --push' } } } @@ -25,7 +25,7 @@ pipeline { stage("Tag image as latest") { steps { script { - sh 'docker tag docker-registry1.in.thelinuxpro.net:5000/sites/kameronkenny.com:0.0.4 docker-registry1.in.thelinuxpro.net:5000/sites/kameronkenny.com:latest' + sh 'docker tag docker-registry1.in.thelinuxpro.net:5000/sites/kameronkenny.com:0.0.5 docker-registry1.in.thelinuxpro.net:5000/sites/kameronkenny.com:latest' } } } @@ -37,9 +37,101 @@ pipeline { } } } - stage("Start web1 container") { + + stage("Create Contexts") { steps { - sh 'docker compose up -d --no-color' + sh 'docker context ls | grep pi502 || docker context create pi502 --docker "host=ssh://pi502.in.thelinuxpro.net"' + sh 'docker context ls | grep pi503 || docker context create pi503 --docker "host=ssh://pi503.in.thelinuxpro.net"' + } + } + + stage("Stop pi501 web1 container") { + steps { + script { + def status = sh(returnStatus: true, script: 'grep $(docker compose ps | grep kameronkenny.com_web1 | teail -n1 | awk \'{ print $2 }\') docker-compose.yml') + + if (status == 0) { + sh 'docker compose down' + sh 'sleep 5' + } else { + echo 'skip' + } + } + } + } + + stage("Start pi501 web1 container") { + steps { + script { + def status = sh(returnStatus: true, script: 'grep $(docker compose ps | grep kameronkenny.com_web1 | teail -n1 | awk \'{ print $2 }\') docker-compose.yml') + + if (status != 0) { + sh 'docker compose up -d' + sh 'docker ps' + } else { + echo 'skip' + } + } + } + } + + stage("Stop pi502 web1 container") { + steps { + script { + def status = sh(returnStatus: true, script: 'grep $(docker --context pi502 compose ps | grep kameronkenny.com_web1 | teail -n1 | awk \'{ print $2 }\') docker-compose.yml') + + if (status == 0) { + sh 'docker --context pi502 compose down' + sh 'sleep 5' + } else { + echo 'skip' + } + } + } + } + + stage("Start pi502 web1 container") { + steps { + script { + def status = sh(returnStatus: true, script: 'grep $(docker --context pi502 compose ps | grep kameronkenny.com_web1 | teail -n1 | awk \'{ print $2 }\') docker-compose.yml') + + if (status != 0) { + sh 'docker --context pi502 compose up -d' + sh 'docker --context pi502 ps + } else { + echo 'skip' + } + } + } + } + + stage("Stop pi503 web1 container") { + steps { + script { + def status = sh(returnStatus: true, script: 'grep $(docker --context pi503 compose ps | grep kameronkenny.com_web1 | teail -n1 | awk \'{ print $2 }\') docker-compose.yml') + + if (status == 0) { + sh 'docker --context pi503 compose down' + sh 'sleep 5' + } else { + echo 'skip' + } + } + } + } + + stage("Start pi503 web1 container") { + steps { + script { + def status = sh(returnStatus: true, script: 'grep $(docker --context pi503 compose ps | grep kameronkenny.com_web1 | teail -n1 | awk \'{ print $2 }\') docker-compose.yml') + + if (status != 0) { + sh 'docker --context pi503 compose up -d' + sh 'docker --context pi503 ps + } else { + echo 'skip' + } + } } } }