7
7
8
8
# Python is needed for building libnss.
9
9
# Use it as a common base.
10
- FROM python:3.10.1-slim-buster as builder
10
+ FROM python:3.10.1-slim-bullseye as builder
11
11
12
12
WORKDIR /build
13
13
@@ -19,8 +19,14 @@ RUN apt-get update && \
19
19
# both for libnghttp2 and curl.
20
20
RUN apt-get install -y autoconf automake autotools-dev pkg-config libtool
21
21
22
- # Dependencies for downloading and building BoringSSL
23
- RUN apt-get install -y g++ golang-go unzip
22
+ # Dependencies for building libnss
23
+ # See https://firefox-source-docs.mozilla.org/security/nss/build.html#mozilla-projects-nss-building
24
+ RUN apt-get install -y mercurial python3-pip
25
+
26
+ # curl tries to load the CA certificates for libnss.
27
+ # It loads them from /usr/lib/x86_64-linux-gnu/nss/libnssckbi.so,
28
+ # which is supplied by libnss3 on Debian/Ubuntu
29
+ RUN apt-get install -y libnss3
24
30
25
31
# Download and compile libbrotli
26
32
ARG BROTLI_VERSION=1.0.9
@@ -31,28 +37,18 @@ RUN cd brotli-${BROTLI_VERSION} && \
31
37
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./installed .. && \
32
38
cmake --build . --config Release --target install
33
39
34
- # BoringSSL doesn't have versions. Choose a commit that is used in a stable
35
- # Chromium version.
36
- ARG BORING_SSL_COMMIT=3a667d10e94186fd503966f5638e134fe9fb4080
37
- RUN curl -L https://github.com/google/boringssl/archive/${BORING_SSL_COMMIT}.zip -o boringssl.zip && \
38
- unzip boringssl && \
39
- mv boringssl-${BORING_SSL_COMMIT} boringssl
40
-
41
- # Compile BoringSSL.
42
- # See https://boringssl.googlesource.com/boringssl/+/HEAD/BUILDING.md
43
- COPY patches/boringssl-*.patch boringssl/
44
- RUN cd boringssl && \
45
- for p in $(ls boringssl-*.patch); do patch -p1 < $p; done && \
46
- mkdir build && cd build && \
47
- cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=on -GNinja .. && \
48
- ninja
40
+ # Needed for building libnss
41
+ RUN pip install gyp-next
42
+
43
+ ARG NSS_VERSION=nss-3.77
44
+ # This tarball is already bundled with nspr, a dependency of libnss.
45
+ ARG NSS_URL=https://ftp.mozilla.org/pub/security/nss/releases/NSS_3_77_RTM/src/nss-3.77-with-nspr-4.32.tar.gz
49
46
50
- # Fix the directory structure so that curl can compile against it.
51
- # See https://everything.curl.dev/source/build/tls/boringssl
52
- RUN mkdir boringssl/build/lib && \
53
- ln -s ../crypto/libcrypto.a boringssl/build/lib/libcrypto.a && \
54
- ln -s ../ssl/libssl.a boringssl/build/lib/libssl.a && \
55
- cp -R boringssl/include boringssl/build
47
+ # Download and compile nss.
48
+ RUN curl -o ${NSS_VERSION}.tar.gz ${NSS_URL}
49
+ RUN tar xf ${NSS_VERSION}.tar.gz && \
50
+ cd ${NSS_VERSION}/nss && \
51
+ ./build.sh -o --disable-tests --static --python=python3
56
52
57
53
ARG NGHTTP2_VERSION=nghttp2-1.46.0
58
54
ARG NGHTTP2_URL=https://github.com/nghttp2/nghttp2/releases/download/v1.46.0/nghttp2-1.46.0.tar.bz2
@@ -85,15 +81,15 @@ RUN cd ${CURL_VERSION} && \
85
81
--disable-shared \
86
82
--with-nghttp2=/build/${NGHTTP2_VERSION}/installed \
87
83
--with-brotli=/build/brotli-${BROTLI_VERSION}/build/installed \
88
- --with-openssl =/build/boringssl/build \
89
- LIBS= "-pthread" \
90
- CFLAGS="-I/build/boringssl/ build" \
84
+ --with-nss =/build/${NSS_VERSION}/dist/Release \
85
+ --with-nss-deprecated \
86
+ CFLAGS="-I/build/${NSS_VERSION}/dist/public/nss -I/ build/${NSS_VERSION}/dist/Release/include/nspr " \
91
87
USE_CURL_SSLKEYLOGFILE=true && \
92
88
make && make install
93
89
94
90
RUN mkdir out && \
95
- cp /build/install/bin/curl-impersonate-chrome out/ && \
96
- ln -s curl-impersonate-chrome out/curl-impersonate && \
91
+ cp /build/install/bin/curl-impersonate-ff out/ && \
92
+ ln -s curl-impersonate-ff out/curl-impersonate && \
97
93
strip out/curl-impersonate
98
94
99
95
# Verify that the resulting 'curl' has all the necessary features.
@@ -112,18 +108,18 @@ RUN cd ${CURL_VERSION} && \
112
108
./configure --prefix=/build/install \
113
109
--with-nghttp2=/build/${NGHTTP2_VERSION}/installed \
114
110
--with-brotli=/build/brotli-${BROTLI_VERSION}/build/installed \
115
- --with-openssl =/build/boringssl/build \
116
- LIBS= "-pthread" \
117
- CFLAGS="-I/build/boringssl/ build" \
111
+ --with-nss =/build/${NSS_VERSION}/dist/Release \
112
+ --with-nss-deprecated \
113
+ CFLAGS="-I/build/${NSS_VERSION}/dist/public/nss -I/ build/${NSS_VERSION}/dist/Release/include/nspr " \
118
114
USE_CURL_SSLKEYLOGFILE=true && \
119
115
make clean && make && make install
120
116
121
117
# Copy libcurl-impersonate and symbolic links
122
118
RUN cp -d /build/install/lib/libcurl-impersonate* /build/out
123
119
124
- RUN ver=$(readlink -f ${CURL_VERSION}/lib/.libs/libcurl-impersonate-chrome .so | sed 's/.*so\. //' ) && \
120
+ RUN ver=$(readlink -f ${CURL_VERSION}/lib/.libs/libcurl-impersonate-ff .so | sed 's/.*so\. //' ) && \
125
121
major=$(echo -n $ver | cut -d'.' -f1) && \
126
- ln -s "libcurl-impersonate-chrome .so.$ver" "out/libcurl-impersonate.so.$ver" && \
122
+ ln -s "libcurl-impersonate-ff .so.$ver" "out/libcurl-impersonate.so.$ver" && \
127
123
ln -s "libcurl-impersonate.so.$ver" "out/libcurl-impersonate.so" && \
128
124
strip "out/libcurl-impersonate.so.$ver"
129
125
@@ -132,26 +128,27 @@ RUN ver=$(readlink -f ${CURL_VERSION}/lib/.libs/libcurl-impersonate-chrome.so |
132
128
RUN ! (ldd ./out/curl-impersonate | grep -q -e nghttp2 -e brotli -e ssl -e crypto)
133
129
134
130
# Wrapper scripts
135
- COPY curl_chrome* curl_edge* curl_safari* out/
131
+ COPY curl_ff* out/
132
+
136
133
137
134
# Create a final, minimal image with the compiled binaries
138
135
# only.
139
- FROM python:3.10-buster
136
+ FROM ubuntu:22.10
137
+
138
+ RUN apt-get update && apt-get install -y ca-certificates
139
+ RUN apt-get install -y libnss3 nss-plugin-pem wget python3 python3-pip
140
140
141
- RUN apt update -y && apt install libbrotli-dev libunwind-dev libssl-dev libnghttp2-dev -y
142
141
# Copy curl-impersonate from the builder image
143
142
COPY --from=builder /build/install /usr/local
144
143
RUN ldconfig
145
- # RUN apk add gcc libc-dev openssl-dev brotli
146
-
147
144
# Copy to /build/out as well for backward compatibility with previous versions.
148
145
COPY --from=builder /build/out /build/out
149
146
# Wrapper scripts
150
147
COPY --from=builder /build/out/curl_* /usr/local/bin/
151
148
152
149
RUN wget https://github.com/pycurl/pycurl/archive/refs/tags/REL_7_45_2.tar.gz && tar -xzf REL_7_45_2.tar.gz
153
-
154
- RUN cd pycurl-REL_7_45_2 && python3 setup.py install --curl-config=/usr/local/bin/curl-impersonate-chrome-config
155
-
150
+ RUN cd pycurl-REL_7_45_2 && python3 setup.py install --curl-config=/usr/local/bin/curl-impersonate-ff-config
156
151
RUN pip install request_curl
157
152
153
+ CMD ["python3" ]
154
+
0 commit comments