diff --git a/Dockerfile b/Dockerfile index 1354ebe..801ea44 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,8 +3,7 @@ ARG TARGET_ARCH="library" FROM docker.io/${TARGET_ARCH}/alpine:${ALPINE_VERSION} AS build -WORKDIR /sslh - +# Install build dependencies for sslh and libproxyprotocol RUN apk add --no-cache \ 'gcc' \ 'libconfig-dev' \ @@ -12,15 +11,39 @@ RUN apk add --no-cache \ 'musl-dev' \ 'pcre2-dev' \ 'perl' \ + 'git' \ + 'autoconf' \ + 'automake' \ + 'libtool' \ ; +# Build libproxyprotocol +WORKDIR /tmp +RUN git clone https://github.com/kosmas-valianos/libproxyprotocol.git && \ + cd libproxyprotocol && \ + make && \ + mkdir -p /usr/local/include/ && \ + mv libs/libproxyprotocol.so /usr/local/lib/ && \ + mv src/* /usr/local/include/ + +# Set environment variables for sslh to find libproxyprotocol +ENV C_INCLUDE_PATH=/usr/local/include +ENV LIBRARY_PATH=/usr/local/lib +ENV LD_LIBRARY_PATH=/usr/local/lib + +WORKDIR /sslh COPY . /sslh +# Configure and build sslh +# The configure script should automatically detect libproxyprotocol RUN ./configure && make sslh-select && strip sslh-select FROM docker.io/${TARGET_ARCH}/alpine:${ALPINE_VERSION} +# Copy libproxyprotocol.so from the build stage +COPY --from=build /usr/local/lib/libproxyprotocol.so* /usr/local/lib/ COPY --from=build "/sslh/sslh-select" "/usr/local/bin/sslh" + RUN apk add --no-cache \ 'libconfig' \ 'pcre2' \ @@ -35,4 +58,4 @@ COPY "./container-entrypoint.sh" "/init" ENTRYPOINT [ "/init" ] # required for updating iptables -USER root:root +USER root:root \ No newline at end of file