From 19157d94bca8a4998271082045448a919bcd4761 Mon Sep 17 00:00:00 2001 From: Maxim Beder Date: Wed, 17 Nov 2021 19:37:35 +0100 Subject: [PATCH] feat: allow to specify extra pip packages in config Added OPENEDX_EXTRA_PIP_REQUIREMENTS setting, which allows to specify extra pip packages that should be installed. Moved "openedx-scorm-xblock" package from Dockerfile to the new setting in the config.yml. --- CHANGELOG.md | 1 + docs/configuration.rst | 26 +++++++++++++++++++++++- tutor/templates/build/openedx/Dockerfile | 6 +++--- tutor/templates/config.yml | 2 ++ 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f11ac0..8f90cc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ Note: Breaking changes between versions are indicated by "💥". ## Unreleased - [Bugfix] Remove trailing slashes in docker-compose files for [compatibility with docker-compose v2 in WSL](https://github.com/docker/compose/issues/8558). - [Improvement] `settheme` now works with preview domain. +- [Feature] Allow specifying extra pip packages through config.yml. ## v12.1.7 (2021-11-18) diff --git a/docs/configuration.rst b/docs/configuration.rst index e305901..d8044d5 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -93,6 +93,12 @@ By default there are 2 `uwsgi worker processes =12.0.0``) + +This defines extra pip packages that are going to be installed for Open edX. + Vendor services ~~~~~~~~~~~~~~~ @@ -237,14 +243,32 @@ See :ref:`the corresponding tutorial `. Installing extra xblocks and requirements ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Would you like to include custom xblocks, or extra requirements to your Open edX platform? Additional requirements can be added to the ``env/build/openedx/requirements/private.txt`` file. For instance, to include the `polling xblock from Opencraft `_:: +Would you like to include custom xblocks, or extra requirements to your Open edX platform? Additional requirements can be added to the ``OPENEDX_EXTRA_PIP_REQUIREMENTS`` parameter in the :ref:`config file ` or to the ``env/build/openedx/requirements/private.txt`` file. The difference between them, is that ``private.txt`` file, even though it could be used for both, :ref:`should be used for installing extra xblocks or requirements from private repositories `. For instance, to include the `polling xblock from Opencraft `_: + +- add the following to the ``config.yml``:: + + OPENEDX_EXTRA_PIP_REQUIREMENTS: + - "git+https://github.com/open-craft/xblock-poll.git" + +.. warning:: + Specifying extra requirements through ``config.yml`` overwrites :ref:`the default extra requirements`. You might need to add them to the list, if your configuration depends on them. + +- or add the dependency to ``private.txt``:: echo "git+https://github.com/open-craft/xblock-poll.git" >> "$(tutor config printroot)/env/build/openedx/requirements/private.txt" + Then, the ``openedx`` docker image must be rebuilt:: tutor images build openedx +.. _extra_private_xblocks: + +Installing extra requirements from private repositories +******************************************************* + +When installing extra xblock or requirements from private repositories, ``private.txt`` file should be used, because it allows to install dependencies without adding git credentials to the Docker image. By adding your git credentials to the Docker image, you're risking leaking your git credentials, if you were to publish (intentionally or unintentionally) the Docker image in a public place. + To install xblocks from a private repository that requires authentication, you must first clone the repository inside the ``openedx/requirements`` folder on the host:: git clone git@github.com:me/myprivaterepo.git "$(tutor config printroot)/env/build/openedx/requirements/myprivaterepo" diff --git a/tutor/templates/build/openedx/Dockerfile b/tutor/templates/build/openedx/Dockerfile index 1da4334..9da4463 100644 --- a/tutor/templates/build/openedx/Dockerfile +++ b/tutor/templates/build/openedx/Dockerfile @@ -81,9 +81,6 @@ RUN pip install setuptools==44.1.0 pip==20.0.2 wheel==0.34.2 # Install base requirements RUN pip install -r ./requirements/edx/base.txt -# Install scorm xblock -RUN pip install "openedx-scorm-xblock<13.0.0,>=12.0.0" - # Install django-redis for using redis as a django cache RUN pip install django-redis==4.12.1 @@ -98,6 +95,9 @@ RUN cd /openedx/requirements/ \ && touch ./private.txt \ && pip install -r ./private.txt +{% for extra_requirements in OPENEDX_EXTRA_PIP_REQUIREMENTS %}RUN pip install '{{ extra_requirements }}' +{% endfor %} + ###### Install nodejs with nodeenv in /openedx/nodeenv FROM python as nodejs-requirements ENV PATH /openedx/nodeenv/bin:/openedx/venv/bin:${PATH} diff --git a/tutor/templates/config.yml b/tutor/templates/config.yml index eaa6b92..c996179 100644 --- a/tutor/templates/config.yml +++ b/tutor/templates/config.yml @@ -62,6 +62,8 @@ OPENEDX_MYSQL_DATABASE: "openedx" OPENEDX_CSMH_MYSQL_DATABASE: "{{ OPENEDX_MYSQL_DATABASE }}_csmh" OPENEDX_MYSQL_USERNAME: "openedx" OPENEDX_COMMON_VERSION: "open-release/lilac.3" +OPENEDX_EXTRA_PIP_REQUIREMENTS: + - "openedx-scorm-xblock<13.0.0,>=12.0.0" MYSQL_HOST: "mysql" MYSQL_PORT: 3306 MYSQL_ROOT_USERNAME: "root"