Open edX development
In addition to running Open edX in production, Tutor can be used for local development of Open edX. This means that it is possible to hack on Open edX without setting up a Virtual Machine. Essentially, this replaces the devstack provided by edX.
For detailed explanations on how to work on edx-platform and its dependencies, see the Working on edx-platform as a developer tutorial.
First-time setup
Firstly, either install Tutor (for development against the named releases of Open edX) or install Tutor Nightly (for development against Open edX’s master branches).
Then, optionally, tell Tutor to use a local fork of edx-platform:
tutor mounts add ./edx-platform
Then, launch the developer platform setup process:
tutor images build openedx-dev
tutor dev launch
This will perform several tasks. It will:
build the “openedx-dev” Docker image, which is based on the “openedx” production image but is specialized for developer usage (eventually with your fork),
stop any existing locally-running Tutor containers,
disable HTTPS,
set
LMS_HOST
to local.edly.io (a convenience domain that simply points at 127.0.0.1),prompt for a platform details (with suitable defaults),
start LMS, CMS, supporting services, and any plugged-in services,
ensure databases are created and migrated, and
run service initialization scripts, such as service user creation and Waffle configuration.
Additionally, when a local clone of edx-platform is bind-mounted, it will:
re-run setup.py,
clean-reinstall Node modules, and
regenerate static assets.
Once setup is complete, the platform will be running in the background:
LMS will be accessible at http://local.edly.io:8000.
CMS will be accessible at http://studio.local.edly.io:8001.
Plugged-in services should be accessible at their documented URLs.
Now, use the tutor dev ...
command-line interface to manage the development environment. Some common commands are described below.
Note
If you’ve added your edx-platform to the bind-mounted folders, you can remove at any time by running:
tutor mounts remove ./edx-platform
At any time, check your configuration by running:
tutor mounts list
Read more about bind-mounts below.
Stopping the platform
To bring down the platform’s containers, simply run:
tutor dev stop
Starting the platform back up
Once first-time setup has been performed with launch
, the platform can be started going forward with the lighter-weight start -d
command, which brings up containers detached (that is: in the background), but does not perform any initialization tasks:
tutor dev start -d
Or, to start with platform with containers attached (that is: in the foreground, the current terminal), omit the -d
flag:
tutor dev start
When running containers attached, stop the platform with Ctrl+c
, or switch to detached mode using Ctrl+z
.
Finally, the platform can also be started back up with launch
. It will take longer than start
, but it will ensure that config is applied, databases are provisioned & migrated, plugins are fully initialized, and (if applicable) the bind-mounted edx-platform is set up. Notably, launch
is idempotent, so it is always safe to run it again without risk to data. Including the --pullimages
flag will also ensure that container images are up-to-date:
tutor dev launch --pullimages
Running arbitrary commands
To run any command inside one of the containers, run tutor dev run [OPTIONS] SERVICE [COMMAND] [ARGS]...
. For instance, to open a bash shell in the LMS or CMS containers:
tutor dev run lms bash
tutor dev run cms bash
To open a python shell in the LMS or CMS, run:
tutor dev run lms ./manage.py lms shell
tutor dev run cms ./manage.py cms shell
You can then import edx-platform and django modules and execute python code.
To rebuild assets, you can run the build-dev
NPM script that comes with edx-platform:
tutor dev run lms npm run build-dev
Rebuilding the openedx-dev image
The openedx-dev
Docker image is based on the same openedx
image used by tutor local ...
to run LMS and CMS. However, it has a few differences to make it more convenient for developers:
The user that runs inside the container has the same UID as the user on the host, to avoid permission problems inside mounted volumes (and in particular in the edx-platform repository).
Additional Python and system requirements are installed for convenient debugging: ipython, ipdb, vim, telnet.
The edx-platform development requirements are installed.
If you are using a custom openedx
image, then you will need to rebuild openedx-dev
every time you modify openedx
. To so, run:
tutor images build openedx-dev
Alternatively, the image will be automatically rebuilt every time you run:
tutor dev launch