diff --git a/Jenkinsfile b/Jenkinsfile index b2f78c6..d0421b9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -50,7 +50,6 @@ node('docker') { dir('haproxy'){ sh 'docker build --rm -t my/haproxy . > debug' sh 'rm debug' - sh 'docker rm haproxy' } } catch(error) { def error_details = readFile('haproxy/debug'); @@ -124,6 +123,8 @@ def handleError(String message, String tag, Boolean doCleanup = true){ def cleanup(String tag) { try{ sh 'bin/decompose.sh &> debug' + sh 'docker rm haproxy' + sh 'docker rmi my/haproxy' sh 'bin/prune.sh &> debug' } catch(error) { def error_details = readFile('./debug'); diff --git a/haproxy/Dockerfile b/haproxy/Dockerfile index ab58561..b983a39 100644 --- a/haproxy/Dockerfile +++ b/haproxy/Dockerfile @@ -10,4 +10,7 @@ LABEL ImageType="haproxy" LABEL ImageName=$imagename LABEL ImageOS=centos7 LABEL Version=$version + +RUN apt-get update && apt-get install -y socat +COPY container_files/ /opt copy conf/haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg diff --git a/haproxy/conf/haproxy.cfg b/haproxy/conf/haproxy.cfg index bcb15b5..8e9bb29 100644 --- a/haproxy/conf/haproxy.cfg +++ b/haproxy/conf/haproxy.cfg @@ -2,6 +2,7 @@ global log 127.0.0.1 local0 log 127.0.0.1 local1 notice + stats socket /usr/local/etc/haproxysock level admin defaults log global diff --git a/haproxy/container_files/bin/haproxycfg.sh b/haproxy/container_files/bin/haproxycfg.sh new file mode 100755 index 0000000..efb7ce6 --- /dev/null +++ b/haproxy/container_files/bin/haproxycfg.sh @@ -0,0 +1,2 @@ +#!/bin/bash +echo "$@" | socat unix-connect:/usr/local/etc/haproxysock stdio \ No newline at end of file diff --git a/tests/haproxy.bats b/tests/haproxy.bats new file mode 100644 index 0000000..44b8a6b --- /dev/null +++ b/tests/haproxy.bats @@ -0,0 +1,14 @@ +#!/usr/bin/env bats + +load ../common + +# These tests assume the pipeline will start and stop the container. + +@test "socat process exists" { + docker exec -i haproxy which socat +} + +@test "socat helper process exists" { + docker exec -i haproxy /opt/bin/haproxycfg.sh show stat +} +