diff --git a/CHANGELOG.md b/CHANGELOG.md index 38f1161d57..239925c3d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,45 @@ instructions, because git commits are used to generate release notes: + +## v18.0.0 (2024-06-19) + +- 💥[Feature] Upgrade to Redwood (by @dawoudsheraz) +- [Bugfix] Wrap Django5 warning imports in try-except block to avoid failures in django3 that's still in use in edx-platform's master branch (by @mariajgrimaldi). +- 💥[Feature] Pull translations via `atlas` during Docker build. This breaks the `openedx-i18n` custom locale Tutor feature in favor of [OEP-58](https://docs.openedx.org/en/latest/developers/concepts/oep58.html) in favor of . (by @omarithawi) +- 💥[Feature] The `openedx-assets` command is replaced with `npm run` subcommands. This will slightly reduce the build time for edx-platform assets and comprehensive themes. It will also open up the door for more significant build time reductions in the future. Here is a migration guide, where each command is to be run in the `lms` or `cms` container: + + **Before** | **After** + -----------------------------------------|------------------------------------------------------------------------------------- + `openedx-assets build --env=prod ARGS` | `npm run build -- ARGS` + `openedx-assets build --env=dev ARGS` | `npm run build-dev -- ARGS` + `openedx-assets common --env=prod ARGS` | `npm run compile-sass -- --skip-themes ARGS` + `openedx-assets common --env=dev ARGS` | `npm run compile-sass-dev -- --skip-themes ARGS` + `openedx-assets webpack --env=prod ARGS` | `npm run webpack -- ARGS` + `openedx-assets webpack --env=dev ARGS` | `npm run webpack-dev -- ARGS` + `openedx-assets npm` | `npm run postinstall` (`npm clean-install` runs this automatically) + `openedx-assets xmodule` | (no longer necessary) + `openedx-assets collect ARGS` | `./manage.py lms collectstatic --noinput ARGS && ./manage.py cms collectstatic ARGS` + `openedx-assets watch-themes ARGS` | `npm run watch-themes -- ARGS` + +For more details, see the [deprecation notice for paver](https://github.com/openedx/edx-platform/issues/34467) +and the [static assets reference](https://github.com/openedx/edx-platform/tree/open-release/redwood.master/docs/references/static-assets.rst) +in edx-platform. + +- 💥[Feature] Update MongoDB to v7.0.7 (by @dawoudsheraz) MongoDB is upgraded from version 4.4 to 7.0. Since there have been major releases since 4.4, the upgrade will need to go through them before running Mongo 7. MongoDB would need to follow 4.4 --> 5.0 --> 6.0 --> 7.0 upgrade path to work correctly. The container will keep on restarting with featureCompatibility error if the upgrade path is not followed. To upgrade mongo, run the following command based in the appropriate environment: + + tutor upgrade --from=quince + +For k8s only, the above command will not perform the upgrade automatically. Instead, the command will output a series of commands that would need to be run manually to carry out the upgrade. + +- [Improvement] Upgrade Nodejs from 16.14.0 to 18.20.1 in edx-platform. (by @regisb) +- [Improvement] Auto-detect bind mounts of openedx-learning for edx-platform (by @bradenmacdonald) +- [Feature] Upgrade Open edX image to use Python 3.11 (by @dawoudsheraz) +- [Bugfix] Remove CORS_ALLOW_HEADERS setting from the LMS/Studio config template. This setting, which holds site-agnostic application logic, is now consistently set to a reasonable value upstream by LMS and CMS config. Using the upstream values fixes a bug where course import in Studio using the new Course Authoring MFE was broken in Tutor deployments because it required additional headers to be allowed (content-range and content-disposition) (by @ormsbee) +- [Improvement] Made Docker cache hits more frequent during the openedx image build via BuildKit's `COPY --link` feature (by @kdmccormick). +- 💥[Improvement] Upgrade MySQL to 8.4.0. The upgrade should be automatic for most users. However, if you are running a third-party MySQL (i.e., RUN_MYSQL=false), you are expected to upgrade manually. Please refer to the third-party provider's documentation for detailed upgrade instructions. Ensuring that your MySQL version is up-to-date is crucial for maintaining compatibility and security. (by @rohansaeed) +- 💥[Improvement] Ensure that the edx-platform repository git checkout is cached by Docker during image build. This means that the cache will automatically be cleared any time there is an upstream change. Thus, it is no longer necessary to run `tutor images build --no-cache` just to fetch the latest edx-platform changes. For this to work, any GitHub repository referenced by `EDX_PLATFORM_REPOSITORY` needs to end with ".git". Make sure that this is the case if you have modified the value of this setting in the past. (by @regisb) + ## v17.0.6 (2024-06-13) diff --git a/docs/__init__.py b/docs/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/configuration.rst b/docs/configuration.rst index af8a4c8264..4897a46206 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -75,13 +75,13 @@ This configuration parameter defines which Caddy Docker image to use. This configuration parameter defines which Elasticsearch Docker image to use. -- ``DOCKER_IMAGE_MONGODB`` (default: ``"docker.io/mongo:4.4.22"``) +- ``DOCKER_IMAGE_MONGODB`` (default: ``"docker.io/mongo:7.0.7"``) This configuration parameter defines which MongoDB Docker image to use. .. https://hub.docker.com/_/mysql/tags?page=1&name=8.0 -- ``DOCKER_IMAGE_MYSQL`` (default: ``"docker.io/mysql:8.1.0"``) +- ``DOCKER_IMAGE_MYSQL`` (default: ``"docker.io/mysql:8.4.0"``) This configuration parameter defines which MySQL Docker image to use. @@ -132,7 +132,7 @@ Open edX customisation This defines the git repository from which you install Open edX platform code. If you run an Open edX fork with custom patches, set this to your own git repository. You may also override this configuration parameter at build time, by providing a ``--build-arg`` option. -- ``OPENEDX_COMMON_VERSION`` (default: ``"open-release/quince.1"``, or ``master`` in :ref:`nightly `) +- ``OPENEDX_COMMON_VERSION`` (default: ``"open-release/redwood.1"``, or ``master`` in :ref:`nightly `) This defines the default version that will be pulled from all Open edX git repositories. @@ -378,74 +378,28 @@ Note that your edx-platform version must be a fork of the latest release **tag** If you don't create your fork from this tag, you *will* have important compatibility issues with other services. In particular: -- Do not try to run a fork from an older (pre-Quince) version of edx-platform: this will simply not work. +- Do not try to run a fork from an older (pre-Redwood) version of edx-platform: this will simply not work. - Do not try to run a fork from the edx-platform master branch: there is a 99% probability that it will fail. -- Do not try to run a fork from the open-release/quince.master branch: Tutor will attempt to apply security and bug fix patches that might already be included in the open-release/quince.master but which were not yet applied to the latest release tag. Patch application will thus fail if you base your fork from the open-release/quince.master branch. +- Do not try to run a fork from the open-release/redwood.master branch: Tutor will attempt to apply security and bug fix patches that might already be included in the open-release/redwood.master but which were not yet applied to the latest release tag. Patch application will thus fail if you base your fork from the open-release/redwood.master branch. .. _i18n: -Adding custom translations -~~~~~~~~~~~~~~~~~~~~~~~~~~ +Getting and customizing Translations +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -If you are not running Open edX in English (``LANGUAGE_CODE`` default: ``"en"``), chances are that some strings will not be properly translated. In most cases, this is because not enough contributors have helped translate Open edX into your language. It happens! With Tutor, available translated languages include those that come bundled with `edx-platform `__ as well as those from `openedx-i18n `__. +Tutor builds images with the latest translations using the ```atlas pull`` command `__. -Tutor offers a relatively simple mechanism to add custom translations to the openedx Docker image. You should create a folder that corresponds to your language code in the "build/openedx/locale" folder of the Tutor environment. This folder should contain a "LC_MESSAGES" folder. For instance:: +By default the translations are pulled from the `openedx-translations repository `_ +from the ``ATLAS_REVISION`` branch. You can use custom translations on your fork of the openedx-translations repository by setting the following configuration parameters: - mkdir -p "$(tutor config printroot)/env/build/openedx/locale/fr/LC_MESSAGES" +- ``ATLAS_REVISION`` (default: ``"main"`` on nightly and ``"{{ OPENEDX_COMMON_VERSION }}"`` if a named release is used) +- ``ATLAS_REPOSITORY`` (default: ``"openedx/openedx-translations"``). There's a feature request to `support GitLab and other providers `_. +- ``ATLAS_OPTIONS`` (default: ``""``) Pass additional arguments to ``atlas pull``. Refer to the `atlas documentations `_ for more information. -The language code should be similar to those used in edx-platform or openedx-i18n (see links above). - -Then, add a "django.po" file there that will contain your custom translations:: - - msgid "" - msgstr "" - "Content-Type: text/plain; charset=UTF-8" - - msgid "String to translate" - msgstr "你翻译的东西 la traduction de votre bidule" - - -.. warning:: - Don't forget to specify the file ``Content-Type`` when adding message strings with non-ASCII characters; otherwise a ``UnicodeDecodeError`` will be raised during compilation. - -The "String to translate" part should match *exactly* the string that you would like to translate. You cannot make it up! The best way to find this string is to copy-paste it from the `upstream django.po file for the English language `__. - -If you cannot find the string to translate in this file, then it means that you are trying to translate a string that is used in some piece of javascript code. Those strings are stored in a different file named "djangojs.po". You can check it out `in the edx-platform repo as well `__. Your custom javascript strings should also be stored in a "djangojs.po" file that should be placed in the same directory. - -To recap, here is an example. To translate a few strings in French, both from django.po and djangojs.po, we would have the following file hierarchy:: - - $(tutor config printroot)/env/build/openedx/locale/ - fr/ - LC_MESSAGES/ - django.po - djangojs.po - -With django.po containing:: - - msgid "" - msgstr "" - "Content-Type: text/plain; charset=UTF-8" - - msgid "It works! Powered by Open edX{registered_trademark}" - msgstr "Ça marche ! Propulsé by Open edX{registered_trademark}" - -And djangojs.po:: - - msgid "" - msgstr "" - "Content-Type: text/plain; charset=UTF-8" - - msgid "%(num_points)s point possible (graded, results hidden)" - msgid_plural "%(num_points)s points possible (graded, results hidden)" - msgstr[0] "%(num_points)s point possible (noté, résultats cachés)" - msgstr[1] "%(num_points)s points possibles (notés, résultats cachés)" - -Then you will have to re-build the openedx Docker image:: - - tutor images build openedx - -Beware that this will take a long time! Unfortunately, it's difficult to accelerate this process, as translation files need to be compiled before collecting the assets. In development it's possible to accelerate the iteration loop -- but that exercise is left to the reader. +If you are not running Open edX in English (``LANGUAGE_CODE`` default: ``"en"``), chances are that some strings will not be properly translated. In most cases, this is because not enough contributors have helped translate Open edX into your language. It happens! +With ``atlas``, it's possible to add custom translations by either `contributing to the Translations project in Transifex `_ or forking the `openedx-translations repository `_ +and making custom changes as explained in `the repository docs `_. Running a different ``openedx`` Docker image ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/dev.rst b/docs/dev.rst index f67c53cc0e..c7c95616e7 100644 --- a/docs/dev.rst +++ b/docs/dev.rst @@ -99,9 +99,9 @@ To open a python shell in the LMS or CMS, run:: You can then import edx-platform and django modules and execute python code. -To rebuild assets, you can use the ``openedx-assets`` command that ships with Tutor:: +To rebuild assets, you can run the ``build-dev`` NPM script that comes with edx-plaform:: - tutor dev run lms openedx-assets build --env=dev + tutor dev run lms npm run build-dev .. _specialized for developer usage: @@ -113,7 +113,7 @@ The ``openedx-dev`` Docker image is based on the same ``openedx`` image used by - The user that runs inside the container has the same UID as the user on the host, to avoid permission problems inside mounted volumes (and in particular in the edx-platform repository). - Additional Python and system requirements are installed for convenient debugging: `ipython `__, `ipdb `__, vim, telnet. -- The edx-platform `development requirements `__ are installed. +- The edx-platform `development requirements `__ are installed. If you are using a custom ``openedx`` image, then you will need to rebuild ``openedx-dev`` every time you modify ``openedx``. To so, run:: diff --git a/docs/install.rst b/docs/install.rst index b058ddced5..7645fbf49d 100644 --- a/docs/install.rst +++ b/docs/install.rst @@ -123,11 +123,11 @@ Major Open edX releases are published twice a year, in June and December, by the 4. Test the new release in a sandboxed environment. 5. If you are running edx-platform, or some other repository from a custom branch, then you should rebase (and test) your changes on top of the latest release tag (see :ref:`edx_platform_fork`). -The process for upgrading from one major release to the next works similarly to any other upgrade, with the ``launch`` command (see above). The single difference is that if the ``launch`` command detects that your tutor environment was generated with an older release, it will perform a few release-specific upgrade steps. These extra upgrade steps will be performed just once. But they will be ignored if you updated your local environment (for instance: with ``tutor config save``) before running ``launch``. This situation typically occurs if you need to re-build some Docker images (see above). In such a case, you should make use of the ``upgrade`` command. For instance, to upgrade a local installation from Palm to Quince and rebuild some Docker images, run:: +The process for upgrading from one major release to the next works similarly to any other upgrade, with the ``launch`` command (see above). The single difference is that if the ``launch`` command detects that your tutor environment was generated with an older release, it will perform a few release-specific upgrade steps. These extra upgrade steps will be performed just once. But they will be ignored if you updated your local environment (for instance: with ``tutor config save``) before running ``launch``. This situation typically occurs if you need to re-build some Docker images (see above). In such a case, you should make use of the ``upgrade`` command. For instance, to upgrade a local installation from Quince to Redwood and rebuild some Docker images, run:: tutor config save tutor images build all # list the images that should be rebuilt here - tutor local upgrade --from=palm + tutor local upgrade --from=quince tutor local launch .. _autocomplete: diff --git a/docs/quickstart.rst b/docs/quickstart.rst index 58cf4d4e32..0c774f8b4a 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -22,7 +22,7 @@ Yes :) This is what happens when you run ``tutor local launch``: 2. Configuration files are generated from templates. 3. Docker images are downloaded. 4. Docker containers are provisioned. -5. A full, production-ready Open edX platform (`Quince `__ release) is run with docker-compose. +5. A full, production-ready Open edX platform (`Redwood `__ release) is run with docker-compose. The whole procedure should require less than 10 minutes, on a server with good bandwidth. Note that your host environment will not be affected in any way, since everything runs inside docker containers. Root access is not even necessary. diff --git a/docs/reference/indexes.rst b/docs/reference/indexes.rst index e9c337ea33..45fff4b3c0 100644 --- a/docs/reference/indexes.rst +++ b/docs/reference/indexes.rst @@ -7,10 +7,10 @@ Plugin indexes are a great way to have your plugins discovered by other users. P Index file paths ================ -A plugin index is a yaml-formatted file. It can be stored on the web or on your computer. In both cases, the index file location must end with "/plugins.yml". For instance, the following are valid index locations if you run the Open edX "Quince" release: +A plugin index is a yaml-formatted file. It can be stored on the web or on your computer. In both cases, the index file location must end with "/plugins.yml". For instance, the following are valid index locations if you run the Open edX "Redwood" release: -- https://overhang.io/tutor/main/quince/plugins.yml -- ``/path/to/your/local/index/quince/plugins.yml`` +- https://overhang.io/tutor/main/redwood/plugins.yml +- ``/path/to/your/local/index/redwood/plugins.yml`` To add either indexes, run the ``tutor plugins index add`` command without the suffix. For instance:: @@ -106,9 +106,9 @@ Manage plugins in development Plugin developers and maintainers often want to install local versions of their plugins. They usually achieve this with ``pip install -e /path/to/tutor-plugin``. We can improve that workflow by creating an index for local plugins:: # Create the plugin index directory - mkdir -p ~/localindex/quince/ + mkdir -p ~/localindex/redwood/ # Edit the index - vim ~/localindex/quince/plugins.yml + vim ~/localindex/redwood/plugins.yml Add the following to the index:: diff --git a/docs/troubleshooting.rst b/docs/troubleshooting.rst index 8e44a8da1e..a8e9c36927 100644 --- a/docs/troubleshooting.rst +++ b/docs/troubleshooting.rst @@ -158,7 +158,9 @@ The error produced should help better understand what is happening. The chosen default language does not display properly ----------------------------------------------------- -By default, Open edX comes with a `limited set ` of translation/localization files. To complement these languages, we add locales from the `openedx-i18n project `_. But not all supported locales are downloaded. In some cases, the chosen default language will not display properly because it was not packaged in either edx-platform or openedx-i18n. If you feel like your language should be packaged, please `open an issue on the openedx-i18n project `_. +By default, Open edX comes with a `limited set ` of translation/localization files. + +Refer to the :ref:`i18n` section for more information about using your own translations. When I make changes to a course in the CMS, they are not taken into account by the LMS -------------------------------------------------------------------------------------- diff --git a/docs/tutorials/edx-platform.rst b/docs/tutorials/edx-platform.rst index 6a6aba10b7..793498a248 100644 --- a/docs/tutorials/edx-platform.rst +++ b/docs/tutorials/edx-platform.rst @@ -69,7 +69,7 @@ Quite often, developers don't want to work on edx-platform directly, but on a de cd /my/workspace/edx-ora2 git clone https://github.com/openedx/edx-ora2 . -Then, check out the right version of the package. This is the version that is indicated in the `edx-platform/requirements/edx/base.txt `__. Be careful that the version that is currently in use in your version of edx-platform is **not necessarily the head of the master branch**:: +Then, check out the right version of the package. This is the version that is indicated in the `edx-platform/requirements/edx/base.txt `__. Be careful that the version that is currently in use in your version of edx-platform is **not necessarily the head of the master branch**:: git checkout @@ -100,6 +100,8 @@ Verify that your repository is properly bind-mounted by running ``tutor mounts l - service: cms-job container_path: /mnt/edx-ora2 +(If the ``_mounts`` entries are empty, it didn't work automatically - see below.) + You should then re-build the "openedx" Docker image to pick up your changes:: tutor images build openedx-dev @@ -111,6 +113,18 @@ To push your changes in production, you should do the same with ``tutor local`` tutor images build openedx tutor local start -d +What if my edx-platform package is not automatically bind-mounted? +------------------------------------------------------------------ + +It is quite possible that your package is not automatically recognized and bind-mounted by Tutor. Out of the box, Tutor defines a set of regular expressions: if your package name matches this regular expression, it will be automatically bind-mounted. But if it does not, you have to tell Tutor about it. + +To do so, you will need to create a :ref:`Tutor plugin ` that implements the :py:data:`tutor.hooks.Filters.MOUNTED_DIRECTORIES` filter:: + + from tutor import hooks + hooks.Filters.MOUNTED_DIRECTORIES.add_item(("openedx", "my-package")) + +After you implement and enable that plugin, ``tutor mounts list`` should display your directory among the bind-mounted directories. + Debugging with breakpoints -------------------------- @@ -153,18 +167,6 @@ Then, run unit tests with ``pytest`` commands:: .. note:: Getting all edx-platform unit tests to pass on Tutor is currently a work-in-progress. Some unit tests are still failing. If you manage to fix some of these, please report your findings in the `Open edX forum `__. -What if my edx-platform package is not automatically bind-mounted? ------------------------------------------------------------------- - -It is quite possible that your package is not automatically recognized and bind-mounted by Tutor. Out of the box, Tutor defines a set of regular expressions: if your package name matches this regular expression, it will be automatically bind-mounted. But if it does not, you have to tell Tutor about it. - -To do so, you will need to create a :ref:`Tutor plugin ` that implements the :py:data:`tutor.hooks.Filters.MOUNTED_DIRECTORIES` filter:: - - from tutor import hooks - hooks.Filters.MOUNTED_DIRECTORIES.add_item(("openedx", "my-package")) - -After you implement and enable that plugin, ``tutor mounts list`` should display your directory among the bind-mounted directories. - Do I have to re-build the "openedx" Docker image after every change? -------------------------------------------------------------------- diff --git a/requirements/plugins.txt b/requirements/plugins.txt index 36e7c0a5e5..2c4be2fe12 100644 --- a/requirements/plugins.txt +++ b/requirements/plugins.txt @@ -1,14 +1,14 @@ -# change version ranges when upgrading from quince -tutor-android>=17.0.0,<18.0.0 -tutor-cairn>=17.0.0,<18.0.0 -tutor-credentials>=17.0.0,<18.0.0 -tutor-discovery>=17.0.0,<18.0.0 -tutor-ecommerce>=17.0.0,<18.0.0 -tutor-forum>=17.0.0,<18.0.0 -tutor-indigo>=17.0.0,<18.0.0 -tutor-jupyter>=17.0.0,<18.0.0 -tutor-mfe>=17.0.0,<18.0.0 -tutor-minio>=17.0.0,<18.0.0 -tutor-notes>=17.0.0,<18.0.0 -tutor-webui>=17.0.0,<18.0.0 -tutor-xqueue>=17.0.0,<18.0.0 +# change version ranges when upgrading from redwood +tutor-android>=18.0.0,<19.0.0 +tutor-cairn>=18.0.0,<19.0.0 +tutor-credentials>=18.0.0,<19.0.0 +tutor-discovery>=18.0.0,<19.0.0 +tutor-ecommerce>=18.0.0,<19.0.0 +tutor-forum>=18.0.0,<19.0.0 +tutor-indigo>=18.0.0,<19.0.0 +tutor-jupyter>=18.0.0,<19.0.0 +tutor-mfe>=18.0.0,<19.0.0 +tutor-minio>=18.0.0,<19.0.0 +tutor-notes>=18.0.0,<19.0.0 +tutor-webui>=18.0.0,<19.0.0 +tutor-xqueue>=18.0.0,<19.0.0 diff --git a/tests/commands/test_images.py b/tests/commands/test_images.py index 32ddba885f..22a9072c5e 100644 --- a/tests/commands/test_images.py +++ b/tests/commands/test_images.py @@ -49,7 +49,7 @@ def test_images_pull_all_vendor_images(self, image_pull: Mock) -> None: self.assertIsNone(result.exception) self.assertEqual(0, result.exit_code) # Note: we should update this tag whenever the mysql image is updated - image_pull.assert_called_once_with("docker.io/mysql:8.1.0") + image_pull.assert_called_once_with("docker.io/mysql:8.4.0") def test_images_printtag_image(self) -> None: result = self.invoke(["images", "printtag", "openedx"]) diff --git a/tests/test_env.py b/tests/test_env.py index 27cff9678b..e2ba7bbe1d 100644 --- a/tests/test_env.py +++ b/tests/test_env.py @@ -260,7 +260,7 @@ def test_current_version_in_latest_env(self) -> None: ) as f: f.write(__version__) self.assertEqual(__version__, env.current_version(root)) - self.assertEqual("quince", env.get_env_release(root)) + self.assertEqual("redwood", env.get_env_release(root)) self.assertIsNone(env.should_upgrade_from_release(root)) self.assertTrue(env.is_up_to_date(root)) diff --git a/tutor/__about__.py b/tutor/__about__.py index 4924a76e74..8c37f09911 100644 --- a/tutor/__about__.py +++ b/tutor/__about__.py @@ -2,7 +2,7 @@ # Increment this version number to trigger a new release. See # docs/tutor.html#versioning for information on the versioning scheme. -__version__ = "17.0.6" +__version__ = "18.0.0" # The version suffix will be appended to the actual version, separated by a # dash. Use this suffix to differentiate between the actual released version and diff --git a/tutor/commands/upgrade/__init__.py b/tutor/commands/upgrade/__init__.py index b7a4e028de..44592344a5 100644 --- a/tutor/commands/upgrade/__init__.py +++ b/tutor/commands/upgrade/__init__.py @@ -1,4 +1,4 @@ -# Note: don't forget to change this when we upgrade from quince +# Note: don't forget to change this when we upgrade from redwood OPENEDX_RELEASE_NAMES = [ "ironwood", "juniper", @@ -9,4 +9,5 @@ "olive", "palm", "quince", + "redwood", ] diff --git a/tutor/commands/upgrade/common.py b/tutor/commands/upgrade/common.py index 0b50f3eeb7..e641a77001 100644 --- a/tutor/commands/upgrade/common.py +++ b/tutor/commands/upgrade/common.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import click from tutor import config as tutor_config @@ -41,6 +43,23 @@ def upgrade_from_nutmeg(context: click.Context, config: Config) -> None: ) +def get_mongo_upgrade_parameters( + docker_version: str, compatibility_version: str +) -> tuple[int, dict[str, int | str]]: + """ + Helper utility to get parameters required during mongo upgrade. + """ + mongo_version = int(docker_version.split(".")[0]) + admin_command: dict[str, int | str] = { + "setFeatureCompatibilityVersion": compatibility_version + } + if mongo_version == 7: + # Explicit confirmation is required to upgrade to 7 from 6 + # https://www.mongodb.com/docs/manual/reference/command/setFeatureCompatibilityVersion/#confirm + admin_command.update({"confirm": 1}) + return mongo_version, admin_command + + PALM_RENAME_ORA2_FOLDER_COMMAND = """ if stat '/openedx/data/ora2/SET-ME-PLEASE (ex. bucket-name)' 2> /dev/null; then echo "Renaming ora2 folder..." diff --git a/tutor/commands/upgrade/compose.py b/tutor/commands/upgrade/compose.py index 7aef353bda..df54c71d8b 100644 --- a/tutor/commands/upgrade/compose.py +++ b/tutor/commands/upgrade/compose.py @@ -46,6 +46,10 @@ def upgrade_from(context: click.Context, from_release: str) -> None: if running_release == "palm": running_release = "quince" + if running_release == "quince": + upgrade_from_quince(context, config) + running_release = "redwood" + def upgrade_from_ironwood(context: click.Context, config: Config) -> None: click.echo(fmt.title("Upgrading from Ironwood")) @@ -155,6 +159,13 @@ def upgrade_from_olive(context: click.Context, config: Config) -> None: upgrade_mongodb(context, config, "4.4.22", "4.4") +def upgrade_from_quince(context: click.Context, config: Config) -> None: + click.echo(fmt.title("Upgrading from Quince")) + upgrade_mongodb(context, config, "5.0.26", "5.0") + upgrade_mongodb(context, config, "6.0.14", "6.0") + upgrade_mongodb(context, config, "7.0.7", "7.0") + + def upgrade_mongodb( context: click.Context, config: Config, @@ -168,7 +179,11 @@ def upgrade_mongodb( ) return + mongo_version, admin_command = common_upgrade.get_mongo_upgrade_parameters( + to_docker_version, to_compatibility_version + ) click.echo(fmt.title(f"Upgrading MongoDb to v{to_docker_version}")) + # Note that the DOCKER_IMAGE_MONGODB value is never saved, because we only save the # environment, not the configuration. config["DOCKER_IMAGE_MONGODB"] = f"mongo:{to_docker_version}" @@ -180,9 +195,9 @@ def upgrade_mongodb( compose.execute, args=[ "mongodb", - "mongo", + "mongosh" if mongo_version >= 6 else "mongo", "--eval", - f'db.adminCommand({{ setFeatureCompatibilityVersion: "{to_compatibility_version}" }})', + f"db.adminCommand({admin_command})", ], ) context.invoke(compose.stop) diff --git a/tutor/commands/upgrade/k8s.py b/tutor/commands/upgrade/k8s.py index 64cebaf354..db18835704 100644 --- a/tutor/commands/upgrade/k8s.py +++ b/tutor/commands/upgrade/k8s.py @@ -45,6 +45,10 @@ def upgrade_from(context: click.Context, from_release: str) -> None: if running_release == "palm": running_release = "quince" + if running_release == "quince": + upgrade_from_quince(config) + running_release = "redwood" + def upgrade_from_ironwood(config: Config) -> None: upgrade_mongodb(config, "3.4.24", "3.4") @@ -162,6 +166,13 @@ def upgrade_from_olive(context: Context, config: Config) -> None: upgrade_mongodb(config, "4.4.22", "4.4") +def upgrade_from_quince(config: Config) -> None: + click.echo(fmt.title("Upgrading from Quince")) + upgrade_mongodb(config, "5.0.26", "5.0") + upgrade_mongodb(config, "6.0.14", "6.0") + upgrade_mongodb(config, "7.0.7", "7.0") + + def upgrade_mongodb( config: Config, to_docker_version: str, to_compatibility_version: str ) -> None: @@ -171,13 +182,18 @@ def upgrade_mongodb( "responsibility to upgrade your MongoDb instance to {to_docker_version}." ) return + mongo_version, admin_command = common_upgrade.get_mongo_upgrade_parameters( + to_docker_version, to_compatibility_version + ) + mongo_binary = "mongosh" if mongo_version >= 6 else "mongo" + message = f"""Automatic release upgrade is unsupported in Kubernetes. You should manually upgrade your MongoDb cluster to {to_docker_version} by running something similar to: tutor k8s stop tutor config save --set DOCKER_IMAGE_MONGODB=mongo:{to_docker_version} tutor k8s start - tutor k8s exec mongodb mongo --eval 'db.adminCommand({{ setFeatureCompatibilityVersion: "{to_compatibility_version}" }})' + tutor k8s exec mongodb {mongo_binary} --eval 'db.adminCommand({admin_command})' tutor config save --unset DOCKER_IMAGE_MONGODB """ fmt.echo_info(message) diff --git a/tutor/env.py b/tutor/env.py index 6f150fd792..4b91d2d539 100644 --- a/tutor/env.py +++ b/tutor/env.py @@ -467,6 +467,7 @@ def get_release(version: str) -> str: "15": "olive", "16": "palm", "17": "quince", + "18": "redwood", }[version.split(".", maxsplit=1)[0]] diff --git a/tutor/plugins/openedx.py b/tutor/plugins/openedx.py index 284d53f1aa..2984d60792 100644 --- a/tutor/plugins/openedx.py +++ b/tutor/plugins/openedx.py @@ -65,6 +65,7 @@ def _mount_edx_platform_compose( ("openedx", "edx-enterprise"), ("openedx", "edx-ora2"), ("openedx", "edx-search"), + ("openedx", "openedx-learning"), ("openedx", r"platform-plugin-.*"), ] ) diff --git a/tutor/templates/apps/openedx/config/cms.env.yml b/tutor/templates/apps/openedx/config/cms.env.yml index c062b2c230..53e99b0c2d 100644 --- a/tutor/templates/apps/openedx/config/cms.env.yml +++ b/tutor/templates/apps/openedx/config/cms.env.yml @@ -27,8 +27,6 @@ CELERY_BROKER_USER: "{{ REDIS_USERNAME }}" CELERY_BROKER_PASSWORD: "{{ REDIS_PASSWORD }}" ALTERNATE_WORKER_QUEUES: "lms" ENABLE_COMPREHENSIVE_THEMING: true -COMPREHENSIVE_THEME_DIRS: ["/openedx/themes"] -STATIC_ROOT_BASE: "/openedx/staticfiles" EMAIL_BACKEND: "django.core.mail.backends.smtp.EmailBackend" EMAIL_HOST: "{{ SMTP_HOST }}" EMAIL_PORT: {{ SMTP_PORT }} diff --git a/tutor/templates/apps/openedx/config/lms.env.yml b/tutor/templates/apps/openedx/config/lms.env.yml index a1f93eb9a5..565820c81b 100644 --- a/tutor/templates/apps/openedx/config/lms.env.yml +++ b/tutor/templates/apps/openedx/config/lms.env.yml @@ -33,8 +33,6 @@ CELERY_BROKER_USER: "{{ REDIS_USERNAME }}" CELERY_BROKER_PASSWORD: "{{ REDIS_PASSWORD }}" ALTERNATE_WORKER_QUEUES: "cms" ENABLE_COMPREHENSIVE_THEMING: true -COMPREHENSIVE_THEME_DIRS: ["/openedx/themes"] -STATIC_ROOT_BASE: "/openedx/staticfiles" EMAIL_BACKEND: "django.core.mail.backends.smtp.EmailBackend" EMAIL_HOST: "{{ SMTP_HOST }}" EMAIL_PORT: {{ SMTP_PORT }} diff --git a/tutor/templates/apps/openedx/settings/partials/common_all.py b/tutor/templates/apps/openedx/settings/partials/common_all.py index fb963bec37..c317f4c06f 100644 --- a/tutor/templates/apps/openedx/settings/partials/common_all.py +++ b/tutor/templates/apps/openedx/settings/partials/common_all.py @@ -150,9 +150,16 @@ # These warnings are visible in simple commands and init tasks import warnings -from django.utils.deprecation import RemovedInDjango50Warning, RemovedInDjango51Warning -warnings.filterwarnings("ignore", category=RemovedInDjango50Warning) -warnings.filterwarnings("ignore", category=RemovedInDjango51Warning) +try: + from django.utils.deprecation import RemovedInDjango50Warning, RemovedInDjango51Warning + warnings.filterwarnings("ignore", category=RemovedInDjango50Warning) + warnings.filterwarnings("ignore", category=RemovedInDjango51Warning) +except ImportError: + # REMOVE-AFTER-V18: + # In Quince, edx-platform uses Django 5. But on master, edx-platform still uses Django 3. + # So, Tutor v17 needs to silence these warnings, whereas Tutor v17-nightly fails to import them. + # Once edx-platform master is upgraded to Django 5, the try-except wrapper can be removed. + pass warnings.filterwarnings("ignore", category=DeprecationWarning, module="wiki.plugins.links.wiki_plugin") warnings.filterwarnings("ignore", category=DeprecationWarning, module="boto.plugin") @@ -171,8 +178,6 @@ EMAIL_FILE_PATH = "/tmp/openedx/emails" # Language/locales -LOCALE_PATHS.append("/openedx/locale/contrib/locale") -LOCALE_PATHS.append("/openedx/locale/user/locale") LANGUAGE_COOKIE_NAME = "openedx-language-preference" # Allow the platform to include itself in an iframe @@ -225,7 +230,8 @@ CORS_ALLOW_CREDENTIALS = True CORS_ORIGIN_ALLOW_ALL = False CORS_ALLOW_INSECURE = {% if ENABLE_HTTPS %}False{% else %}True{% endif %} -CORS_ALLOW_HEADERS = corsheaders_default_headers + ('use-jwt-cookie',) +# Note: CORS_ALLOW_HEADERS is intentionally not defined here, because it should +# be consistent across deployments, and is therefore set in edx-platform. # Add your MFE and third-party app domains here CORS_ORIGIN_WHITELIST = [] diff --git a/tutor/templates/apps/openedx/settings/partials/common_cms.py b/tutor/templates/apps/openedx/settings/partials/common_cms.py index 1b2f48a2f9..c5dde04400 100644 --- a/tutor/templates/apps/openedx/settings/partials/common_cms.py +++ b/tutor/templates/apps/openedx/settings/partials/common_cms.py @@ -21,7 +21,7 @@ FRONTEND_REGISTER_URL = LMS_ROOT_URL + '/register' # Create folders if necessary -for folder in [LOG_DIR, MEDIA_ROOT, STATIC_ROOT_BASE, ORA2_FILEUPLOAD_ROOT]: +for folder in [LOG_DIR, MEDIA_ROOT, STATIC_ROOT, ORA2_FILEUPLOAD_ROOT]: if not os.path.exists(folder): os.makedirs(folder, exist_ok=True) diff --git a/tutor/templates/apps/openedx/settings/partials/common_lms.py b/tutor/templates/apps/openedx/settings/partials/common_lms.py index e3b86492e0..1a06d613c2 100644 --- a/tutor/templates/apps/openedx/settings/partials/common_lms.py +++ b/tutor/templates/apps/openedx/settings/partials/common_lms.py @@ -38,7 +38,7 @@ } # Create folders if necessary -for folder in [DATA_DIR, LOG_DIR, MEDIA_ROOT, STATIC_ROOT_BASE, ORA2_FILEUPLOAD_ROOT]: +for folder in [DATA_DIR, LOG_DIR, MEDIA_ROOT, STATIC_ROOT, ORA2_FILEUPLOAD_ROOT]: if not os.path.exists(folder): os.makedirs(folder, exist_ok=True) diff --git a/tutor/templates/build/openedx/Dockerfile b/tutor/templates/build/openedx/Dockerfile index 9f3cc7f054..6964dedea1 100644 --- a/tutor/templates/build/openedx/Dockerfile +++ b/tutor/templates/build/openedx/Dockerfile @@ -24,9 +24,9 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ # Install pyenv # https://www.python.org/downloads/ # https://github.com/pyenv/pyenv/releases -ARG PYTHON_VERSION=3.8.18 +ARG PYTHON_VERSION=3.11.8 ENV PYENV_ROOT /opt/pyenv -RUN git clone https://github.com/pyenv/pyenv $PYENV_ROOT --branch v2.3.29 --depth 1 +RUN git clone https://github.com/pyenv/pyenv $PYENV_ROOT --branch v2.3.36 --depth 1 # Install Python RUN $PYENV_ROOT/bin/pyenv install $PYTHON_VERSION @@ -38,9 +38,9 @@ RUN $PYENV_ROOT/versions/$PYTHON_VERSION/bin/python -m venv /openedx/venv FROM minimal as code ARG EDX_PLATFORM_REPOSITORY={{ EDX_PLATFORM_REPOSITORY }} ARG EDX_PLATFORM_VERSION={{ EDX_PLATFORM_VERSION }} -RUN mkdir -p /openedx/edx-platform && \ - git clone $EDX_PLATFORM_REPOSITORY --branch $EDX_PLATFORM_VERSION --depth 1 /openedx/edx-platform +RUN mkdir -p /openedx/edx-platform WORKDIR /openedx/edx-platform +ADD --keep-git-dir=true $EDX_PLATFORM_REPOSITORY#$EDX_PLATFORM_VERSION . # Identify tutor user to apply patches using git RUN git config --global user.email "tutor@overhang.io" \ @@ -53,13 +53,6 @@ RUN git config --global user.email "tutor@overhang.io" \ # Patches in nightly node {%- else %} # Patches in non-nightly mode -# Prevent course structure cache infinite growth -# https://github.com/openedx/edx-platform/pull/34210 -RUN curl -fsSL https://github.com/openedx/edx-platform/commit/ad201cd664b6c722cbefcbda23ae390c06daf621.patch | git am -# Security patch for "Privilege re-escalation in Studio after staff access removed" -# https://github.com/openedx/edx-platform/security/advisories/GHSA-99vw-2wrq-xh9x -# https://discuss.openedx.org/t/upcoming-security-fix-for-edx-platform-on-2024-05-17/13004 -RUN curl -fsSL https://github.com/openedx/edx-platform/commit/3ff69fd5813256f935f19c237ea0c42d4c16edbf.patch | git am {%- endif %} {# Example: RUN curl -fsSL https://github.com/openedx/edx-platform/commit/.patch | git am #} @@ -76,15 +69,6 @@ COPY --from=code /openedx/edx-platform / FROM scratch as mnt-{{ name }} {% endfor %} -###### Download extra locales to /openedx/locale/contrib/locale -FROM minimal as locales -ARG OPENEDX_I18N_REPOSITORY=https://github.com/openedx/openedx-i18n.git -ARG OPENEDX_I18N_VERSION=release/quince -ADD --keep-git-dir=true $OPENEDX_I18N_REPOSITORY#$OPENEDX_I18N_VERSION /tmp/openedx-i18n -RUN mkdir --parents /openedx/locale && \ - mv /tmp/openedx-i18n/edx-platform/locale /openedx/locale/contrib && \ - rm -rf /tmp/openedx-i18n/ - ###### Install python requirements in virtualenv FROM python as python-requirements ENV PATH /openedx/venv/bin:${PATH} @@ -102,7 +86,7 @@ RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared \ # https://pypi.org/project/setuptools/ # https://pypi.org/project/pip/ # https://pypi.org/project/wheel/ - setuptools==68.2.2 pip==23.2.1. wheel==0.41.2 + setuptools==69.1.1 pip==24.0 wheel==0.43.0 # Install base requirements RUN --mount=type=bind,from=edx-platform,source=/requirements/edx/base.txt,target=/openedx/edx-platform/requirements/edx/base.txt \ @@ -115,12 +99,12 @@ RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared \ # Use redis as a django cache https://pypi.org/project/django-redis/ django-redis==5.4.0 \ # uwsgi server https://pypi.org/project/uWSGI/ - uwsgi==2.0.22 + uwsgi==2.0.24 {{ patch("openedx-dockerfile-post-python-requirements") }} # Install scorm xblock -RUN pip install "openedx-scorm-xblock>=17.0.0,<18.0.0" +RUN pip install "openedx-scorm-xblock>=18.0.0,<19.0.0" {% for extra_requirements in OPENEDX_EXTRA_PIP_REQUIREMENTS %} RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared \ @@ -133,9 +117,8 @@ ENV PATH /openedx/nodeenv/bin:/openedx/venv/bin:${PATH} # Install nodeenv with the version provided by edx-platform # https://github.com/openedx/edx-platform/blob/master/requirements/edx/base.txt -# https://github.com/pyenv/pyenv/releases RUN pip install nodeenv==1.8.0 -RUN nodeenv /openedx/nodeenv --node=16.14.0 --prebuilt +RUN nodeenv /openedx/nodeenv --node=18.20.1 --prebuilt # Install nodejs requirements ARG NPM_REGISTRY={{ NPM_REGISTRY }} @@ -162,26 +145,35 @@ RUN if [ "$APP_USER_ID" = 0 ]; then echo "app user may not be root" && false; fi RUN useradd --no-log-init --home-dir /openedx --create-home --shell /bin/bash --uid ${APP_USER_ID} app USER ${APP_USER_ID} +# Note: +# For directories from other stages, we prefer 'COPY --link' to plain 'COPY' because it copies +# without regard to files from previous layers, providing significant caching benefits. However, +# since Linux's username->userid mapping is stored in a file (/etc/passwd), it means that we must +# --chown with an integer user id ($APP_USER_ID) rather the a username (app). + # https://hub.docker.com/r/powerman/dockerize/tags COPY --link --from=docker.io/powerman/dockerize:0.19.0 /usr/local/bin/dockerize /usr/local/bin/dockerize -COPY --chown=app:app --from=edx-platform / /openedx/edx-platform -COPY --chown=app:app --from=locales /openedx/locale /openedx/locale -COPY --chown=app:app --from=python /opt/pyenv /opt/pyenv -COPY --chown=app:app --from=python-requirements /openedx/venv /openedx/venv -COPY --chown=app:app --from=python-requirements /mnt /mnt -COPY --chown=app:app --from=nodejs-requirements /openedx/nodeenv /openedx/nodeenv -COPY --chown=app:app --from=nodejs-requirements /openedx/edx-platform/node_modules /openedx/node_modules +COPY --link --chown=$APP_USER_ID:$APP_USER_ID --from=edx-platform / /openedx/edx-platform +COPY --link --chown=$APP_USER_ID:$APP_USER_ID --from=python /opt/pyenv /opt/pyenv +COPY --link --chown=$APP_USER_ID:$APP_USER_ID --from=python-requirements /openedx/venv /openedx/venv +COPY --link --chown=$APP_USER_ID:$APP_USER_ID --from=python-requirements /mnt /mnt +COPY --link --chown=$APP_USER_ID:$APP_USER_ID --from=nodejs-requirements /openedx/nodeenv /openedx/nodeenv +COPY --link --chown=$APP_USER_ID:$APP_USER_ID --from=nodejs-requirements /openedx/edx-platform/node_modules /openedx/node_modules # Symlink node_modules such that we can bind-mount the edx-platform repository RUN ln -s /openedx/node_modules /openedx/edx-platform/node_modules ENV PATH /openedx/venv/bin:./node_modules/.bin:/openedx/nodeenv/bin:${PATH} ENV VIRTUAL_ENV /openedx/venv/ +ENV COMPREHENSIVE_THEME_DIRS /openedx/themes +ENV STATIC_ROOT_LMS /openedx/staticfiles +ENV STATIC_ROOT_CMS /openedx/staticfiles/studio + WORKDIR /openedx/edx-platform {# Install auto-mounted directories as Python packages. #} {% for name in iter_mounted_directories(MOUNTS, "openedx") %} -COPY --from=mnt-{{ name }} --chown=app:app / /mnt/{{ name }} +COPY --link --chown=$APP_USER_ID:$APP_USER_ID --from=mnt-{{ name }} / /mnt/{{ name }} RUN pip install -e "/mnt/{{ name }}" {% endfor %} @@ -199,15 +191,17 @@ ENV REVISION_CFG /openedx/config/revisions.yml COPY --chown=app:app settings/lms/*.py ./lms/envs/tutor/ COPY --chown=app:app settings/cms/*.py ./cms/envs/tutor/ -# Copy user-specific locales to /openedx/locale/user/locale and compile them -RUN mkdir /openedx/locale/user -COPY --chown=app:app ./locale/ /openedx/locale/user/locale/ -RUN cd /openedx/locale/user && \ - django-admin compilemessages -v1 - -# Compile i18n strings: in some cases, js locales are not properly compiled out of the box -# and we need to do a pass ourselves. Also, we need to compile the djangojs.js files for -# the downloaded locales. +# Pull latest translations via atlas +RUN make clean_translations +RUN ./manage.py lms --settings=tutor.i18n pull_plugin_translations --verbose --repository='{{ ATLAS_REPOSITORY }}' --revision='{{ ATLAS_REVISION }}' {{ ATLAS_OPTIONS }} +RUN ./manage.py lms --settings=tutor.i18n pull_xblock_translations --repository='{{ ATLAS_REPOSITORY }}' --revision='{{ ATLAS_REVISION }}' {{ ATLAS_OPTIONS }} +RUN atlas pull --repository='{{ ATLAS_REPOSITORY }}' --revision='{{ ATLAS_REVISION }}' {{ ATLAS_OPTIONS }} \ + translations/edx-platform/conf/locale:conf/locale \ + translations/studio-frontend/src/i18n/messages:conf/plugins-locale/studio-frontend +RUN ./manage.py lms --settings=tutor.i18n compile_xblock_translations +RUN ./manage.py cms --settings=tutor.i18n compile_xblock_translations +RUN ./manage.py lms --settings=tutor.i18n compile_plugin_translations +RUN ./manage.py lms --settings=tutor.i18n compilemessages -v1 RUN ./manage.py lms --settings=tutor.i18n compilejsi18n RUN ./manage.py cms --settings=tutor.i18n compilejsi18n @@ -218,27 +212,22 @@ ENV PATH /openedx/bin:${PATH} {{ patch("openedx-dockerfile-pre-assets") }} -# Collect production assets. By default, only assets from the default theme +# Build & collect production assets. By default, only assets from the default theme # will be processed. This makes the docker image lighter and faster to build. -# Only the custom themes added to /openedx/themes will be compiled. -# Here, we don't run "paver update_assets" which is slow, compiles all themes -# and requires a complex settings file. Instead, we decompose the commands -# and run each one individually to collect the production static assets to -# /openedx/staticfiles. -ENV NO_PYTHON_UNINSTALL 1 -ENV NO_PREREQ_INSTALL 1 -# We need to rely on a separate openedx-assets command to accelerate asset processing. -# For instance, we don't want to run all steps of asset collection every time the theme -# is modified. -RUN openedx-assets xmodule \ - && openedx-assets npm \ - && openedx-assets webpack --env=prod \ - && openedx-assets common -COPY --chown=app:app ./themes/ /openedx/themes/ -RUN openedx-assets themes \ - && openedx-assets collect --settings=tutor.assets \ - # De-duplicate static assets with symlinks - && rdfind -makesymlinks true -followsymlinks true /openedx/staticfiles/ +RUN npm run postinstall # Postinstall artifacts are stuck in nodejs-requirements layer. Create them here too. +RUN npm run compile-sass -- --skip-themes +RUN npm run webpack + +# Now that the default theme is built, build any custom themes +COPY --chown=app:app ./themes/ /openedx/themes +RUN npm run compile-sass -- --skip-default + +# and finally, collect assets for the production image, +# de-duping assets with symlinks. +RUN ./manage.py lms collectstatic --noinput --settings=tutor.assets && \ + ./manage.py cms collectstatic --noinput --settings=tutor.assets && \ + # De-duplicate static assets with symlinks \ + rdfind -makesymlinks true -followsymlinks true /openedx/staticfiles/ # Create a data directory, which might be used (or not) RUN mkdir /openedx/data @@ -273,13 +262,13 @@ USER app RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared \ pip install -r requirements/edx/development.txt # https://pypi.org/project/ipdb/ -# https://pypi.org/project/ipython (8.12.x for Python 3.8) +# https://pypi.org/project/ipython (>=Python 3.10 started with 8.20) RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared \ - pip install ipdb==0.13.13 ipython==8.12.3 + pip install ipdb==0.13.13 ipython==8.24.0 {# Re-install mounted requirements, otherwise they will be superseded by upstream reqs #} {% for name in iter_mounted_directories(MOUNTS, "openedx") %} -COPY --from=mnt-{{ name }} --chown=app:app / /mnt/{{ name }} +COPY --link --chown=$APP_USER_ID:$APP_USER_ID --from=mnt-{{ name }} / /mnt/{{ name }} RUN pip install -e "/mnt/{{ name }}" {% endfor %} @@ -291,7 +280,7 @@ ENV PYTHONBREAKPOINT=ipdb.set_trace # static assets, then production assets will be served instead. RUN rm -r /openedx/staticfiles && \ mkdir /openedx/staticfiles && \ - openedx-assets webpack --env=dev + npm run build-dev {{ patch("openedx-dev-dockerfile-post-python-requirements") }} diff --git a/tutor/templates/build/openedx/bin/openedx-assets b/tutor/templates/build/openedx/bin/openedx-assets deleted file mode 100755 index 1b89434d67..0000000000 --- a/tutor/templates/build/openedx/bin/openedx-assets +++ /dev/null @@ -1,218 +0,0 @@ -#! /usr/bin/env python -from __future__ import print_function -import argparse -import os -import subprocess -import sys -import traceback - -from path import Path - -from pavelib import assets - - -DEFAULT_STATIC_ROOT = "/openedx/staticfiles" -DEFAULT_THEMES_DIR = "/openedx/themes" - - -def main(): - parser = argparse.ArgumentParser( - description="Various assets processing/building/collection utility for Open edX" - ) - subparsers = parser.add_subparsers() - - npm = subparsers.add_parser("npm", help="Copy static assets from node_modules") - npm.set_defaults(func=run_npm) - - build = subparsers.add_parser("build", help="Build all assets") - build.add_argument("-e", "--env", choices=["prod", "dev"], default="prod") - build.add_argument("--theme-dirs", nargs="+", default=[DEFAULT_THEMES_DIR]) - build.add_argument("--themes", nargs="+", default=["all"]) - build.add_argument("-r", "--static-root", default=DEFAULT_STATIC_ROOT) - build.add_argument("--systems", nargs="+", default=["lms", "cms"]) - build.set_defaults(func=run_build) - - xmodule = subparsers.add_parser("xmodule", help="Process assets from xmodule") - xmodule.set_defaults(func=run_xmodule) - - webpack = subparsers.add_parser("webpack", help="Run webpack") - webpack.add_argument("-r", "--static-root", default=DEFAULT_STATIC_ROOT) - webpack.add_argument("-e", "--env", choices=["prod", "dev"], default="prod") - webpack.set_defaults(func=run_webpack) - - common = subparsers.add_parser( - "common", help="Compile static assets for common theme" - ) - common.add_argument("--systems", nargs="+", default=["lms", "cms"]) - common.set_defaults(func=run_common) - - themes = subparsers.add_parser( - "themes", help="Compile static assets for custom themes" - ) - themes.add_argument("--theme-dirs", nargs="+", default=[DEFAULT_THEMES_DIR]) - themes.add_argument("--themes", nargs="+", default=["all"]) - themes.add_argument("--systems", nargs="+", default=["lms", "cms"]) - themes.set_defaults(func=run_themes) - - collect = subparsers.add_parser( - "collect", help="Collect static assets to be served by webserver" - ) - collect.add_argument( - "-s", - "--settings", - default="tutor.assets", - help="Django settings module", - ) - collect.add_argument( - "--systems", - nargs="+", - choices=["lms", "cms"], - default=["lms", "cms"], - help="Limit collection to lms or cms", - ) - collect.set_defaults(func=run_collect) - - watch_themes = subparsers.add_parser( - "watch-themes", help="Watch theme assets for changes and recompile on-the-fly" - ) - watch_themes.add_argument( - "-e", - "--env", - choices=["prod", "dev"], - default="prod", - help="Webpack target to run", - ) - watch_themes.add_argument("--theme-dirs", default=[DEFAULT_THEMES_DIR]) - watch_themes.set_defaults(func=run_watch_themes) - - args = parser.parse_args() - args.func(args) - - -def run_build(args): - run_xmodule(args) - run_npm(args) - run_webpack(args) - run_common(args) - run_themes(args) - - -def run_xmodule(_args): - # Collecting xmodule assets is incompatible with setting the django path, because - # of an unfortunate call to settings.configure() - django_settings_module = os.environ.get("DJANGO_SETTINGS_MODULE") - if django_settings_module: - os.environ.pop("DJANGO_SETTINGS_MODULE") - - sys.argv[1:] = ["common/static/xmodule"] - import xmodule.static_content - - xmodule.static_content.main() - - if django_settings_module: - os.environ["DJANGO_SETTINGS_MODULE"] = django_settings_module - - -def run_npm(_args): - assets.process_npm_assets() - - -def run_webpack(args): - os.environ["STATIC_ROOT_LMS"] = args.static_root - os.environ["STATIC_ROOT_CMS"] = os.path.join(args.static_root, "studio") - os.environ["NODE_ENV"] = {"prod": "production", "dev": "development"}[args.env] - subprocess.check_call( - [ - "webpack", - "--progress", - "--config=webpack.{env}.config.js".format(env=args.env), - ] - ) - - -def run_common(args): - for system in args.systems: - print("Compiling {} sass assets from common theme...".format(system)) - assets._compile_sass(system, None, False, False, []) - - -def run_themes(args): - for theme_dir in args.theme_dirs: - local_themes = ( - list_subdirectories(theme_dir) if "all" in args.themes else args.themes - ) - for theme in local_themes: - theme_path = os.path.join(theme_dir, theme) - if os.path.exists(theme_path): - for system in args.systems: - print( - "Compiling {} sass assets from theme {}...".format( - system, theme_path - ) - ) - assets._compile_sass(system, Path(theme_path), False, False, []) - - -def run_collect(args): - assets.collect_assets(args.systems, args.settings) - - -def run_watch_themes(args): - """ - Watch static assets for changes and re-compile those changes when - necessary. This piece of code is heavily inspired from the - edx-platform/pavelib/assets.py:watch_assets function, which could not be - used directly because it does not properly read the platform settings - environment variable. - - Note that this function will only work for watching assets in development - mode. In production, watching changes does not make much sense anyway. - """ - observer = assets.Observer() - for theme_dir in args.theme_dirs: - print("Watching changes in {}...".format(theme_dir)) - ThemeWatcher(theme_dir).register(observer) - observer.start() - try: - while True: - observer.join(2) - except KeyboardInterrupt: - observer.stop() - - -def list_subdirectories(path): - return [ - subpath - for subpath in os.listdir(path) - if os.path.isdir(os.path.join(path, subpath)) - ] - - -class ThemeWatcher(assets.SassWatcher): - def __init__(self, theme_dir): - super(ThemeWatcher, self).__init__() - self.theme_dir = theme_dir - - # pylint: disable=arguments-differ - def register(self, observer): - return super(ThemeWatcher, self).register(observer, [self.theme_dir]) - - @assets.debounce() - def on_any_event(self, event): - components = os.path.relpath(event.src_path, self.theme_dir).split("/") - try: - theme = components[0] - system = components[1] - except IndexError: - return - try: - print("Detected change:", event.src_path) - print("\tRecompiling {} theme for {}".format(theme, system)) - assets._compile_sass(system, Path(self.theme_dir) / theme, False, False, []) - print("\tDone recompiling {} theme for {}".format(theme, system)) - except Exception: # pylint: disable=broad-except - traceback.print_exc() - - -if __name__ == "__main__": - main() diff --git a/tutor/templates/build/openedx/locale/customlocales.md b/tutor/templates/build/openedx/locale/customlocales.md deleted file mode 100644 index a098936305..0000000000 --- a/tutor/templates/build/openedx/locale/customlocales.md +++ /dev/null @@ -1,13 +0,0 @@ -Add your custom translations to this folder, with the following filesystem structure: - - languagecode/ - LC_MESSAGES/ - django.po - djangojs.po - -Where "languagecode" is one of "fr", "de_DE", "zh_CN", etc. - -The localized string in the *.po file should have the following format: - - msgid "String to translate" - msgstr "Your custom translation 你发音的东西 le bidule que vous voulez traduire" diff --git a/tutor/templates/build/openedx/revisions.yml b/tutor/templates/build/openedx/revisions.yml index c01e271e53..d30d0cbc0e 100644 --- a/tutor/templates/build/openedx/revisions.yml +++ b/tutor/templates/build/openedx/revisions.yml @@ -1 +1 @@ -EDX_PLATFORM_REVISION: quince +EDX_PLATFORM_REVISION: redwood diff --git a/tutor/templates/build/openedx/settings/cms/assets.py b/tutor/templates/build/openedx/settings/cms/assets.py index 59b1dd0d30..010df2b44a 100644 --- a/tutor/templates/build/openedx/settings/cms/assets.py +++ b/tutor/templates/build/openedx/settings/cms/assets.py @@ -1,9 +1,5 @@ {% include "build/openedx/settings/partials/assets.py" %} -STATIC_ROOT = path(STATIC_ROOT_BASE) / 'studio' -WEBPACK_LOADER['DEFAULT']['STATS_FILE'] = STATIC_ROOT / "webpack-stats.json" +WEBPACK_LOADER['DEFAULT']['STATS_FILE'] = path(STATIC_ROOT) / "webpack-stats.json" derive_settings(__name__) - -LOCALE_PATHS.append("/openedx/locale/contrib/locale") -LOCALE_PATHS.append("/openedx/locale/user/locale") diff --git a/tutor/templates/build/openedx/settings/lms/assets.py b/tutor/templates/build/openedx/settings/lms/assets.py index 4cf476d1ca..010df2b44a 100644 --- a/tutor/templates/build/openedx/settings/lms/assets.py +++ b/tutor/templates/build/openedx/settings/lms/assets.py @@ -1,9 +1,5 @@ {% include "build/openedx/settings/partials/assets.py" %} -STATIC_ROOT = path(STATIC_ROOT_BASE) -WEBPACK_LOADER['DEFAULT']['STATS_FILE'] = STATIC_ROOT / "webpack-stats.json" +WEBPACK_LOADER['DEFAULT']['STATS_FILE'] = path(STATIC_ROOT) / "webpack-stats.json" derive_settings(__name__) - -LOCALE_PATHS.append("/openedx/locale/contrib/locale") -LOCALE_PATHS.append("/openedx/locale/user/locale") diff --git a/tutor/templates/build/openedx/settings/partials/assets.py b/tutor/templates/build/openedx/settings/partials/assets.py index fce97cdb85..86ef9110ab 100644 --- a/tutor/templates/build/openedx/settings/partials/assets.py +++ b/tutor/templates/build/openedx/settings/partials/assets.py @@ -5,9 +5,6 @@ from openedx.core.lib.derived import derive_settings ENABLE_COMPREHENSIVE_THEMING = True -COMPREHENSIVE_THEME_DIRS.append('/openedx/themes') - -STATIC_ROOT_BASE = '/openedx/staticfiles' SECRET_KEY = 'secret' XQUEUE_INTERFACE = { diff --git a/tutor/templates/build/openedx/settings/partials/i18n.py b/tutor/templates/build/openedx/settings/partials/i18n.py index 708c2507e0..4c5e98a77f 100644 --- a/tutor/templates/build/openedx/settings/partials/i18n.py +++ b/tutor/templates/build/openedx/settings/partials/i18n.py @@ -1,8 +1,6 @@ from ..common import * from openedx.core.lib.derived import derive_settings -STATIC_ROOT_BASE = '/openedx/staticfiles' - SECRET_KEY = 'secret' XQUEUE_INTERFACE = { 'django_auth': None, @@ -14,7 +12,5 @@ derive_settings(__name__) -LOCALE_PATHS.append("/openedx/locale/contrib/locale") -LOCALE_PATHS.append("/openedx/locale/user/locale") {{ patch("openedx-common-i18n-settings") }} diff --git a/tutor/templates/config/defaults.yml b/tutor/templates/config/defaults.yml index 109aa4ef6c..a7f70c8948 100644 --- a/tutor/templates/config/defaults.yml +++ b/tutor/templates/config/defaults.yml @@ -2,6 +2,9 @@ # This file includes all Tutor setting defaults. Settings that do not have a # default value, such as passwords, should be stored in base.yml. # This must be defined early +ATLAS_REVISION: "{% if OPENEDX_COMMON_VERSION == 'master' %}main{% else %}{{ OPENEDX_COMMON_VERSION }}{% endif %}" +ATLAS_REPOSITORY: "openedx/openedx-translations" +ATLAS_OPTIONS: "" CADDY_HTTP_PORT: 80 CMS_HOST: "studio.{{ LMS_HOST }}" CMS_OAUTH2_KEY_SSO: "cms-sso" @@ -16,9 +19,9 @@ DOCKER_IMAGE_CADDY: "docker.io/caddy:2.7.4" # https://hub.docker.com/_/elasticsearch/tags DOCKER_IMAGE_ELASTICSEARCH: "docker.io/elasticsearch:7.17.13" # https://hub.docker.com/_/mongo/tags -DOCKER_IMAGE_MONGODB: "docker.io/mongo:4.4.25" +DOCKER_IMAGE_MONGODB: "docker.io/mongo:7.0.7" # https://hub.docker.com/_/mysql/tags -DOCKER_IMAGE_MYSQL: "docker.io/mysql:8.1.0" +DOCKER_IMAGE_MYSQL: "docker.io/mysql:8.4.0" DOCKER_IMAGE_PERMISSIONS: "{{ DOCKER_REGISTRY }}overhangio/openedx-permissions:{{ TUTOR_VERSION }}" # https://hub.docker.com/_/redis/tags DOCKER_IMAGE_REDIS: "docker.io/redis:7.2.4" @@ -58,7 +61,7 @@ OPENEDX_LMS_UWSGI_WORKERS: 2 OPENEDX_MYSQL_DATABASE: "openedx" OPENEDX_MYSQL_USERNAME: "openedx" # the common version will be automatically set to "master" in the nightly branch -OPENEDX_COMMON_VERSION: "open-release/quince.3" +OPENEDX_COMMON_VERSION: "open-release/redwood.1" OPENEDX_EXTRA_PIP_REQUIREMENTS: [] MYSQL_HOST: "mysql" MYSQL_PORT: 3306 diff --git a/tutor/templates/dev/docker-compose.yml b/tutor/templates/dev/docker-compose.yml index fa39d4b73f..6c435a7917 100644 --- a/tutor/templates/dev/docker-compose.yml +++ b/tutor/templates/dev/docker-compose.yml @@ -41,7 +41,7 @@ services: # Additional service for watching theme changes watchthemes: <<: *openedx-service - command: openedx-assets watch-themes --env dev + command: npm run watch-sass restart: unless-stopped {% if RUN_ELASTICSEARCH and is_docker_rootless() %} diff --git a/tutor/templates/jobs/init/mounted-directories.sh b/tutor/templates/jobs/init/mounted-directories.sh index e10dc7b7c9..0f7c615b8b 100644 --- a/tutor/templates/jobs/init/mounted-directories.sh +++ b/tutor/templates/jobs/init/mounted-directories.sh @@ -37,7 +37,7 @@ pip install -e . npm clean-install # Regenerate static assets. -openedx-assets build --env=dev +npm run build-dev set -x echo "Done setting up bind-mounted edx-platform." diff --git a/tutor/templates/k8s/deployments.yml b/tutor/templates/k8s/deployments.yml index a48740baf3..5deaec4300 100644 --- a/tutor/templates/k8s/deployments.yml +++ b/tutor/templates/k8s/deployments.yml @@ -352,7 +352,7 @@ spec: containers: - name: mongodb image: {{ DOCKER_IMAGE_MONGODB }} - args: ["mongod", "--nojournal", "--storageEngine", "wiredTiger"] + args: ["mongod", "--storageEngine", "wiredTiger"] ports: - containerPort: 27017 volumeMounts: diff --git a/tutor/templates/local/docker-compose.yml b/tutor/templates/local/docker-compose.yml index 9dc74cd214..227f92df8f 100644 --- a/tutor/templates/local/docker-compose.yml +++ b/tutor/templates/local/docker-compose.yml @@ -27,7 +27,7 @@ services: mongodb: image: {{ DOCKER_IMAGE_MONGODB }} # Use WiredTiger in all environments, just like at edx.org - command: mongod --nojournal --storageEngine wiredTiger + command: mongod --storageEngine wiredTiger restart: unless-stopped user: "999:999" volumes: