Skip to content

Commit 2b78c27

Browse files
authored
Upgrade to Debian Bookworm and Python 3.11 (#4028)
This commit upgrades the Debian distro to Bookworm, which requires an update in the Python (3.11) and Java (17) versions. It also comes with an update to the Google Cloud CLI package names and repository secret installation (the recommended approach in the deprecation section of man apt-key). This is a prerequisite for upgrading to Go 1.23. Had to run pip-compile requirements.in as part of the process.
1 parent e459c54 commit 2b78c27

File tree

9 files changed

+26
-31
lines changed

9 files changed

+26
-31
lines changed

Dockerfile

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
# vim: set expandtab sw=4
2-
FROM golang:1.22.7-bullseye
2+
FROM golang:1.22.7-bookworm
33

44
# Create a non-priviledged user to run browsers as (Firefox and Chrome do not
55
# like to run as root).
66
RUN chmod a+rx $HOME && useradd --uid 9999 --user-group --create-home browser
77

88
# Sort the package names!
99
# firefox-esr: provides deps for Firefox (we don't use ESR directly)
10-
# openjdk-11-jdk: provides JDK/JRE to Selenium & gcloud SDK
10+
# openjdk-17-jdk: provides JDK/JRE to Selenium & gcloud SDK
1111
# python-crcmod: native module to speed up CRC checksum in gsutil
1212
RUN apt-get update -qqy && apt-get install -qqy --no-install-suggests \
1313
curl \
1414
firefox-esr \
1515
lsb-release \
16-
openjdk-11-jdk \
17-
python3.9 \
16+
openjdk-17-jdk \
17+
python3.11 \
1818
python3-crcmod \
1919
sudo \
2020
tox \
@@ -35,13 +35,14 @@ RUN curl -sL https://deb.nodesource.com/setup_18.x | bash - && \
3535
# Based on https://github.com/GoogleCloudPlatform/cloud-sdk-docker/blob/master/Dockerfile
3636
RUN export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)" && \
3737
echo "deb https://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" > /etc/apt/sources.list.d/google-cloud-sdk.list && \
38-
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - && \
39-
apt-get update -qqy && apt-get install -qqy \
40-
google-cloud-sdk \
41-
google-cloud-sdk-app-engine-python \
42-
google-cloud-sdk-app-engine-python-extras \
43-
google-cloud-sdk-app-engine-go \
44-
google-cloud-sdk-datastore-emulator && \
38+
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" > /etc/apt/sources.list.d/google-cloud-sdk.list && \
39+
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg && \
40+
apt-get update -y && apt-get install -y \
41+
google-cloud-cli \
42+
google-cloud-cli-app-engine-python \
43+
google-cloud-cli-app-engine-python-extras \
44+
google-cloud-cli-app-engine-go \
45+
google-cloud-cli-datastore-emulator && \
4546
gcloud config set core/disable_usage_reporting true && \
4647
gcloud config set component_manager/disable_update_check true && \
4748
gcloud --version

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,15 +229,15 @@ gcc: apt-get-gcc
229229
git: apt-get-git
230230
jq: apt-get-jq
231231
psmisc: apt-get-psmisc
232-
python3: apt-get-python3.9
232+
python3: apt-get-python3.11
233233
tox: apt-get-tox
234234
unzip: apt-get-unzip
235235
wget: apt-get-wget
236236

237237
java:
238238
@ # java has a different apt-get package name.
239239
if [[ "$$(which java)" == "" ]]; then \
240-
sudo apt-get install -qqy --no-install-suggests openjdk-11-jdk; \
240+
sudo apt-get install -qqy --no-install-suggests openjdk-17-jdk; \
241241
fi
242242

243243
gpg:

api/query/cache/service/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Production deployment spec for query cache service.
22

3-
FROM golang:1.22.7-bullseye as builder
3+
FROM golang:1.22.7-bookworm as builder
44

55
RUN apt-get update
66
RUN apt-get install -qy --no-install-suggests git

docs/upgrading-go.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Once you have confirmed that the desired version is available:
1515
- tooling [Dockerfile](../Dockerfile) at the root of the repo
1616
- searchcache [Dockerfile](../api/query/cache/service/Dockerfile)
1717

18-
The tooling image and the first stage of searchcache use the same Golang image. Check out the Golang [page](https://hub.docker.com/_/golang?tab=tags) on Docker Hub for the latest tags. Currently, we are using the `bullseye` [release](https://wiki.debian.org/DebianReleases) of Debian. As a result pick the `golang:<latest stable version>-bullseye` tag. If bullseye is superseded by a new version, you should change that as well.
18+
The tooling image and the first stage of searchcache use the same Golang image. Check out the Golang [page](https://hub.docker.com/_/golang?tab=tags) on Docker Hub for the latest tags. Currently, we are using the `bookworm` [release](https://wiki.debian.org/DebianReleases) of Debian. As a result pick the `golang:<latest stable version>-bookworm` tag. If bookworm is superseded by a new version, you should change that as well.
1919

2020
## Step 3 - Change the version in go.mod
2121

results-processor/.python-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.9
1+
3.11

results-processor/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.9.20-bullseye
1+
FROM python:3.11.9-bookworm
22

33
# Install runtime dependencies.
44
# python3-crcmod for faster gsutil checksum
@@ -17,7 +17,7 @@ RUN gcloud config set disable_usage_reporting false
1717
RUN rm -f $HOME/.config/gcloud/gce
1818

1919
# Setup and activate virtualenv.
20-
RUN virtualenv -p python3.9 /env
20+
RUN virtualenv -p python3.11 /env
2121
ENV VIRTUAL_ENV /env
2222
ENV PATH /env/bin:$PATH
2323

results-processor/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Basics
22

3-
The results processor runs on Python 3.9. The entry point is a Flask web server
3+
The results processor runs on Python 3.11. The entry point is a Flask web server
44
(`main.py`). In production, gunicorn is used as the WSGI (see `Dockerfile`) and
55
the container runs as a custom AppEngine Flex instance (see `app.yaml`).
66

@@ -10,7 +10,7 @@ We can create a virtualenv to recreate a setup close to production for daily
1010
development.
1111

1212
```bash
13-
virtualenv env -p python3.9
13+
virtualenv env -p python3.11
1414
. env/bin/activate
1515
pip install -r requirements.txt
1616
```
@@ -38,8 +38,8 @@ Dependabot is used to automatically update `requirements.txt`. To manually
3838
update dependencies, run the following commands:
3939

4040
```bash
41-
pip3.9 install --user pip-tools
42-
python3.9 -m piptools compile requirements.in
41+
pip3.11 install --user pip-tools
42+
python3.11 -m piptools compile requirements.in
4343
```
4444

4545
## Local debugging

results-processor/requirements.txt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# This file is autogenerated by pip-compile with Python 3.9
2+
# This file is autogenerated by pip-compile with Python 3.11
33
# by the following command:
44
#
55
# pip-compile requirements.in
@@ -53,14 +53,12 @@ grpcio==1.53.2
5353
# via
5454
# google-api-core
5555
# grpcio-status
56-
grpcio-status==1.44.0
56+
grpcio-status==1.53.2
5757
# via google-api-core
5858
gunicorn==23.0.0
5959
# via -r requirements.in
6060
idna==3.7
6161
# via requests
62-
importlib-metadata==6.8.0
63-
# via flask
6462
itsdangerous==2.1.2
6563
# via flask
6664
jinja2==3.1.4
@@ -103,13 +101,9 @@ requests==2.32.3
103101
# google-cloud-storage
104102
rsa==4.8
105103
# via google-auth
106-
tomli==2.0.1
107-
# via mypy
108104
typing-extensions==4.7.1
109105
# via mypy
110106
urllib3==1.26.19
111107
# via requests
112108
werkzeug==3.0.3
113109
# via flask
114-
zipp==3.19.1
115-
# via importlib-metadata

results-processor/tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py39
2+
envlist = py311
33
# We don't have or need setup.py for now.
44
skipsdist=True
55

0 commit comments

Comments
 (0)