diff --git a/README.md b/README.md index f3151de..3330124 100644 --- a/README.md +++ b/README.md @@ -8,13 +8,13 @@ for MFEs. | Open edX release | Tutor version | Tutor MFE Version | Plugin release | |------------------|-------------------|--------------------------------------|----------------| -| Olive | `>=15.0, <16` | `edunext/tutor-mfe@15.0.7.post1` | 1.x.x | +| Nutmeg | `>=13.0, <14` | `edunext/tutor-mfe@14.0.2.post1` | 14.x.x | ## Installation ```bash -pip install git+https://github.com/edunext/tutor-contrib-mfe-extensions@v1.1.0#egg=tutor-contrib-mfe-extensions==v1.1.0 -pip install git+https://github.com/edunext/tutor-mfe@v15.0.7.post1#egg=tutor-mfe==v15.0.7.post1 +pip install git+https://github.com/edunext/tutor-contrib-mfe-extensions@v14.0.0#egg=tutor-contrib-mfe-extensions==v14.0.0 +pip install git+https://github.com/edunext/tutor-mfe@v14.0.2.post1#egg=tutor-mfe==v14.0.2.post1 ``` ## Plugin Configuration @@ -36,42 +36,51 @@ bundles of each MFE and simply serve a small index.html file through caddy. We use webpack's [`output.publicPath`](https://webpack.js.org/configuration/output/#outputpublicpath) to accomplish this. Due to current limitations in the building scripts -we need to use a custom version of -[`frontend-build`](https://github.com/eduNEXT/frontend-build/branches/all?query=cdn). -Until [`openedx/frontend-build#398`](https://github.com/openedx/frontend-build/pull/398) -is merged. - -There is a custom version for each major release of `frontend-build` used by -the 7 default MFEs in olive: - -- account: `v12.0.6-cdn-support` -- course-authoring: `v11.0.2-cdn-support` -- discussions: `v11.0.2-cdn-support` -- authn: `v11.0.2-cdn-support` -- gradebook: `v9.1.4-cdn-support` -- learning: `v9.1.4-cdn-support` -- profile: `v12.0.6-cdn-support` - -In addition, we need to use a custom version of `tutor-mfe` to set extra environment -variables before the build step. The custom version version of `tutor-mfe` is going -to be needed for Olive installations and will eventually be dropped some time during -the Palm release. +we need to use custom versions of `frontend-platform` that include a backport of +[`openedx/frontend-platform#568`](https://github.com/openedx/frontend-platform/pull/568) +for releases previous to Quince. + +The following is a list of supported MFEs for the current plugin version, each MFE is a +custom fork hosted by eduNEXT. You might use your own fork, but you must include the backport +mentioned before. + + +- Learning: [`eduNEXT/frontend-app-learning@ednx-release/nuez.master`](https://github.com/eduNEXT/frontend-app-learning/tree/ednx-release/nuez.master) + +In addition, we need to use a custom version of `tutor-mfe` that includes the patch +`mfe-dockerfile-production-final` introduced in [`overhangio/tutor-mfe#179`](https://github.com/overhangio/tutor-mfe/pull/179). ### Building Caveats -At the moment each MFE image will be tied to a specific CDN endpoint. As a result, -it isn't possible to reuse the MFE image between environments (namely Staging and -production). You will have to rebuild the image in the following scenarios: - -1. You have a working production image and want to enable CDN support: You must - rebuild the image using the same parameters while setting the - `MFE_EXTENSIONS_CDN_URL` variable with your distribution. -2. You modified your CDN endpoint and it now uses a different URL: Update the - value of `MFE_EXTENSIONS_CDN_URL` to the new URL. -3. You made changes to the code of any of the MFEs in the image and want to - deploy a new version: If your configuration already had CDN support update - the other parameters as you usually do in your deployment process, if it - didn't have CDN support follow step #1. +The value of `publicPath` is fixed at build time, therefore it's not possible to reuse +the MFE docker image if we set it's value to a specific CDN endpoint. +To avoid this limitation we use a script +[`docker-entrypoint.sh`](tutormfe_extensions/templates/mfe/build/mfe/docker-entrypoint.sh) +to dinamically change a placeholder value used in `publicPath` each time the container is +started. + +We need to make sure our image is built using the placeholder `MFE_EXTENSIONS_PLACEHOLDER_STRING/app_name` as our `publicPath` (where `app_name` refers to the value of `MFE_MYMFE_MFE_APP.name`). In Nutmeg you configure `PUBLIC_PATH` through the `config.yml` file: + +```yaml +MFE_LEARNING_MFE_APP: + env: + production: + PUBLIC_PATH: MFE_EXTENSIONS_PLACEHOLDER_STRING/learning + MFE_CONFIG_API_URL: /api/mfe_config/v1 + APP_ID: learning + name: learning + port: 2000 + repository: https://github.com/eduNEXT/frontend-app-learning.git + version: ednx-release/nuez.master +``` + +The learning MFE in eduNEXT fork also has support for the [`MFE_CONFIG_API`](https://github.com/openedx/edx-platform/blob/master/lms/djangoapps/mfe_config_api/docs/decisions/0001-mfe-config-api.rst) in Nutmeg, you must also include the variables `MFE_CONFIG_API_URL` and `APP_ID` in your +`config.yml` while building the MFE to enable the API. + +Once you enable the plugin and add the previous snippet to your configuration you can build +an image with a _"dynamic"_ `publicPath`. By default the placeholder will be replaced by +an empty string, which was the original value. In a Kubernetes environment it will be +replaced with the value of `MFE_EXTENSIONS_CDN_URL`. ## Hosting by Path diff --git a/tutormfe_extensions/__about__.py b/tutormfe_extensions/__about__.py index c68196d..2294691 100644 --- a/tutormfe_extensions/__about__.py +++ b/tutormfe_extensions/__about__.py @@ -1 +1 @@ -__version__ = "1.2.0" +__version__ = "14.0.0" diff --git a/tutormfe_extensions/patches/kustomization-configmapgenerator b/tutormfe_extensions/patches/kustomization-configmapgenerator deleted file mode 100644 index 7ecd338..0000000 --- a/tutormfe_extensions/patches/kustomization-configmapgenerator +++ /dev/null @@ -1,6 +0,0 @@ -- name: mfeextensions-docker - files: - - plugins/mfe_extensions/apps/docker-entrypoint.sh - options: - labels: - apps.kubernetes.io/name: mfe diff --git a/tutormfe_extensions/patches/mfe-dockerfile-post-npm-install b/tutormfe_extensions/patches/mfe-dockerfile-post-npm-install deleted file mode 100644 index e69de29..0000000 diff --git a/tutormfe_extensions/patches/mfe-dockerfile-post-npm-install-account b/tutormfe_extensions/patches/mfe-dockerfile-post-npm-install-account deleted file mode 100644 index a620cf9..0000000 --- a/tutormfe_extensions/patches/mfe-dockerfile-post-npm-install-account +++ /dev/null @@ -1,3 +0,0 @@ -{% if MFE_EXTENSIONS_NPM_OVERRIDES %} -RUN npm install git+https://github.com/eduNEXT/frontend-build#v12.0.6-cdn-support -{% endif %} diff --git a/tutormfe_extensions/patches/mfe-dockerfile-post-npm-install-authn b/tutormfe_extensions/patches/mfe-dockerfile-post-npm-install-authn deleted file mode 100644 index 738083b..0000000 --- a/tutormfe_extensions/patches/mfe-dockerfile-post-npm-install-authn +++ /dev/null @@ -1,3 +0,0 @@ -{% if MFE_EXTENSIONS_NPM_OVERRIDES %} -RUN npm install git+https://github.com/eduNEXT/frontend-build#v11.0.2-cdn-support -{% endif %} diff --git a/tutormfe_extensions/patches/mfe-dockerfile-post-npm-install-course-authoring b/tutormfe_extensions/patches/mfe-dockerfile-post-npm-install-course-authoring deleted file mode 100644 index 738083b..0000000 --- a/tutormfe_extensions/patches/mfe-dockerfile-post-npm-install-course-authoring +++ /dev/null @@ -1,3 +0,0 @@ -{% if MFE_EXTENSIONS_NPM_OVERRIDES %} -RUN npm install git+https://github.com/eduNEXT/frontend-build#v11.0.2-cdn-support -{% endif %} diff --git a/tutormfe_extensions/patches/mfe-dockerfile-post-npm-install-discussions b/tutormfe_extensions/patches/mfe-dockerfile-post-npm-install-discussions deleted file mode 100644 index 738083b..0000000 --- a/tutormfe_extensions/patches/mfe-dockerfile-post-npm-install-discussions +++ /dev/null @@ -1,3 +0,0 @@ -{% if MFE_EXTENSIONS_NPM_OVERRIDES %} -RUN npm install git+https://github.com/eduNEXT/frontend-build#v11.0.2-cdn-support -{% endif %} diff --git a/tutormfe_extensions/patches/mfe-dockerfile-post-npm-install-gradebook b/tutormfe_extensions/patches/mfe-dockerfile-post-npm-install-gradebook deleted file mode 100644 index 3db2003..0000000 --- a/tutormfe_extensions/patches/mfe-dockerfile-post-npm-install-gradebook +++ /dev/null @@ -1,3 +0,0 @@ -{% if MFE_EXTENSIONS_NPM_OVERRIDES %} -RUN npm install git+https://github.com/eduNEXT/frontend-build#v9.1.4-cdn-support -{% endif %} diff --git a/tutormfe_extensions/patches/mfe-dockerfile-post-npm-install-learning b/tutormfe_extensions/patches/mfe-dockerfile-post-npm-install-learning deleted file mode 100644 index 3db2003..0000000 --- a/tutormfe_extensions/patches/mfe-dockerfile-post-npm-install-learning +++ /dev/null @@ -1,3 +0,0 @@ -{% if MFE_EXTENSIONS_NPM_OVERRIDES %} -RUN npm install git+https://github.com/eduNEXT/frontend-build#v9.1.4-cdn-support -{% endif %} diff --git a/tutormfe_extensions/patches/mfe-dockerfile-post-npm-install-profile b/tutormfe_extensions/patches/mfe-dockerfile-post-npm-install-profile deleted file mode 100644 index a620cf9..0000000 --- a/tutormfe_extensions/patches/mfe-dockerfile-post-npm-install-profile +++ /dev/null @@ -1,3 +0,0 @@ -{% if MFE_EXTENSIONS_NPM_OVERRIDES %} -RUN npm install git+https://github.com/eduNEXT/frontend-build#v12.0.6-cdn-support -{% endif %} diff --git a/tutormfe_extensions/patches/mfe-dockerfile-pre-npm-build b/tutormfe_extensions/patches/mfe-dockerfile-pre-npm-build deleted file mode 100644 index ff0ba56..0000000 --- a/tutormfe_extensions/patches/mfe-dockerfile-pre-npm-build +++ /dev/null @@ -1 +0,0 @@ -ENV ASSETS_URL="MFE_EXTENSIONS_PLACEHOLDER_STRING" diff --git a/tutormfe_extensions/patches/mfe-dockerfile-production-final b/tutormfe_extensions/patches/mfe-dockerfile-production-final new file mode 100644 index 0000000..ca86321 --- /dev/null +++ b/tutormfe_extensions/patches/mfe-dockerfile-production-final @@ -0,0 +1,5 @@ +COPY --chmod=755 ./docker-entrypoint.sh /openedx + +ENTRYPOINT ["/openedx/docker-entrypoint.sh"] + +CMD [ "caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile" ] diff --git a/tutormfe_extensions/patches/openedx-lms-production-settings b/tutormfe_extensions/patches/openedx-lms-production-settings new file mode 100644 index 0000000..3bd02f7 --- /dev/null +++ b/tutormfe_extensions/patches/openedx-lms-production-settings @@ -0,0 +1,35 @@ +LEARNING_MICROFRONTEND_URL = "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}/learning" +ENABLE_MFE_CONFIG_API = True +MFE_CONFIG = { + "PARAGON_THEME_URLS": { + "core": { + "url": "https://cdn.jsdelivr.net/combine/npm/@edx/paragon@22.0.0-alpha.13/styles/css/themes/light/utility-classes.min.css,npm/@edx/paragon@22.0.0-alpha.13/dist/core.min.css" + }, + "defaults": { + "light": "light" + }, + "variants": { + "light": { + "url": "https://css-varsify.s3.amazonaws.com/public/a9959998-0bab-4447-ada5-6819866195f3.css" + } + } + }, + "ACCESS_TOKEN_COOKIE_NAME": "edx-jwt-cookie-header-payload", + "BASE_URL": "{{ MFE_HOST }}", + "CSRF_TOKEN_API_PATH": "/csrf/api/v1/token", + "CREDENTIALS_BASE_URL": "", + "DISCOVERY_API_BASE_URL": "{% if DISCOVERY_HOST is defined %}{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ DISCOVERY_HOST }}{% endif %}", + "FAVICON_URL": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}/favicon.ico", + "LANGUAGE_PREFERENCE_COOKIE_NAME": "openedx-language-preference", + "LMS_BASE_URL": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}", + "LOGIN_URL": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}/login", + "LOGO_URL": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}/theming/asset/images/logo.png", + "LOGO_TRADEMARK_URL": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}/theming/asset/images/logo.png", + "LOGO_WHITE_URL": "", + "LOGOUT_URL": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}/logout", + "MARKETING_SITE_BASE_URL": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}", + "REFRESH_ACCESS_TOKEN_ENDPOINT": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}/login_refresh", + "SEGMENT_KEY": "", + "STUDIO_BASE_URL": "{{ 'https' if ENABLE_HTTPS else 'http' }}://{{ CMS_HOST }}", + "USER_INFO_COOKIE_NAME": "user-info", +} diff --git a/tutormfe_extensions/plugin.py b/tutormfe_extensions/plugin.py index a56a0ef..f6af182 100644 --- a/tutormfe_extensions/plugin.py +++ b/tutormfe_extensions/plugin.py @@ -22,7 +22,6 @@ ("MFE_EXTENSIONS_VERSION", __version__), ("MFE_EXTENSIONS_CDN_URL", ""), ("MFE_EXTENSIONS_BY_PATH", True), - ("MFE_EXTENSIONS_NPM_OVERRIDES", True), ] ) @@ -42,7 +41,22 @@ # Danger zone! # Add values to override settings from Tutor core or other plugins here. # Each override is a pair: (setting_name, new_value). For example: - ### ("PLATFORM_NAME", "My platform"), + ( + "MFE_LEARNING_MFE_APP", + { + "name": "learning", + "repository": "https://github.com/eduNEXT/frontend-app-learning", + "env": { + "production": { + "PUBLIC_PATH": "MFE_EXTENSIONS_PLACEHOLDER_STRING/learning", + "MFE_CONFIG_API_URL": "/api/mfe_config/v1", + "APP_ID": "learning", + } + }, + "port": 2000, + "version": "ednx-release/nuez.master", + }, + ), ] ) @@ -148,6 +162,7 @@ [ ("mfe_extensions/apps", "plugins"), ("mfe_extensions/k8s", "plugins"), + ("mfe/build", "plugins"), ], ) diff --git a/tutormfe_extensions/templates/mfe_extensions/apps/docker-entrypoint.sh b/tutormfe_extensions/templates/mfe/build/mfe/docker-entrypoint.sh similarity index 100% rename from tutormfe_extensions/templates/mfe_extensions/apps/docker-entrypoint.sh rename to tutormfe_extensions/templates/mfe/build/mfe/docker-entrypoint.sh diff --git a/tutormfe_extensions/templates/mfe_extensions/apps/.gitignore b/tutormfe_extensions/templates/mfe_extensions/apps/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/tutormfe_extensions/templates/mfe_extensions/jobs/init/.gitignore b/tutormfe_extensions/templates/mfe_extensions/jobs/init/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/tutormfe_extensions/templates/mfe_extensions/k8s/mfe-deployment-overrides.yml b/tutormfe_extensions/templates/mfe_extensions/k8s/mfe-deployment-overrides.yml index b7eeb8b..d9a37cd 100644 --- a/tutormfe_extensions/templates/mfe_extensions/k8s/mfe-deployment-overrides.yml +++ b/tutormfe_extensions/templates/mfe_extensions/k8s/mfe-deployment-overrides.yml @@ -10,20 +10,3 @@ spec: - name: MFE_CDN_URL value: {{ MFE_EXTENSIONS_CDN_URL }} name: mfe - volumeMounts: - - mountPath: /openedx/bin/ - name: entrypoint - command: - - /openedx/bin/docker-entrypoint.sh - args: - - caddy - - run - - --config - - /etc/caddy/Caddyfile - - --adapter - - caddyfile - volumes: - - configMap: - defaultMode: 484 - name: mfeextensions-docker - name: entrypoint