commit 307b51e0a7b8cceeb1fdd344d2eb8693f7011bea Author: Kameron Kenny Date: Mon Feb 24 16:00:02 2025 -0500 init dnsdist diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1be5a40 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM docker-registry1.in.thelinuxpro.net:5000/tlp/tlp_ubuntu:latest + +RUN apt update && apt upgrade -y +RUN apt install -y dnsdist +RUN apt clean + +EXPOSE 53/tcp 53/udp + +RUN [[ ! -d '/etc/dnsdist' ]] && mkdir /etc/dnsdist +COPY dnsdist.conf /etc/dnsdist/dnsdist.conf + +ENTRYPOINT ["/usr/local/bin/dnsdist", "--uid", "dnsdist", "--gid", "dnsdist"] +CMD ["--supervised"] diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..7b18bb4 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,102 @@ +pipeline { + agent { + label 'pi501.in.thelinuxpro.net' + } + + stages { + stage("verify tooling") { + steps { + sh ''' + docker version + docker info + docker compose version + ''' + } + } + + stage("Build Containers and push to registry") { + steps { + script { + def status = sh(returnStatus: true, script: 'docker images | grep nagios | grep $(grep image docker-compose.yml | awk -F\':\' \'{ print $4 }\')') + + if (status != 0) { + sh 'docker compose build --push' + } else { + echo "Primary Image version already exists, no need to rebuild." + } + } + } + } + + stage('Create contexts') { + steps { + sh 'docker context ls | grep pi503 || docker context create pi503 --docker "host=ssh://pi503.in.thelinuxpro.net"' + sh 'docker context ls | grep pi502 || docker context create pi502 --docker "host=ssh://pi502.in.thelinuxpro.net"' + } + } + + stage('Stop container 1') { + steps { + script { + def status = sh(returnStatus: true, script: 'grep $(docker --context pi503 compose ps | tail -n1 | awk \'{ print $2 }\') docker-compose.yml') + + if (status != 0) { + sh 'docker --context pi503 compose down' + sh 'sleep 5' + } else { + echo 'skip' + } + } + } + } + + stage('Stop container 2') { + steps { + script { + def status = sh(returnStatus: true, script: 'grep $(docker --context pi502 compose ps | tail -n1 | awk \'{ print $2 }\') docker-compose.yml') + + if (status != 0) { + sh 'docker --context pi502 compose down' + sh 'sleep 5' + } else { + echo 'skip' + } + } + } + } + + stage('Start container 1') { + steps { + script { + def status = sh(returnStatus: true, script: 'grep $(docker --context pi503 compose ps | tail -n1 | awk \'{ print $2 }\') docker-compose.yml') + + if (status != 0) { + sh 'docker --context pi503 compose up -d' + sh 'docker --context pi503 compose ps' + sh 'sleep 3' + sh 'docker --context pi503 compose logs' + } else { + echo 'skip' + } + } + } + } + + stage('Start container 2') { + steps { + script { + def status = sh(returnStatus: true, script: 'grep $(docker --context pi502 compose ps | tail -n1 | awk \'{ print $2 }\') docker-compose.yml') + + if (status != 0) { + sh 'docker --context pi502 compose up -d' + sh 'docker --context pi502 compose ps' + sh 'sleep 3' + sh 'docker --context pi502 compose logs' + } else { + echo 'skip' + } + } + } + } + } +} diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..f118b97 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,32 @@ +--- +networks: + dns_local_net: + external: true + +services: + dnsdist1: + build: + dockerfile: Dockerfile + container_name: dnsdist1 + image: docker-registry1.in.thelinuxpro.net:5000/tlp/dnsdist:250224.0.01 + networks: + infra_dev_net: + ipv4_address: 10.200.53.251 + restart: always + volumes: + - /etc/timezone:/etc/timezone:ro + - /etc/localtime:/etc/localtime:ro + - /etc/resolv.conf:/etc/resolv.conf:ro + dnsdist2: + build: + dockerfile: Dockerfile + container_name: dnsdist2 + image: docker-registry1.in.thelinuxpro.net:5000/tlp/dnsdist:250224.0.01 + networks: + infra_dev_net: + ipv4_address: 10.200.53.252 + restart: always + volumes: + - /etc/timezone:/etc/timezone:ro + - /etc/localtime:/etc/localtime:ro + - /etc/resolv.conf:/etc/resolv.conf:ro