FROM ubuntu:20.04 AS builder-ssl ENV DEBIAN_FRONTEND noninteractive RUN apt-get -y update && apt-get -y install git make gcc RUN git clone --depth 1 https://github.com/quictls/openssl.git RUN cd /openssl && ./config enable-tls1_3 && make -j$(nproc) && make install_sw FROM ubuntu:20.04 AS builder ENV DEBIAN_FRONTEND noninteractive COPY --from=builder-ssl /usr/local/include/openssl/ /usr/local/include/openssl/ COPY --from=builder-ssl /usr/local/lib64/libssl.so* /usr/local/lib64/libcrypto.so* /usr/local/lib64/ RUN apt -y update && apt install -y git ca-certificates gcc libc6-dev liblua5.3-dev libpcre3-dev libssl-dev libsystemd-dev make wget zlib1g-dev socat \ && git clone --depth 1 https://github.com/haproxy/haproxy.git haproxy \ && cd /haproxy \ && make -j $(nproc) \ CC=gcc \ TARGET=linux-glibc \ USE_LUA=1 \ USE_OPENSSL=1 \ USE_PCRE=1 \ USE_ZLIB=1 \ USE_SYSTEMD=1 \ USE_PROMEX=1 \ USE_QUIC=1 \ SSL_INC=/usr/local/include/ \ SSL_LIB=/usr/local/lib64/ \ LDFLAGS="-Wl,-rpath,/usr/local/lib64" \ USE_TFO=1 \ && make install FROM ubuntu:20.04 AS haproxy COPY --from=builder-ssl /usr/local/lib64/*.* /usr/local/lib64/ COPY --from=builder /usr/local/sbin/haproxy /usr/local/sbin/ env tz=asia/shanghai RUN echo $TZ > /etc/timezone && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && apt -y update && apt install -y liblua5.3-dev libpcre3-dev && echo "/usr/local/lib64/" >> /etc/ld.so.conf && groupadd haproxy && useradd -g haproxy haproxy -s /bin/false && apt-get clean \ && rm -rf /var/lib/apt/lists/* \ && rm -rf /var/cache/* /var/log/* /tmp/* /var/lib/dpkg/status-old
docker build -t qctt/haproxy -f haproxy/Dockerfile . 测试配置文件 docker run -it --rm --name haproxy -v /root/haproxy:/etc/haproxy:ro qctt/haproxy haproxy -c -f /etc/haproxy/haproxy.cfg