-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
97 lines (90 loc) · 2.5 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
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
95
96
97
FROM alpine:3.21.1 AS builder
LABEL maintainer="Russell Martin - github/rmartin16/docker-keepalived"
LABEL description="multiarch keepalived"
RUN apk --update-cache add \
autoconf \
automake \
bash \
binutils \
curl \
file \
file-dev \
gcc \
ipset \
ipset-dev \
iptables \
iptables-dev \
libip6tc \
libip4tc \
libmnl-dev \
libnftnl-dev \
libnl3 \
libnl3-dev \
linux-headers \
make \
musl-dev \
net-snmp-dev \
openssl \
openssl-dev \
pcre2 \
pcre2-dev
ARG KEEPALIVED_VERSION=2.3.2
RUN curl -s -o keepalived.tar.gz -SL http://keepalived.org/software/keepalived-${KEEPALIVED_VERSION}.tar.gz && \
mkdir -p /build/keepalived && \
tar -xzf keepalived.tar.gz --strip 1 -C /build/keepalived
WORKDIR /build/keepalived
ENV CFLAGS="-Wno-incompatible-pointer-types"
RUN sed -i 's/#include <linux\/if_ether.h>//' keepalived/vrrp/vrrp.c
RUN ./build_setup
RUN /bin/bash ./configure \
MKDIR_P='/bin/mkdir -p' \
--disable-dynamic-linking \
--disable-dependency-tracking \
--enable-bfd \
--enable-json \
--enable-nftables \
--enable-snmp \
--enable-snmp-rfc \
--enable-regex \
--prefix=/usr \
--exec-prefix=/usr \
--bindir=/usr/bin \
--sbindir=/usr/sbin \
--sysconfdir=/etc \
--datadir=/usr/share \
--localstatedir=/var \
--mandir=/usr/share/man
RUN make
RUN make install
RUN strip /usr/sbin/keepalived
FROM alpine:3.21.1
RUN apk --no-cache add \
file \
ipset \
iptables \
libip6tc \
libip4tc \
libmagic \
libnl3 \
libgcc \
net-snmp \
openssl \
pcre2 && \
addgroup -S keepalived_script && \
adduser -D -S -G keepalived_script keepalived_script && \
# workaround for https://github.com/acassen/keepalived/issues/2503
mkdir -p /usr/share/iproute2/rt_addrprotos.d && \
mkdir -p /etc/iproute2/rt_addrprotos.d
COPY --from=builder /usr/sbin/keepalived /usr/sbin/keepalived
COPY assets/keepalived.conf /etc/keepalived/keepalived.conf
COPY assets/notify.sh /notify.sh
COPY assets/entrypoint.sh /entrypoint.sh
ENV INTERFACE="eth0" \
STATE="BACKUP" \
ROUTER_ID="41" \
PRIORITY="100" \
UNICAST_PEERS="192.168.2.101 192.168.2.102 192.168.2.103" \
VIRTUAL_IPS="192.168.2.100/24" \
PASSWORD="KeptAliv" \
NOTIFY="/notify.sh"
CMD ["/bin/sh", "-x", "entrypoint.sh"]