This page is out-of-date! For the latest Open edX development workflows with Tutor, see https://docs.tutor.overhang.io/dev.html. |
This page is a work in progress. Reach out to #devenv-working-group on slack with questions |
Tutor is a Docker-based OpenEdX distribution. It was adopted as the primary installation method for OpenEdX with the Maple release in December 2021. It has also been widely adopted as a development platform in the greater OpenEdx community as a replacement for devstack. We hope to make this the case at 2U/edX as well.
For more general information on Tutor website, you can visit the documentation site at https://docs.tutor.overhang.io/index.html .
If you are unfamiliar with Docker, you may wish to familiarize yourself with some of the concepts here: https://www.docker.com/resources/what-container/ https://docs.docker.com/compose/
If you come across unknown terms, check out the Docker glossary: https://docs.docker.com/glossary/
These instructions are for developing in the edx-platform repository ONLY. Information about development of MFEs and other IDAs is forthcoming.
Familiarize yourself with how tutor works by taking a look at https://docs.tutor.overhang.io/intro.html#how-does-tutor-work. This will provide helpful context when following the setup steps below.
You will want to create and activate a python3 virtual environment. You will also need to have Docker Desktop set up.
Heuristically, 9.5G should be enough memory to allot to Docker to run everything successfully.
If you are still running devstack you may need to allocate additional disk space to account for duplicate images for each service.
To develop off the master branch of edx-platform, you will need to install Tutor from the “nightly” branch, documented here, whose installation method is documented here: https://docs.tutor.overhang.io/tutorials/nightly.html .
Then you should be able to follow the directions for first time setup and to ensure the LMS and CMS are running and accessible. Now is a good time to familiarize yourself with the following concepts:
At this point you are running off the master branch at the point in time when each ‘nightly’ image was built.
In order to run the code in your local checkout of edx-platform you will need to mount that folder into the container. Additionally you will also want to mount a virtualenv folder to persist any differing pip requirements.
Each service you plan to run with a local branch will need it’s own venv folder. It’s recommended you create a folder on your machine to manage these.
mkdir ~/tutor-venvs |
Use the ‘copyfrom’ command to copy the default environment into this folder. copy-files-from-containers-to-the-local-filesystem
If you used the same tutor-venvs
folder above:
tutor dev copyfrom lms /openedx/venv $HOME/tutor-venvs/venv-openedx |
it’s possible that this command might fail copying some requirements based on MacOS filesystem differences. Generally this won’t be an issue because we’re going to re-install requirements later |
Read the directions to bind-mount a project folder to point Tutor towards your local branch of edx-platform and the venv folder you just created. You will need to include these mount arguments each time you run a command that starts the service if you want it to run against you locally checked out branch.
For example 'run lms bash' using the venv created above:
tutor dev run lms \ -m $YOUR_PROJECT_WORKSPACE/edx-platform \ -m lms,lms-worker,cms,cms-worker:$HOME/tutor-venvs/venv-openedx/venv:/openedx/venv \ bash |
work is being done to make this a persistent configuration, in the future you won’t need to include a pile of mount arguments in every command |
Follow the instructions at setting-up-a-development-environment-for-edx-platform to install python/node requirements and compile static assets.
LMS will be accessible at http://local.overhang.io:8000.
CMS will be accessible at http://studio.local.overhang.io:8001
To test if you are set up for development, make a cosmetic or logging change in your local branch of edx-platform. They server should automatically reload and pick up your change.
Tutor makes adding test data pretty easy. To match the users and courses created in normal devstack provisioning, you have to stop the local server with tutor local stop
(note in this case you actually do want local
and not dev
). You can run the createuser
and importdemocourse
commands as follows:
tutor dev createuser --staff --superuser staff staff@example.com tutor dev importdemocourse |
If you are doing work on edx-platform plugins, the following steps will allow you to mount your local checkout of those plugins and install them in the platform.
start the LMS with a local venv and your plugin code mounted
# use xblock-lti-consumer as an example tutor dev start lms \ -m $YOUR_PROJECT_WORKSPACE/edx-platform \ -m lms,lms-worker,cms,cms-worker:$HOME/tutor-venvs/venv-openedx/venv:/openedx/venv \ -m lms,lms-worker,cms,cms-worker:$YOUR_PROJECT_WORKSPACE/xblock-lti-consumer:/openedx/packages/xblock-lti-consumer |
install plugin as an editable requirement
tutor dev exec lms pip install -e /openedx/packages/xblock-lti-consumer |
Make a change in your locally checked out plugin repo, the platform should reload with your changes.
MFEs can be added to your development environment using the https://github.com/overhangio/tutor-mfe plugin. You can read more about Tutor plugins here: https://docs.tutor.overhang.io/plugins/intro.html .
Follow the instruction at https://github.com/overhangio/tutor-mfe to install and enable the tutor-mfe plugin. By default this plugin will allow you to run the account, gradebook, profile and learning MFEs.
Checkout the frontend repository
On you local machine install node requirements using an npm version suitable for that codebase.
Run tutor dev with --mount
tutor dev start learning \ -m learning:$YOUR_PROJECT_WORKSPACE/frontend-app-learning:/openedx/app |
Most MFE projects share the same environment variables and build tasks so the tutor-mfe plugin should be able to handle other projects if given some additional configuration. At minimum you will need the project name, port, and git url. Some projects may require additional environment variables.
open your local config
vim "$(tutor config printroot)"/config.yml |
add your new MFE (course-authoring as an example)
MFE_AUTHORING_MFE_APP: name: authoring port: 2001 repository: https://github.com/edx/frontend-app-course-authoring env: development: APP_SPECIFIC_URL: http://blah.co |
*note the MFE_
prefix, this is important for your settings to get picked up by tutor-mfe
To pick up your changes you will either need to initialize the mfe plugin. (quickstart will also do this)
tutor dev init -l mfe |
The newly added MFE can be run using the name
used in config.yml
tutor dev start authoring \ -m authoring:$YOUR_PROJECT_WORKSPACE/frontend-app-course-authoring:/openedx/app |
Most ancillary enterprise services (catalog service, license manager, etc) and MFEs (learner portal, explore catalog, etc) are not currently supported. |
Stop all devstack docker containers
devstack and tutor can live side by side but its not recommended to run both simultaneously
Install nightly tutor (see above) - be sure to have a virtualenv setup for tutor
Configure ample resources for Docker Desktop (2+ CPU, 8+ GB ram, 4 GB swap, 150+ GB disk)
extra disk space is required to create the virtualenv bindmount copy
Build the initial docker images, which we’ll need to bootstrap our bindmount virtualenv:
tutor dev dc build lms |
Extract the supplied virtualenv and move it somewhere useful/obvious:
This is required to bootstrap the docker image because nightly code and tutor code will have mismatched requirements which will cause tutor images to exit before you’re able to shell in to install them. |
tutor dev bindmount lms /openedx/venv cp -R "$(tutor config printroot)/volumes/venv" $HOME/tutor-venvs/edx-platform |
Configure local mounts for venv and code checkouts:
vim "$(tutor config printroot)/env/dev/docker-compose.override.yml" |
Use a config similar to this:
LMS git checkout in /Users/jnagro/edx-repos/edx-platform
edx-enterprise git checkout in /Users/jnagro/edx-repos/src/edx-enterprise
tutor-extracted venv (from above) in /Users/jnagro/tutor-venvs/edx-platform
version: "3.7" services: lms: volumes: - /Users/jnagro/edx-repos/edx-platform:/openedx/edx-platform - /Users/jnagro/edx-repos/src:/openedx/src - /Users/jnagro/tutor-venvs/edx-platform:/openedx/venv cms: volumes: - /Users/jnagro/edx-repos/edx-platform:/openedx/edx-platform - /Users/jnagro/edx-repos/src:/openedx/src - /Users/jnagro/tutor-venvs/edx-platform:/openedx/venv lms-worker: volumes: - /Users/jnagro/edx-repos/edx-platform:/openedx/edx-platform - /Users/jnagro/edx-repos/src:/openedx/src - /Users/jnagro/tutor-venvs/edx-platform:/openedx/venv cms-worker: volumes: - /Users/jnagro/edx-repos/edx-platform:/openedx/edx-platform - /Users/jnagro/edx-repos/src:/openedx/src - /Users/jnagro/tutor-venvs/edx-platform:/openedx/venv |
Install current dependencies:
this will use/save the mounted venv folder locally
tutor dev run lms pip install -r requirements/edx/development.txt |
Install current edx-enterprise:
tutor dev run lms pip install -e /openedx/src/edx-enterprise |
Run migrations:
tutor dev run lms ./manage.py lms migrate |
Start local development server:
tutor dev runserver lms |
Add a local development user:
tutor dev createuser --superuser --staff -p edx edx edx@example.org |
Browse to http://local.overhang.io:8000/
Tutor: Developing with Course Discovery
Make sure to run tutor dev
and not tutor local
commands since they point to different tutor configurations.
If you run into errors on initial migration, make sure you have allotted enough memory to Docker. See https://discuss.overhang.io/t/quickstart-failed-on-fresh-mac/143 for more information
If you run into port already allocated
errors when starting up CMS, check to see if you are running kubectl anywhere. It also uses port 8001 so it will cause a collision.