-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
101 lines (82 loc) · 3.77 KB
/
Dockerfile
File metadata and controls
101 lines (82 loc) · 3.77 KB
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
98
99
100
101
FROM golang:latest AS builder
ENV DATAPLANE_MINOR 2.6.0
ENV DATAPLANE_URL https://github.com/haproxytech/dataplaneapi.git
RUN git clone "${DATAPLANE_URL}" "${GOPATH}/src/github.com/haproxytech/dataplaneapi"
RUN cd "${GOPATH}/src/github.com/haproxytech/dataplaneapi" && \
git checkout "v${DATAPLANE_MINOR}" && \
make build && cp build/dataplaneapi /dataplaneapi
FROM alpine:3.15
LABEL Name HAProxy
LABEL Release Community Edition
LABEL Vendor HAProxy
LABEL Version 2.6.2
LABEL RUN /usr/bin/docker -d IMAGE
ENV HAPROXY_BRANCH 2.6
ENV HAPROXY_MINOR 2.6.2
ENV HAPROXY_SHA256 f9b7dc06e02eb13b5d94dc66e0864a714aee2af9dfab10fa353ff9f1f52c8202
ENV HAPROXY_SRC_URL http://www.haproxy.org/download
ENV DATAPLANE_MINOR 2.6.0
ENV DATAPLANE_SHA256 ec685350576898bb0a00d656f427f5da7c28043551a3e0050c1b5301547e235a
ENV DATAPLANE_URL https://github.com/haproxytech/dataplaneapi/releases/download
ENV HAPROXY_UID haproxy
ENV HAPROXY_GID haproxy
COPY --from=builder /dataplaneapi /usr/local/bin/dataplaneapi
# grab su-exec for easy step-down from root and add bash
RUN apk add --no-cache bash
RUN apk add --no-cache --virtual build-deps ca-certificates gcc libc-dev \
linux-headers lua5.3-dev make openssl openssl-dev pcre2-dev tar \
zlib-dev curl shadow ca-certificates && \
curl -sfSL "${HAPROXY_SRC_URL}/${HAPROXY_BRANCH}/src/haproxy-${HAPROXY_MINOR}.tar.gz" -o haproxy.tar.gz && \
echo "$HAPROXY_SHA256 *haproxy.tar.gz" | sha256sum -c - && \
groupadd "$HAPROXY_GID" && \
useradd -g "$HAPROXY_GID" "$HAPROXY_UID" && \
mkdir -p /tmp/haproxy && \
tar -xzf haproxy.tar.gz -C /tmp/haproxy --strip-components=1 && \
rm -f haproxy.tar.gz && \
make -C /tmp/haproxy -j"$(nproc)" TARGET=linux-musl CPU=generic USE_PCRE2=1 USE_PCRE2_JIT=1 USE_OPENSSL=1 \
USE_TFO=1 USE_LINUX_TPROXY=1 USE_GETADDRINFO=1 \
USE_LUA=1 LUA_LIB=/usr/lib/lua5.3 LUA_INC=/usr/include/lua5.3 \
USE_PROMEX=1 USE_SLZ=1 \
all && \
make -C /tmp/haproxy TARGET=linux2628 install-bin install-man && \
ln -s /usr/local/sbin/haproxy /usr/sbin/haproxy && \
mkdir -p /var/lib/haproxy && \
chown "$HAPROXY_UID:$HAPROXY_GID" /var/lib/haproxy && \
mkdir -p /usr/local/etc/haproxy && \
ln -s /usr/local/etc/haproxy /etc/haproxy && \
cp -R /tmp/haproxy/examples/errorfiles /usr/local/etc/haproxy/errors && \
rm -rf /tmp/haproxy && \
chmod +x /usr/local/bin/dataplaneapi && \
ln -s /usr/local/bin/dataplaneapi /usr/bin/dataplaneapi && \
touch /usr/local/etc/haproxy/dataplaneapi.hcl && \
chown "$HAPROXY_UID:$HAPROXY_GID" /usr/local/etc/haproxy/dataplaneapi.hcl && \
apk del build-deps && \
apk add --no-cache openssl zlib lua5.3-libs pcre2 && \
rm -f /var/cache/apk/*
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
# RUN addgroup -g 1000 -S haproxy && adduser -u 1000 -S -G haproxy haproxy
RUN set -x \
&& apk add --update rsyslog \
&& apk add --update curl \
&& mkdir -p /etc/service/rsyslog \
&& apk update \
&& apk upgrade \
&& rm -rf /var/cache/apk/* \
&& rm /usr/bin/nc
COPY run.sh /etc/service/rsyslog/run
COPY haproxy.cfg /usr/local/etc/haproxy
COPY docker-entrypoint.sh /
COPY healthz.sh /
COPY healthz_li.sh /
RUN chmod +x /docker-entrypoint.sh && chmod +x /healthz.sh && chmod +x /healthz_li.sh \
&& chown haproxy:haproxy /usr/local/etc/haproxy \
&& chown haproxy:haproxy /run \
&& chown haproxy:haproxy docker-entrypoint.sh \
&& chown haproxy:haproxy healthz.sh \
&& chown haproxy:haproxy healthz_li.sh
ADD rsyslog.conf /etc/rsyslog.conf
EXPOSE 514 514/udp
# STOPSIGNAL SIGUSR1
USER haproxy
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["haproxy", "-f", "/usr/local/etc/haproxy/haproxy.cfg"]