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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
FROM alpine:latest
ARG GIT_VER=
ENV VER=@VERSION@
LABEL version=@VERSION@${GIT_VER}
LABEL author="Alexandre Cassen <acassen@gmail.com>"
LABEL project="https://github.com/acassen/keepalived"
LABEL homepage="https://www.keepalived.org"
# add keepalived sources to /tmp/keepalived-@VERSION@
ADD keepalived-@VERSION@.tar.gz /tmp
# Add keepalived default script user to make sure their IDs get assigned consistently,
# regardless of whatever dependencies get added
RUN addgroup -S keepalived_script && adduser -D -S -G keepalived_script keepalived_script
# 1. install required libraries and tools
# 2. compile and install keepalived
# 3. remove keepalived sources and unnecessary libraries and tools
RUN apk --no-cache add \
binutils \
@MAGIC_TRUE@ file \
@MAGIC_TRUE@ file-dev \
gcc \
@WITH_DBUS_TRUE@ glib \
@WITH_DBUS_TRUE@ glib-dev \
@LIBIPSET_TRUE@ ipset \
@LIBIPSET_TRUE@ ipset-dev \
@IPTABLES_TRUE@ iptables \
@IPTABLES_TRUE@ iptables-dev \
@NFTABLES_TRUE@ libmnl-dev \
@NFTABLES_TRUE@ libnftnl-dev \
libnl3 \
libnl3-dev \
linux-headers \
make \
musl-dev \
@SNMP_TRUE@ net-snmp-dev \
openssl \
openssl-dev \
@WITH_REGEX_TRUE@ pcre2 \
@WITH_REGEX_TRUE@ pcre2-dev \
autoconf \
automake \
&& cd /tmp/keepalived-@VERSION@/ \
&& ./autogen.sh \
&& ./configure \
--disable-dynamic-linking \
--prefix=/usr \
--exec-prefix=/usr \
--bindir=/usr/bin \
--sbindir=/usr/sbin \
--sysconfdir=/etc \
--datadir=/usr/share \
--localstatedir=/var \
--mandir=/usr/share/man \
@WITH_DBUS_TRUE@ --with-dbus-data-dir=/usr/share \
--enable-bfd \
@WITH_DBUS_TRUE@ --enable-dbus \
@WITH_REGEX_TRUE@ --enable-regex \
@SNMP_TRUE@ --enable-snmp \
@SNMP_TRUE@ --enable-snmp-rfc \
@NFTABLES_TRUE@ --enable-nftables \
@IPTABLES_FALSE@ --disable-iptables \
@IPTABLES_TRUE@@LIBIPSET_FALSE@ --disable-libipset \
@WITH_JSON_TRUE@ --enable-json \
&& make && make install \
&& strip /usr/sbin/keepalived \
&& cd - \
&& rm -rf /tmp/keepalived-@VERSION@ \
&& apk --no-cache del \
binutils \
@MAGIC_TRUE@ file-dev \
gcc \
@WITH_DBUS_TRUE@ glib-dev \
@LIBIPSET_TRUE@ ipset-dev \
@IPTABLES_TRUE@ iptables-dev \
@NFTABLES_TRUE@ libmnl-dev \
libnl3-dev \
@NFTABLES_TRUE@ libnftnl-dev \
make \
musl-dev \
openssl-dev \
@WITH_REGEX_TRUE@ pcre2-dev \
autoconf \
automake
ADD docker/keepalived.conf /etc/keepalived/keepalived.conf
# set keepalived as image entrypoint with --dont-fork and --log-console (to make it docker friendly)
# define /etc/keepalived/keepalived.conf as the configuration file to use
ENTRYPOINT ["/usr/sbin/keepalived","--dont-fork","--log-console", "-f","/etc/keepalived/keepalived.conf"]
# example command to customise keepalived daemon:
# CMD ["--log-detail","--dump-conf"]
|