Proposal: Official Docker Images for Xylon - with NO forks/patches. Is it possible?

With the ongoing surge of AI-discovered software vulnerabilities, the ability to deploy security updates quickly is becoming critical. At the same time, Open edX community in general has faced longstanding challenges around institutions/operators depending on old releases of Open edX.

I’d like to propose that we make a serious architectural push toward resolving this for the Xylon release, with a simple solution: starting from the Xylon release, the only supported production deployment method for the Open edX backend should be running the official docker images, and nobody should be building custom images (for the backend anyways).

What this would mean is that applying security updates and bugfixes, e.g. going from Xylon.1 to Xylon.2, is as simple as bumping the container version and rolling the update out to the cluster/VM. The time required would go from hours to minutes.

How this could be achieved

  1. Focus on the backend: Frontends tend to be heavily customized or themed, and the value for effort ratio is not as promising at the moment; so let’s focus on creating a simplified, common backend deployment that everyone can use, and continue to use the existing methodology of customizing and deploying frontend-base/MFEs.

    • Ensure that Tutor has a command to do a quick backend-only deployment, without tying the frontend deployment lifecycle to the backend.
    • Make all Open edX backend releases fully compatible with the previous release’s MFEs, so operators can upgrade the backend to Xylon as soon as it’s released and then slowly upgrade the MFEs from Willow to Xylon over, say, the next month.
  2. [Forcibly] embrace extension points: create a list of all customizations that large institutions currently achieve by patching/forking openedx-platform’s code, and adopt a goal to ensure that equivalent functionality can be achieved via config/plugins/hooks/filters by Xylon. This has been an ongoing effort, and we’ve made great progress, so I’m not sure how much work is left to do. Quantifying and evaluating that would be a great first step. And having a strict “no forks/patches to openedx-platform” goal as a forcing function would be a great way to finalize this effort.

  3. Support a python overlay in the openedx-platform image: the official openedx/edxapp docker image should be redesigned to have an overlay directory such as /openedx/extra-packages, where plugins, customizations, and additional apps can be installed without re-building the image.

    • This directory would be on PYTHONPATH, so it is searched before the venv’s site-packages. Python 3.12’s importlib.metadata.entry_points() scans every sys.path entry and de-duplicates distributions, with the first found winning. So this would work well: plugin discovery and XBlock entry points would work as expected. Forked packages in the overlay would be prioritized over the versions in the base image.
    • The specification of the overlay (e.g. list of plugins / python packages) is treated as regular configuration for each deployment.
    • When the official image boots up, it checks hash(base venv requirements + system version (ubuntu version, glic, python version, etc.) + overrides) and checks if the overlay volume contains a compatible build of the overlay; if so, that is used as the overlay. If not, a new cached overlay is built within the image (so using the same python version, base venv, glibc, etc.) and saved into the overlay volume. As a result, scaling out a deployment is very fast (the overlay is built once and then the build on the shared volume is used by all compatible deployments, e.g. all Xylon.1 and Xylon.2 containers deployed to k8s during a rollout; if a future version like Xylon.3 bumps some critical system package, the first time a Xylon.3 image is run, it would rebuild its overlay to be compatible, and from then on all Xylon.3 images run instantly with the new overlay).
  4. Other technical improvements:

    • Get rid of all Node/SASS/comprehensive/collectstatic/theming code from the backend. (If we still depend on some HTML on the backend, the source artifacts could be moved to a separate repo and only the resulting plain HTML+CSS+JS committed into openedx-platform until such time as we truly can remove it all.)
    • Ship a generous superset of the Ubuntu system libraries that plugins may need. If any custom functionality requires other system libraries beyond this set, it needs to be implemented as a sidecar or separate container/service, not a python plugin.
    • Translations: allow mounting an additional volume like /openedx/translations/ that is appended to PREPEND_LOCALE_PATHS, so custom/additional translations can be injected into the base image as needed. But keep in mind that most of the UI strings are in the frontend.
    • Try to simplify configuration in general and allow more things to be set by environment variables rather than django settings overrides.
    • Post-Xylon: merge lms and cms together.

Well, that’s my idea. I think it would both nicely simplify deployment and improve our security posture and upgrade speed. But is it practical and worth the effort? Did I miss something that would make this much harder to achieve? What are people’s thoughts?

Please let me know if I misunderstood anything, but how would deploying stage environments or sandboxes work when we need to test the changes in a non-dev environment? Some projects require multiple rounds of external QA before moving forward with the product proposal and upstream implementation.

Stage environments and sandboxes should be easier than ever, because you’d be deploying 100% identical images among all the environments, just with different environment variables set. The stage environment would have different environment variables / injected config for which databases and S3 bucket(s) to use, but otherwise everything would be identical.

The key point is that you’re never rebuilding images when you test out different scenarios and make fixes. You’re just adjusting the config (which upstream image to use - xylon.2 or xylon.3, which plugins to install - my-xblock 3.0.2, my-grader 2.8.1, my-monitoring 1.0.0, and which config settings (DB is stage.mysql.local not prod.mysql.local).

Deploying to a new environment just involves rolling out the containers and running migrations, but not building images. (Ignoring frontends here.)

I meant the use case where we modify the code within openedx-platform, not its dependencies. Let’s say we make a major change to the import mechanism and want to provide a sandbox to a few institutions to test it before we merge the changes. We could use feature flags or temporary plugins for small things and just merge them as-is, but for bigger features it would introduce a whole new layer of complexity.

Ah, well that’s the kind of thing I want to ask about here.

If you’re just talking about the normal developer workflow where you’ve made some change or fix to openedx-platform, the PR sandboxes would continue to work as they do today, so you’d open a PR to openedx-platform, and a developer sandbox would automatically spin up, and you can send that to people to test the change. Nothing different there.

But if you’re saying “my institution has a heavily customized platform with themes and plugins and custom frontends”, and we want to spin up a temporary prod-like sandbox in our private environment with new modifications to openedx-platform that change it from the plain upstream version and can’t be isolated to a plugin/hook/etc., then that’s exactly the kind of thing that would be discouraged/difficult to do in this scenario, and that’s what I’d like people to flag.

(It’s not actually technically difficult or impossible to do - after all, you can just take the upstream base image, apply a new layer over top of it with your customization, then deploy it, but doing that regularly means bringing image building and divergent images back to prod deployments and over time would defeat the purpose as the number of such customizations built up over time.)

The goal would be for production environments to rarely if ever modify openedx-platform, other than upgrading official releases, like Xylon.1 to Xylon.2.


Or in other words:

We could use…temporary plugins for small things

The architectural goal of the platform is that anything custom you reasonably want to achieve can and should be done via plugins (or hooks/filters/xblocks/etc.). So if you’re encountering real-world change requirements on a regular basis that cannot be achieved via plugins, that’s a platform shortcoming that we should resolve. Such “simple things that can’t be done via extension points” are what I’d like us to categorize and resolve so that we can achieve the goal.

Let’s say we make a major change to the import mechanism

Can you elaborate on this example?

@braden thanks for this proposal, I think this is a necessary step for evolving the platform, streamlining extension development and enabling quick patching and better updates.

On the idea of supporting a python overlay in the openedx-platform image: From the docker perspective, does this mean mounting a volume in the container where all the extra requirements are going to be installed?

I see this as a great way to allow fast development and for small instances, but for larger instances where you have several environments (sit, stage, prod), ideally you would want to guarantee parity and minimize startup time (which would only be an issue the first time the container launches according to your proposal, but then what happens if you have several pods in a k8s cluster, for example?).

For these use cases, what I would suggest is to use the base image, and then extend it via normal Docker means (Dockerfile FROM openedx:xylon etc., for example).

This also has the side effect of greatly reducing the build time for these images, as most of the work is already done in the base image.

Now, there may be cases where people still need to patch openedx-platform, I think those cases would be out of scope for this and they would still need to build the image from scratch, but as a community we should push to make this no longer needed and promote extensibility instead.

Hi, @braden Thanks for bringing this up; it’s really important to improve the security posture of the platform for the benefit of the whole community.

I just have some questions regarding some of the points you’re proposing:

I’d like to propose that we make a serious architectural push toward resolving this for the Xylon release, with a simple solution: starting from the Xylon release, the only supported production deployment method for the Open edX backend should be running the official docker images, and nobody should be building custom images (for the backend anyways).

1. What does it mean exactly by official Docker images? Does it mean that the images will be part of the Docker Official Images program? Does it mean that they will live under the OpenedX organization in Docker Hub instead of Overhangio?

2. To what extent do you propose that nobody should be building custom images? For installations that use the default platform functionality, I think it’s ok, but for customized platforms, what will it mean for those?

What this would mean is that applying security updates and bugfixes, e.g. going from Xylon.1 to Xylon.2, is as simple as bumping the container version and rolling the update out to the cluster/VM.

3. Is this different than the current workflow where we bump the Tutor version to obtain new images (minor or patch updates)?

Ensure that Tutor has a command to do a quick backend-only deployment, without tying the frontend deployment lifecycle to the backend.

4. Is there any difference between updating the tag or the image digest value in the config.yml and running tutor k8s apply with this new command?

And having a strict “no forks/patches to openedx-platform” goal as a forcing function would be a great way to finalize this effort.

5. To what extent do you imagine the “no forks/patches to openedx platform” goal?

Support a python overlay in the openedx-platform image

I think this is what this plugin tries to cover: GitHub - overhangio/tutor-livedeps: Tutor plugin that allows installing python packages at runtime without building the openedx image (Under active development: works only for tutor local and tutor k8s for now) · GitHub , or do you foresee a difference between what you are proposing and the tutor-livedeps plugin?

How do these two scenarios differ? Both instances (a PR sandbox and a temporary prod-like sandbox in a private environment) use a feature branch that diverges from the upstream one. Would opening a PR create a temporary Docker image that’s marked as “official, but experimental”, which would bypass the image tag restrictions?

I was thinking about this PR, but it’s a very rare scenario. I suppose this one is a better example - it modifies the transformers, so we do not want to merge this until it’s thoroughly tested by multiple institution-specific teams (course authors, UX, etc.), and we need some way to provide the testing environment. Then, despite being better than years ago, the usual PR flow (with product proposal and developer review) still takes many months in some cases, which is not a reasonable delay for some institutional deployments.

Edit: also, even if we had quicker turnarounds for the PRs, we usually do not backport the features, only the fixes. In some cases, we cannot delay releasing new features until the next named release.

Yes. The volume contains the installed additional requirements. So it looks like this:

  • /openedx/venv/bin/python - python, installed by Tutor
  • /openedx/venv/lib/python3.12/site-packages/ - base requirements (Django, etc.)
  • /openedx/extra-packages - shared volume mounted on all images, for extra packages
    • e.g. /openedx/extra-packages/xylon-py312-amd64-linux-gnu-glibc2.39-0ubuntu8.12/site-packages would hold installed versions of my-custom-xblock-3.0 and any dependencies it has that aren’t already installed into /openedx/venv/lib/python3.12/site-packages/.
    • on container startup, if /openedx/extra-packages/xylon-py312-amd64-linux-gnu-glibc2.39-0ubuntu8.12/site-packages is empty/outdated, then it will read some spec file like /openedx/extra-packages/requirements.toml and install them. But because this is a shared volume, this slow install operation only happens one time. For any additional containers that you start later, the packages are already installed, and found on the volume, so they’re just mounted and used (added to PYTHONPATH).

If you have several pods, you’d roll out only one container at first, and then once it’s spent ~10 seconds installing and building the extra requirements and is in a healthy/ready state, you can scale it up instantly to however many pods you want, and then you can scale down the previous version. All the pods would behave identically going forward, and there is no build step after the first image has cached its extra requirements build.

That would be fine. (Why aren’t we doing that already?!?!?)

However, either way, only the additional requirements are getting built. So that way would be a bit more traditional, but not necessarily faster.

I’m still liking the “extra requirements” volume instead, because:

  • When you “extend it via normal Docker means (Dockerfile FROM openedx:xylon)”, you may end up overwriting base requirements. So the upstream image can bump Django from 5.2.19 to 5.2.20 for an important security fix, but you install an XBlock which depends on Django==5.2.19 and then it silently restores the insecure version of Django, overwriting the base image, and you would never even know that the security upgrade is lost due to your customization. With the “extra requirements” volume, we can have a check that no base requirements are shadowed/overwritten unless explicitly declared via an OVERRIDE_BASE_PACKAGES list. (Because the override packages are in a separate folder, not merged into the base venv)
  • When you build custom docker images, you have to store them somewhere and manage the images. With the volume approach, you can skip this step. You don’t have to manage or build images at all. You just bump the version of the upstream image, then roll out the new deployment.

However, this is just a rough idea so I’m very open to other more standard approaches if it makes more sense :slight_smile:

I didn’t mean the Docker Official Images program. I just meant that everyone would be using the same images, which would live on Docker Hub under either Overhangio or Open edX. Currently, my understanding is that most production deployments use images that tutor builds from scratch, starting with ubuntu:22.04 rather than starting with some openedx:xylon base image.

I can’t (and wouldn’t) actually block anyone from building custom images. But what I want is for operators to be able to achieve most customizations without modifying the platform or the base image. You should be able to customize the platform using plugins/hooks/filters/APIs/themes/etc, which would not require modifying the image. (instead, all of these are achieved by changing a setting or installing a plugin)

Not sure yet.

Probably not, but I’m not sure yet.

Oh, neat. I hadn’t heard about that! Yeah it’s a very similar idea, though I’m proposing using a volume rather than object storage. I don’t think an S3 server should be a dependency for container boot.

OK, those are good points. But this is exactly the problem I’m trying to solve: as soon as you start forking and modifying the platform to implement a feature, then applying security patches becomes more involved because not only do you have to rebase your changes onto the new version, but you have to do more testing to ensure your customizations don’t cause issues once you’ve rebased them.

So: how often do such features require modifying the core platform code, rather than being implementable as plugins?

In the example you provided, for example, you could subclass HiddenContentTransformer as CustomizedHiddenContentTransformer, which is installed as a plugin, and use configuration to replace the built-in HiddenContentTransformer with CustomizedHiddenContentTransformer. But I know that sounds like a pain.

Sooner or later (and I can definitely think of a “sooner” case here that already applies to Xylon), somebody will run into a scenario where they need to modify the openedx-platform for the instance and will need a bypass for this, which will likely increase their number of forks by 1 (effectively reducing the security even further). Maybe we could make this the default experience and let users disable it with a toggle? Alternatively, we could consider other approaches, like adding a separate Docker layer that applies the modifications on top of the built image (after verifying the official code hashes).

Agree, but I would also like to have the option to “persist” these extra packages in a custom image if desired, perhaps have a tutor command or standard script that can be called within a Dockerfile to do the same thing the original image would do on first run, but persist it within the image?