From a6ae701e4dc5fbccbfa3663861c12474b07128e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Behmo?= Date: Tue, 5 Dec 2023 16:48:03 +0100 Subject: [PATCH] fix: auto-build 3rd-party MFEs When a 3rd party develops an MFE and bind-mounts it, it is expected that the dev image will be automatically built on `dev launch`. Also, author should be able to build it with `tutor images build mymfe-dev`. This was not the case for plugins that were loaded after the "mfe" plugin. For instance: "partners" is loaded after "mfe". See discussion: https://discuss.openedx.org/t/issues-developing-a-non-core-mfe-using-tutor/11855 --- ...231205_164707_regis_fix_3rd_party_build.md | 1 + tutormfe/plugin.py | 26 ++++++++++--------- 2 files changed, 15 insertions(+), 12 deletions(-) create mode 100644 changelog.d/20231205_164707_regis_fix_3rd_party_build.md diff --git a/changelog.d/20231205_164707_regis_fix_3rd_party_build.md b/changelog.d/20231205_164707_regis_fix_3rd_party_build.md new file mode 100644 index 00000000..587b36c8 --- /dev/null +++ b/changelog.d/20231205_164707_regis_fix_3rd_party_build.md @@ -0,0 +1 @@ +- [Bugfix] Fix image build/pull/push when 3rd-party microfrontends are bind-mounted. (by @regisb) diff --git a/tutormfe/plugin.py b/tutormfe/plugin.py index 1a1fa5ff..64cf1cde 100644 --- a/tutormfe/plugin.py +++ b/tutormfe/plugin.py @@ -143,19 +143,21 @@ def is_mfe_enabled(mfe_name: str) -> bool: # Build, pull and push {mfe}-dev images -for mfe_name, mfe_attrs in iter_mfes(): - name = f"{mfe_name}-dev" - tag = "{{ DOCKER_REGISTRY }}overhangio/openedx-" + name + ":{{ MFE_VERSION }}" - tutor_hooks.Filters.IMAGES_BUILD.add_item( - ( - name, - os.path.join("plugins", "mfe", "build", "mfe"), - tag, - (f"--target={mfe_name}-dev",), +@tutor_hooks.Actions.PLUGINS_LOADED.add() +def _mounted_mfe_image_management() -> None: + for mfe_name, _mfe_attrs in iter_mfes(): + name = f"{mfe_name}-dev" + tag = "{{ DOCKER_REGISTRY }}overhangio/openedx-" + name + ":{{ MFE_VERSION }}" + tutor_hooks.Filters.IMAGES_BUILD.add_item( + ( + name, + os.path.join("plugins", "mfe", "build", "mfe"), + tag, + (f"--target={mfe_name}-dev",), + ) ) - ) - tutor_hooks.Filters.IMAGES_PULL.add_item((name, tag)) - tutor_hooks.Filters.IMAGES_PUSH.add_item((name, tag)) + tutor_hooks.Filters.IMAGES_PULL.add_item((name, tag)) + tutor_hooks.Filters.IMAGES_PUSH.add_item((name, tag)) # init script