From 6abc7cd1a3c85ef641dda7342c1bc42da82c2cdb Mon Sep 17 00:00:00 2001 From: acaranta Date: Thu, 10 Dec 2020 16:47:14 +0100 Subject: [PATCH] switched to building haproxy from source adding prometheus exporter. also switched to multistage building to reduce image size --- Dockerfile | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 841eb14..dac993f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:18.04 +FROM ubuntu:18.04 AS buildstage MAINTAINER arthur@caranta.com ENV DEBIAN_FRONTEND noninteractive @@ -6,9 +6,21 @@ ENV INITRD No RUN apt-get update -y RUN apt-get install --force-yes -y haproxy inotify-tools python-pip curl lua-socket lua-json lua-http && \ - pip install envtpl supervisor supervisor-logging && \ - apt-get -y remove build-essential ".*-dev" && \ - apt-get -y autoremove + pip install envtpl supervisor supervisor-logging + +#Fetch and build haproxy from github, compile it with prometheus exporter +RUN cd /tmp && \ + apt install -y git ca-certificates gcc libc6-dev liblua5.3-dev libpcre3-dev libssl-dev libsystemd-dev make wget zlib1g-dev && \ + git clone https://github.com/haproxy/haproxy.git && \ + cd haproxy && \ + make TARGET=linux-glibc USE_LUA=1 USE_OPENSSL=1 USE_PCRE=1 USE_ZLIB=1 USE_SYSTEMD=1 EXTRA_OBJS="contrib/prometheus-exporter/service-prometheus.o" && \ + make install-bin && \ + cp /usr/local/sbin/haproxy /usr/sbin/haproxy && \ + cd / && rm -rf /tmp/haproxy + +RUN apt-get -y remove build-essential ".*-dev" git gcc make && \ + apt-get -y autoremove && \ + rm -rf /var/lib/apt/lists/* /var/cache/apt/* ADD . /app WORKDIR /app @@ -21,6 +33,16 @@ RUN cp /app/lua/haproxy-lua-http.lua /usr/share/lua/5.3/haproxy-lua-http.lua #Source : https://raw.githubusercontent.com/TimWolla/haproxy-auth-request/master/auth-request.lua RUN cp /app/lua/auth-request.lua /etc/haproxy/auth-request.lua +#Multistage build +FROM scratch + +COPY --from=buildstage / / + +WORKDIR /app + +MAINTAINER arthur@caranta.com +ENV DEBIAN_FRONTEND noninteractive +ENV INITRD No ENV TPLFILES /etc/supervisor/supervisord.conf ENV HASVC hapconf.cfg ENV SYSLOG_SERVER 127.0.0.1