-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
54 lines (42 loc) · 1.92 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
FROM ubuntu:20.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 python3-pip curl lua-socket lua-json lua-http rsync pcregrep
RUN pip3 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="addons/promex/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/*
#Multistage build
FROM scratch
COPY --from=buildstage / /
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
ENV SYSLOG_PORT 514
ENV SYSLOG_PROTO udp
VOLUME ["/hacfg"]
ADD . /app
WORKDIR /app
RUN mkdir -p /etc/supervisor && cp /app/supervisord.conf.tpl /etc/supervisor/supervisord.conf.tpl
RUN cp /app/dir-prereqs.sh /dir-prereqs.sh
RUN cp /app/haproxy.cfg /etc/haproxy
#Source : https://raw.githubusercontent.com/haproxytech/haproxy-lua-http/master/http.lua
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
EXPOSE 80
CMD . ./dir-prereqs.sh && for FILE in $TPLFILES; do envtpl --keep-template --allow-missing $FILE.tpl; done && ./run.sh