From 829ba703a1589a4257432017ed2d7b68abfeec17 Mon Sep 17 00:00:00 2001 From: Omar Al-Ithawi Date: Mon, 29 Jan 2024 18:04:49 +0300 Subject: [PATCH] feat: enable `atlas pull` for all MFEs --- README.rst | 16 +++++++++++++--- changelog.d/20240202_172501_i_atlas_for_all.md | 1 + tutormfe/templates/mfe/build/mfe/Dockerfile | 4 ---- 3 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 changelog.d/20240202_172501_i_atlas_for_all.md diff --git a/README.rst b/README.rst index 1642c09c..a2cfa6bb 100644 --- a/README.rst +++ b/README.rst @@ -130,6 +130,7 @@ Adding new MFEs - As of Tutor v16 (Palm release) it is no longer possible to add new MFEs by creating ``*_MFE_APP`` settings. Instead, users must implement the approach described below. - As of Tutor v17 (Quince release) you must make sure that the git URL of your MFE repository ends with ``.git``. Otherwise the plugin build will fail. +- As of Tutor v18 (Redwood release) all MFEs must provide a ``make pull_translations`` command. Otherwise the plugin build will fail. Providing an empty command is enough to bypass this requirement. See the `Custom translations section <#mfe-custom-translations>`_ for more information. Other MFE developers can take advantage of this plugin to deploy their own MFEs. To declare a new MFE, create a Tutor plugin and add your MFE configuration to the ``tutormfe.hooks.MFE_APPS`` filter. This configuration should include the name, git repository (and optionally: git branch or tag) and development port. For example:: @@ -163,10 +164,19 @@ To disable an existing MFE, remove the corresponding entry from the ``MFE_APPS`` Using custom translations to your MFEs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -By default, translations are pulled from the `openedx/openedx-translations repository `_ on build time. +.. _mfe-custom-translations: -To use your own translations repository, you can override the -``ATLAS_REPOSITORY: your-organization/translations`` configuration variable. +During docker image build, this plugin runs ``make pull_translations`` for each Micro-frontend. This +program is used in the ``Dockerfile`` to pull translations from the `openedx/openedx-translations repository `_ via `openedx-atlas `_. + +The ``make pull_translations`` command passes the ``ATLAS_OPTIONS`` environment variable to the ``atlas pull`` command. This allows specifying a custom repository or branch to pull translations from. + +Translations in the MFE plugin as well as other Tutor plugins can be customized with the following configuration +variables: + +- ``ATLAS_REVISION`` (default: ``"main"`` on nightly and ``"{{ OPENEDX_COMMON_VERSION }}"`` if a named release is used) +- ``ATLAS_REPOSITORY`` (default: ``"openedx/openedx-translations"``). +- ``ATLAS_OPTIONS`` (default: ``""``) Pass additional arguments to ``atlas pull``. Refer to the `atlas documentations `_ for more information. The `Getting and customizing Translations `_ diff --git a/changelog.d/20240202_172501_i_atlas_for_all.md b/changelog.d/20240202_172501_i_atlas_for_all.md new file mode 100644 index 00000000..c3dde6cd --- /dev/null +++ b/changelog.d/20240202_172501_i_atlas_for_all.md @@ -0,0 +1 @@ +- [Feature] Enable `atlas pull` on all Micro-frontends. (by @omarithawi) diff --git a/tutormfe/templates/mfe/build/mfe/Dockerfile b/tutormfe/templates/mfe/build/mfe/Dockerfile index 274b0b4e..fe62ff24 100644 --- a/tutormfe/templates/mfe/build/mfe/Dockerfile +++ b/tutormfe/templates/mfe/build/mfe/Dockerfile @@ -48,11 +48,7 @@ RUN --mount=type=cache,target=/root/.npm,sharing=shared npm clean-install --no-a {{ patch("mfe-dockerfile-post-npm-install-{}".format(app_name)) }} COPY --from={{ app_name }}-src / /openedx/app -# Whenever a new MFE supports Atlas, it should be added to this list. -# When all MFEs support Atlas, this if-statement should be removed. -{% if app_name in ["communications"] %} RUN make OPENEDX_ATLAS_PULL=true ATLAS_OPTIONS="--repository={{ ATLAS_REPOSITORY }} --revision={{ ATLAS_REVISION }} {{ ATLAS_OPTIONS }}" pull_translations -{% endif %} EXPOSE {{ app['port'] }}