Created
May 23, 2024 14:22
-
-
Save glic3rinu/0878f9c2d1e72dc07932325bca8f6a4a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM debian:bookworm-slim | |
ENV DEBIAN_FRONTEND noninteractive | |
ARG APT_PY_VERSION=3.11 | |
ARG ALT_PY_VERSION=3.11.8 | |
ARG PIP_BUILD_DEPENDENCIES=" \ | |
build-essential \ | |
clang-15 \ | |
python$APT_PY_VERSION-dev \ | |
libcap-dev" | |
ARG ALT_PY_BUILD_DEPENDENCIES=" \ | |
curl \ | |
build-essential \ | |
unzip \ | |
clang-15 \ | |
pkg-config \ | |
zlib1g-dev \ | |
libgdbm-dev \ | |
libnss3-dev \ | |
libffi-dev \ | |
uuid-dev \ | |
lzma-dev \ | |
liblzma-dev \ | |
libbz2-dev" | |
RUN apt-get update | |
RUN apt-get install -y \ | |
${ALT_PY_BUILD_DEPENDENCIES} \ | |
${PIP_BUILD_DEPENDENCIES} | |
ENV CC=/usr/bin/clang-15 | |
ENV CXX=/usr/bin/clang++-15 | |
ENV LLVM_PROFDATA=/usr/bin/llvm-profdata-15 | |
ENV LLVM_AR=/usr/bin/llvm-ar-15 | |
# https://github.com/openssl/openssl/issues/17064 | |
#RUN curl -O https://www.openssl.org/source/openssl-3.3.0.tar.gz && \ | |
RUN curl -O https://www.openssl.org/source/old/1.1.1/openssl-1.1.1v.tar.gz && \ | |
tar xvfz openssl-*.tar.gz && \ | |
( cd openssl-* && ./config --prefix=/usr/local --openssldir=/usr/local/ssl --libdir=lib shared zlib; ) && \ | |
( cd openssl-* && make -j8 && make install_sw && make install_ssldirs; ) && \ | |
ln -sf /etc/ssl/certs/ca-certificates.crt /usr/local/ssl/cert.pem && \ | |
rm -r /usr/local/ssl/certs && ln -sf /etc/ssl/certs /usr/local/ssl/certs && \ | |
rm -r /usr/local/ssl/private && ln -sf /etc/ssl/private /usr/local/ssl/private && \ | |
strip /usr/local/lib/libssl.* && \ | |
strip /usr/local/bin/openssl && \ | |
ldconfig && \ | |
/usr/local/bin/openssl version && \ | |
rm -rf openssl-* | |
RUN curl -O https://www.python.org/ftp/python/${ALT_PY_VERSION}/Python-${ALT_PY_VERSION}.tgz && \ | |
tar xvf Python-${ALT_PY_VERSION}.tgz && \ | |
( cd Python-${ALT_PY_VERSION} && LDFLAGS="${LDFLAGS} -Wl,-rpath=/usr/local/ssl/lib" ./configure \ | |
--with-openssl=/usr/local/ \ | |
--with-ssl-default-suites=openssl \ | |
--enable-option-checking=fatal \ | |
--enable-optimizations \ | |
--with-lto=thin \ | |
) && \ | |
( cd Python-${ALT_PY_VERSION} && make -j8 && make -j8 altinstall ) && \ | |
rm -rf Python-${ALT_PY_VERSION} && \ | |
strip /usr/local/bin/python${ALT_PY_VERSION%.*} && \ | |
strip /usr/local/lib/libpython* && \ | |
find /usr/local/lib/python${ALT_PY_VERSION%.*} | grep "\.so$" | grep -v cffi | xargs strip && \ | |
rm -fr /tmp/* | |
RUN LDFLAGS=-flto /usr/local/bin/pip${ALT_PY_VERSION%.*} install \ | |
gevent \ | |
requests | |
Author
glic3rinu
commented
May 24, 2024
•
- Added alternative http client using urllib (reusing ssl context) vs using requests (not reusing ssl context)
- Added 6 second timeout
- Using gevent pool imap_unordered to avoid head-of-the-line blocking problem with multiprocessing pool.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment