Skip to content

Commit

Permalink
switched to building haproxy from source adding prometheus exporter. …
Browse files Browse the repository at this point in the history
…also switched to multistage building to reduce image size
  • Loading branch information
acaranta committed Dec 10, 2020
1 parent 616d391 commit 6abc7cd
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
FROM ubuntu:18.04
FROM ubuntu:18.04 AS buildstage

MAINTAINER arthur@caranta.com
ENV DEBIAN_FRONTEND noninteractive
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
Expand All @@ -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
Expand Down

0 comments on commit 6abc7cd

Please sign in to comment.