Skip to content

Commit fe77438

Browse files
authored
chore: update python post processor base image (#2123)
1 parent edc28c4 commit fe77438

File tree

3 files changed

+288
-296
lines changed

3 files changed

+288
-296
lines changed

‎docker/owlbot/python/Dockerfile‎

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,53 @@
1616

1717
# build from the root of this repo:
1818
# docker build -t gcr.io/repo-automation-bots/owlbot-python -f docker/owlbot/python/Dockerfile .
19-
FROM python:3.10.6-buster
19+
FROM marketplace.gcr.io/google/ubuntu2404
2020

21-
WORKDIR /
21+
RUN apt-get update && \
22+
apt-get install -y --no-install-recommends \
23+
# Essential for compiling C code
24+
build-essential \
25+
git \
26+
wget \
27+
ca-certificates \
28+
libssl-dev \
29+
zlib1g-dev \
30+
libbz2-dev \
31+
libffi-dev \
32+
libsqlite3-dev \
33+
libreadline-dev \
34+
# ------------------------------------------------------
35+
&& apt-get clean && \
36+
rm -rf /var/lib/apt/lists/*
2237

23-
###################### Install python 3.8.11
38+
# Install multiple Python versions from source. `make altinstall` is used to
39+
# prevent replacing the system's default python binary.
40+
# TODO(http://github.com/googleapis/gapic-generator-python/issues/2435): Remove `3.10.18` when the linked issue is resolved.
41+
RUN for PYTHON_VERSION in 3.10.18 3.13.5; do \
42+
wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz && \
43+
tar -xvf Python-${PYTHON_VERSION}.tgz && \
44+
cd Python-${PYTHON_VERSION} && \
45+
./configure --enable-optimizations --prefix=/usr/local && \
46+
make -j$(nproc) && \
47+
make altinstall && \
48+
cd / && \
49+
rm -rf Python-${PYTHON_VERSION}* \
50+
; done
2451

25-
# Download python 3.8.11
26-
RUN wget https://www.python.org/ftp/python/3.8.11/Python-3.8.11.tgz
52+
# Install pip for each python version
53+
# TODO(http://github.com/googleapis/gapic-generator-python/issues/2435): Remove `3.10` when the linked issue is resolved.
54+
RUN wget --no-check-certificate -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' && \
55+
for PYTHON_VERSION in 3.10 3.13; do \
56+
python${PYTHON_VERSION} /tmp/get-pip.py; \
57+
done && \
58+
rm /tmp/get-pip.py
2759

28-
# Extract files
29-
RUN tar -xvf Python-3.8.11.tgz
3060

31-
# Install python 3.8.11
32-
RUN ./Python-3.8.11/configure --enable-optimizations
33-
RUN make altinstall
61+
WORKDIR /
3462

3563
###################### Install synthtool's requirements.
3664
COPY requirements.txt /synthtool/requirements.txt
37-
RUN pip install --require-hashes -r /synthtool/requirements.txt
65+
RUN python3.10 -m pip install --require-hashes -r /synthtool/requirements.txt
3866

3967
# Put synthtool in the PYTHONPATH so owlbot.py scripts will find it.
4068
ENV PYTHONPATH="/synthtool"

‎docker/owlbot/python/entrypoint.sh‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ set -e
1717
set -x
1818

1919
if [ -f owlbot.py ]; then
20-
python owlbot.py
20+
python3.10 owlbot.py
2121
else
22-
python -m synthtool.languages.python
22+
python3.10 -m synthtool.languages.python
2323
fi

0 commit comments

Comments
 (0)