FROM quay.io/pypa/manylinux_2_24_x86_64

ENV OPENSSL openssl-1.1.1q
ENV LIBSSH 0.10.4
ENV KRB 1.18.4
ENV SYSTEM_LIBSSH 1
ENV CFLAGS "-g0 -s"
ENV OPENSSL_ROOT_DIR /usr/lib

RUN apt-get update -y && apt-get install zlib1g-dev cmake -y

ADD libssh-${LIBSSH}.tar.xz libssh.tar.xz
ADD https://www.openssl.org/source/${OPENSSL}.tar.gz ${OPENSSL}.tar.gz
ADD krb5-${KRB}.tar.xz krb5-${KRB}.tar.xz

RUN tar -xzf ${OPENSSL}.tar.gz
# Openssl
RUN cd ${OPENSSL} && \
    ./config --prefix=/usr --openssldir=/usr/openssl threads shared && \
    make -j6 && make install_sw

# Kerberos
RUN cd krb5-${KRB}.tar.xz/krb5-${KRB}/src && \
    ./configure && \
    make -j6 && \
    make install

# Libssh
RUN mkdir -p build_libssh && cd build_libssh && \
    cmake ../libssh.tar.xz/libssh-${LIBSSH} -DCMAKE_BUILD_TYPE=Release \
          -DWITH_GSSAPI=ON -DWITH_EXAMPLES=OFF && \
    make -j6 install/strip

RUN rm -rf ${OPENSSL}* libssh build_libssh krb5-${KRB}.tar.xz

VOLUME /var/cache
