Skip to content

Commit baacfa6

Browse files
Don't build python for no reason. Copy it (#1690)
1 parent 6ca6757 commit baacfa6

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

docker/benchmark-builder/Dockerfile

+11-18
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
ARG parent_image
1616

17+
# Using multi-stage build to copy latest Python 3.
18+
FROM gcr.io/fuzzbench/base-image AS base-image
19+
1720
FROM $parent_image
1821

1922
ARG fuzzer
@@ -24,36 +27,26 @@ ENV FUZZER $fuzzer
2427
ENV BENCHMARK $benchmark
2528
ENV DEBUG_BUILDER $debug_builder
2629

27-
# Python 3.10.8 is not the default version in Ubuntu 20.04 (Focal Fossa).
28-
ENV PYTHON_VERSION 3.10.8
2930

3031
# Install dependencies required by Python3 or Pip3.
3132
RUN apt-get update && \
3233
apt-get upgrade -y && \
3334
apt-get install -y \
3435
curl \
3536
xz-utils \
36-
build-essential \
3737
zlib1g-dev \
3838
libssl-dev \
3939
libffi-dev
4040

41-
RUN cd /tmp/ && \
42-
curl -O \
43-
https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tar.xz && \
44-
tar -xvf Python-$PYTHON_VERSION.tar.xz > /dev/null && \
45-
cd Python-$PYTHON_VERSION && \
46-
./configure \
47-
--enable-loadable-sqlite-extensions \
48-
--enable-optimizations \
49-
> /dev/null && \
50-
make -j install > /dev/null && \
51-
rm -r /tmp/Python-$PYTHON_VERSION.tar.xz /tmp/Python-$PYTHON_VERSION
52-
53-
# Install common python dependencies.
54-
COPY ./requirements.txt /tmp
55-
RUN pip3 install -r /tmp/requirements.txt
41+
RUN rm -rf /usr/local/bin/python3.8* /usr/local/bin/pip3 /usr/local/lib/python3.8 \
42+
/usr/local/include/python3.8 /usr/local/lib/python3.8/site-packages
5643

44+
# Copy latest python3 from base-image into local.
45+
COPY --from=base-image /usr/local/bin/python3* /usr/local/bin/
46+
COPY --from=base-image /usr/local/bin/pip3* /usr/local/bin/
47+
COPY --from=base-image /usr/local/lib/python3.10 /usr/local/lib/python3.10
48+
COPY --from=base-image /usr/local/include/python3.10 /usr/local/include/python3.10
49+
COPY --from=base-image /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages
5750

5851
# Copy the entire fuzzers directory tree to allow for module dependencies.
5952
COPY fuzzers $SRC/fuzzers

0 commit comments

Comments
 (0)