Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create small MFE base image using runtime MFE config system #235

Closed
Tracked by #202 ...
kdmccormick opened this issue Jul 14, 2022 · 12 comments
Closed
Tracked by #202 ...

Create small MFE base image using runtime MFE config system #235

kdmccormick opened this issue Jul 14, 2022 · 12 comments
Assignees
Labels
enhancement Relates to new features or improvements to existing features release blocker Blocks the upcoming release (fix needed)
Milestone

Comments

@kdmccormick
Copy link
Member

kdmccormick commented Jul 14, 2022

Context

The MFE runtime config API has been added to frontend-platform and edx-platform! Issue: openedx/wg-frontend#103

We would like to make use of that API in the tutor-mfe plugin so that we can statically build a minimal tutor-mfe image, which can be used by anyone along with runtime configuration.

Acceptance

  • Ensure all built-in MFEs have upgraded frontend-platform and specify an APP_ID
  • ...
  • Update mfe plugin to use dynamic config API instead of static config
  • Build & publish an upstream mfe image.
  • TODO: add remaining steps
  • ...
  • Remove --build flag from tutor dev start, as it's no longer needed.
@kdmccormick
Copy link
Member Author

@ghassanmas , @arbrandes and I recently talked about this. We needed to figure out a way to allow the MFEs to communicate with the dynamic configuration API without hard-coding the MFE_CONFIG_API_URL (which varies based on the LMS_HOST Tutor config setting) into the image. What we came up with was:

  • Set MFE_CONFIG_API_URL to a particular relative URL, for example /config-api. The relative URL would cause the MFE Config API request to go to the mfe nginx container, not the lms app container.
  • Add an nginx routing rule that would redirect /config-api requests to the proper lms API. This rule would be templated based on LMS_HOST.

@kdmccormick
Copy link
Member Author

This is blocked by completion of: openedx/wg-frontend#103

regardless, I'm starting work on a prototype over here: kdmccormick/tutor-mfe#1

@ghassanmas
Copy link
Member

@kdmccormick thats great to hear, let me know if I can help with anything.

I was doing some discovery lately regarding module federation which would be also added on top of this. Simply put the vision is just as we have config variables for settings, we can have config variables of location of bundle. e.g. if I don't want to use the default (footer, header, paragon). I could add a config to overide it. That config is a url which points to a sepearte bundle of a which can be hosted on mfe-host or any CDNs... I don't know the possbilty of this yet just though its a path worth discovering.

@kdmccormick
Copy link
Member Author

@ghassanmas Interesting, would that be an alternative to the current system for overriding components, where you must npm-install a package (like https://github.com/edx/frontend-component-footer-edx) so that it replaces the exports of an existing package (like https://github.com/openedx/frontend-component-footer)? Let me know when you have a prototype, I am interested to see.

@kdmccormick
Copy link
Member Author

kdmccormick commented Aug 17, 2022

Something I noticed while working on this:

The Dockerfile uses staged builds to progressively build a base image and and intermediate prod image for every single installed MFE. I think the intention is that rebuilding, say, gradebook-dev, would only require the gradebook stages to be rebuilt. It seems though that Docker does not do this: it rebuilds every stage including and above the gradebook-dev stage, including learning, learning-dev, learning-src, account-dev, account-src, and so on. I believe that this significantly slows down the startup time for the MFEs in dev mode.

@kdmccormick
Copy link
Member Author

I created overhangio/tutor-mfe#58 to address ^

@ghassanmas
Copy link
Member

@ghassanmas Interesting, would that be an alternative to the current system for overriding components, where you must npm-install a package (like https://github.com/edx/frontend-component-footer-edx) so that it replaces the exports of an existing package (like https://github.com/openedx/frontend-component-footer)? Let me know when you have a prototype, I am interested to see.

Yes your are exactly right. I haven't created a prototype that exactly uses those pacakges per say, but I tried to do a POOF of concpent with basic webpack/react and it worked, what I did exactly is that the app at runtime was able to require a module (a module can be a library, compnenet, pacakge...etc) from a somewhere else. What I used is WebpackModuleFederatoinPlugin, where I had to configure both the module (that was imported at run time) and the app that used it.

@ghassanmas
Copy link
Member

Something I noticed while working on this:

The Dockerfile uses staged builds to progressively build a base image and and intermediate prod image for every single installed MFE. I think the intention is that rebuilding, say, gradebook-dev, would only require the gradebook stages to be rebuilt. It seems though that Docker does not do this: it rebuilds every stage including and above the gradebook-dev stage, including learning, learning-dev, learning-src, account-dev, account-src, and so on. I believe that this significantly slows down the startup time for the MFEs in dev mode.

I haven't used tutor-mfe in development mode, or I didn't rely on it. I think there is area of improvment in the Dockerfile, Now I am not sure about what exactly you did, I know docker stage build is meant to optimize the cahching or buildtime...etc for example I always enable docker buildkit so that those stages would built in parrales (but it's gonna consume network/RAM at a high scale) On the other hand there is somehting that can enhance buildtime (consecutive built) which I though about before I will link what I mean in the PR you opend.

kdmccormick referenced this issue in kdmccormick/frontend-app-account Aug 23, 2022
Recently, a capability was added to this MFE that allows it
to load configuration from an the LMS's MFE Config
API instead of requiring it to be baked-in to the webpack
build.

When enabled, though, this capability blocks any render
of the MFE until the Config API responds. So, in order to
minimize the amount of time that the MFE is waiting
on the Config API response, we preload the API
response via a in the section
of index.html, which recommends to the browser
to immediately begin loading the MFE Config API
response as soon as index.html is loaded. Otherwise,
the Config API wouldn't be called until React and
frontend-platform are loaded.
Recently, a capability was added to MFE that allows it
to load configuration from an LMS API (the "MFE Config
API") instead of requiring it to be baked-in to the webpack
build.

Related to:
* https://github.com/overhangio/2u-tutor-adoption/issues/87
* openedx/wg-frontend#103
@kdmccormick kdmccormick changed the title Create small MFE base image using dynamic MFE config system Create small MFE base image using runtime MFE config system Aug 30, 2022
@kdmccormick
Copy link
Member Author

Update: This is in review on overhangio/tutor-mfe#69

@kdmccormick
Copy link
Member Author

Moving this to the build-test-release-wg repo, since this is a big concern for the Olive release.

@kdmccormick kdmccormick transferred this issue from openedx-unsupported/wg-developer-experience Dec 5, 2022
@kdmccormick kdmccormick added the release blocker Blocks the upcoming release (fix needed) label Dec 5, 2022
@ghassanmas
Copy link
Member

[Update]: From my end one of the current blocker is this openedx/frontend-app-gradebook/pull/290

@arbrandes arbrandes added this to the Olive.1 milestone Dec 6, 2022
@arbrandes arbrandes added the enhancement Relates to new features or improvements to existing features label Dec 6, 2022
@arbrandes
Copy link
Contributor

Gradebook is no longer a blocker, and it looks like images are going to start being built by CI! I think we can close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Relates to new features or improvements to existing features release blocker Blocks the upcoming release (fix needed)
Projects
Development

Successfully merging a pull request may close this issue.

3 participants