From e591d350e0fb074558bab92ac7a75e051b92b0d9 Mon Sep 17 00:00:00 2001 From: Usama Sadiq Date: Wed, 26 Jun 2024 18:39:48 +0500 Subject: [PATCH] build: update Dockerfile to use Python 3.12 --- Dockerfile | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 71026f2a..1ebb8880 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,17 @@ FROM ubuntu:focal as base # System requirements. +# ENV variables for Python 3.12 support +ARG PYTHON_VERSION=3.12 +ENV TZ=UTC +ENV TERM=xterm-256color +ENV DEBIAN_FRONTEND=noninteractive + +# software-properties-common is needed to setup Python 3.12 env +RUN apt-get update && \ + apt-get install -y software-properties-common && \ + apt-add-repository -y ppa:deadsnakes/ppa + # pkg-config; mysqlclient>=2.2.0 requires pkg-config (https://github.com/PyMySQL/mysqlclient/issues/620) RUN apt update && \ @@ -10,14 +21,24 @@ RUN apt update && \ vim \ language-pack-en \ build-essential \ - python3.8-dev \ - python3-virtualenv \ - python3.8-distutils \ + libffi-dev \ + libsqlite3-dev \ + python3-pip \ + python${PYTHON_VERSION} \ + python${PYTHON_VERSION}-dev \ + python${PYTHON_VERSION}-distutils \ libmysqlclient-dev \ pkg-config \ libssl-dev && \ rm -rf /var/lib/apt/lists/* +# Set Zoneinfo settings for Python 3.12 support +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +# need to use virtualenv pypi package with Python 3.12 +RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python${PYTHON_VERSION} +RUN pip install virtualenv + # Use UTF-8. RUN locale-gen en_US.UTF-8 ENV LANG en_US.UTF-8 @@ -39,7 +60,7 @@ ENV ANALYTICS_API_CFG "/edx/etc/${ANALYTICS_API_SERVICE_NAME}.yml" # Working directory will be root of repo. WORKDIR ${ANALYTICS_API_CODE_DIR} -RUN virtualenv -p python3.8 --always-copy ${ANALYTICS_API_VENV_DIR} +RUN virtualenv -p python${PYTHON_VERSION} --always-copy ${ANALYTICS_API_VENV_DIR} # Expose canonical Analytics port EXPOSE 19001