From 37d510056e11b0ce628943edae470a195f644f44 Mon Sep 17 00:00:00 2001 From: Usama Sadiq Date: Tue, 5 Nov 2024 16:13:34 +0500 Subject: [PATCH 1/4] build: Update edx-notes-api Dockerfile to use Python 3.12 --- dockerfiles/edx-notes-api.Dockerfile | 32 +++++++++++++++++++--------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/dockerfiles/edx-notes-api.Dockerfile b/dockerfiles/edx-notes-api.Dockerfile index 4d570df..4aebfdc 100644 --- a/dockerfiles/edx-notes-api.Dockerfile +++ b/dockerfiles/edx-notes-api.Dockerfile @@ -7,7 +7,7 @@ FROM ubuntu:focal AS app # language-pack-en locales; ubuntu locale support so that system utilities have a consistent # language and time zone. -# python3.8-dev; to install python 3.8 +# python3.12-dev; to install python 3.12 # python3-venv; installs venv module required to create virtual environments # libssl-dev; # mysqlclient wont install without this. @@ -17,29 +17,44 @@ FROM ubuntu:focal AS app # If you add a package here please include a comment above describing what it is used for +# ENV variables for Python 3.12 support +ARG PYTHON_VERSION=3.12 +ENV TZ=UTC +ENV TERM=xterm-256color +ENV DEBIAN_FRONTEND=noninteractive + RUN apt-get update && \ apt-get install -y software-properties-common && \ apt-add-repository -y ppa:deadsnakes/ppa && \ apt-get update && apt-get upgrade -qy && \ apt-get install \ + build-essential \ language-pack-en \ locales \ git \ - libmysqlclient-dev \ + curl \ pkg-config \ libssl-dev \ - build-essential \ - python3.8-dev \ - python3.8-distutils \ - python3-virtualenv -qy && \ + libffi-dev \ + libsqlite3-dev \ + libmysqlclient-dev \ + python3-pip \ + python{PYTHON_VERSION} \ + python{PYTHON_VERSION}-dev \ + python{PYTHON_VERSION}-distutils && \ rm -rf /var/lib/apt/lists/* +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone +RUN ln -s /usr/bin/python3 /usr/bin/python RUN locale-gen en_US.UTF-8 ENV LANG=en_US.UTF-8 ENV LANGUAGE=en_US:en ENV LC_ALL=en_US.UTF-8 +# 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 # ENV variables lifetime is bound to the container whereas ARGS variables lifetime is bound to the image building process only # Also ARGS provide us an option of compatibility of Path structure for Tutor and other OpenedX installations @@ -51,12 +66,9 @@ ENV PATH="$NOTES_VENV_DIR/bin:$PATH" RUN useradd -m --shell /bin/false app -# Install curl -RUN apt-get update && apt-get install -y curl - RUN mkdir -p requirements -RUN virtualenv -p python3.8 --always-copy ${NOTES_VENV_DIR} +RUN virtualenv -p python{PYTHON_VERSION} --always-copy ${NOTES_VENV_DIR} RUN pip install --upgrade pip setuptools From abb4dd6d46046a699900ea115aee99ac44231fa1 Mon Sep 17 00:00:00 2001 From: Usama Sadiq Date: Tue, 5 Nov 2024 16:14:41 +0500 Subject: [PATCH 2/4] test: test edx-notes-api image build workflow on PR --- .github/workflows/push-edx-notes-api-image.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/push-edx-notes-api-image.yaml b/.github/workflows/push-edx-notes-api-image.yaml index 8ad2558..71d1f11 100644 --- a/.github/workflows/push-edx-notes-api-image.yaml +++ b/.github/workflows/push-edx-notes-api-image.yaml @@ -8,6 +8,8 @@ on: schedule: - cron: "0 4 * * 1-5" # UTC Time + + pull_request: jobs: build-and-push-image: @@ -41,7 +43,7 @@ jobs: file: ./dockerfiles/edx-notes-api.Dockerfile push: true target: dev - tags: edxops/edx-notes-api-dev:${{ steps.get-tag-name.outputs.result }} + tags: edxops/edx-notes-api-dev:test platforms: linux/amd64,linux/arm64 - name: Send failure notification From dae025bdf5e8b6e056d0ccd3300b1b0a1d6338cc Mon Sep 17 00:00:00 2001 From: Usama Sadiq Date: Tue, 5 Nov 2024 16:22:48 +0500 Subject: [PATCH 3/4] build: update edx-notes-api dockerfile --- dockerfiles/edx-notes-api.Dockerfile | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/dockerfiles/edx-notes-api.Dockerfile b/dockerfiles/edx-notes-api.Dockerfile index 4aebfdc..7707c16 100644 --- a/dockerfiles/edx-notes-api.Dockerfile +++ b/dockerfiles/edx-notes-api.Dockerfile @@ -23,25 +23,26 @@ 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 && \ - apt-get update && apt-get upgrade -qy && \ - apt-get install \ + apt-get install -y software-properties-common && \ + apt-add-repository -y ppa:deadsnakes/ppa + +RUN apt-get update && apt-get -qy install --no-install-recommends \ build-essential \ language-pack-en \ locales \ - git \ - curl \ pkg-config \ libssl-dev \ libffi-dev \ libsqlite3-dev \ libmysqlclient-dev \ + git \ + curl \ python3-pip \ - python{PYTHON_VERSION} \ - python{PYTHON_VERSION}-dev \ - python{PYTHON_VERSION}-distutils && \ + python${PYTHON_VERSION} \ + python${PYTHON_VERSION}-dev \ + python${PYTHON_VERSION}-distutils && \ rm -rf /var/lib/apt/lists/* RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone @@ -68,7 +69,7 @@ RUN useradd -m --shell /bin/false app RUN mkdir -p requirements -RUN virtualenv -p python{PYTHON_VERSION} --always-copy ${NOTES_VENV_DIR} +RUN virtualenv -p python${PYTHON_VERSION} --always-copy ${NOTES_VENV_DIR} RUN pip install --upgrade pip setuptools From 5ba8b000f767138ef691dccc299accd518e5e2cf Mon Sep 17 00:00:00 2001 From: Usama Sadiq Date: Tue, 5 Nov 2024 16:51:40 +0500 Subject: [PATCH 4/4] test: remove test changes from PR --- .github/workflows/push-edx-notes-api-image.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/push-edx-notes-api-image.yaml b/.github/workflows/push-edx-notes-api-image.yaml index 71d1f11..8ad2558 100644 --- a/.github/workflows/push-edx-notes-api-image.yaml +++ b/.github/workflows/push-edx-notes-api-image.yaml @@ -8,8 +8,6 @@ on: schedule: - cron: "0 4 * * 1-5" # UTC Time - - pull_request: jobs: build-and-push-image: @@ -43,7 +41,7 @@ jobs: file: ./dockerfiles/edx-notes-api.Dockerfile push: true target: dev - tags: edxops/edx-notes-api-dev:test + tags: edxops/edx-notes-api-dev:${{ steps.get-tag-name.outputs.result }} platforms: linux/amd64,linux/arm64 - name: Send failure notification