Hi tutor community.
Problem
Theme installation process, as documented on the indigo repo, requires building a new openedx docker image and restarting the platform. I need to be able to install, modify and customize a theme without building an image, avoiding the build time and downtime of the platform. The goal being better development experience and rather seamless theme change in a software as a service scenario.
Possible solution
As I inspected the theme installation process, I reckon I could use a docker volume mounted at the themes directory to solve this problem. The steps I took in detail are as follows:
- Looking at the Dockerfile at
~/.local/share/tutor/env/build/openedx/Dockerfile
, the theme installation steps are:
COPY ./themes/ /openedx/themes/
RUN openedx-assets themes \
&& openedx-assets collect --settings=tutor.assets \
# De-duplicate static assets with symlinks
&& rdfind -makesymlinks true -followsymlinks true /openedx/staticfiles/
I modified the docker-compose at ~/.local/share/tutor/env/local/docker-compose.yml
in order to have the lms service have volume a mounted at /openedx/themes
:
lms:
image: docker.io/overhangio/openedx:12.0.2
environment:
SERVICE_VARIANT: lms
UWSGI_WORKERS: 2
SETTINGS: ${TUTOR_EDX_PLATFORM_SETTINGS:-tutor.production}
restart: unless-stopped
volumes:
- ../apps/openedx/settings/lms/:/openedx/edx-platform/lms/envs/tutor/:ro
- ../apps/openedx/settings/cms/:/openedx/edx-platform/cms/envs/tutor/:ro
- ../apps/openedx/config/:/openedx/config/:ro
- ../../data/lms:/openedx/data
- ../../data/openedx-media:/openedx/media
# My theme volume
- ../themes_volume:/openedx/themes
depends_on:
- mysql
- elasticsearch
- forum
- mongodb
- redis
- smtp
- Having access to the theme directory on the lms container, I copied the rendered theme to the volume and ran the steps from Dockerfile manually:
$ tutor config render --extra-config ~/indigo/config.yml ~/indigo/theme/ "$(tutor config printroot)/env/build/openedx/themes/indigo"
$ cp -r ~/.local/share/tutor/env/build/openedx/themes/indigo ~/.local/share/tutor/env/themes_volume
Now that the rendered theme is in place:
$ tutor local run lms openedx-assets themes
$ tutor local run lms openedx-assets collect
$ tutor local run lms rdfind -makesymlinks true -followsymlinks true /openedx/staticfiles/
Which are run successfully.
- Finally, set the theme using the
settheme
command:
$ tutor local settheme indigo $(tutor config printvalue LMS_HOST) $(tutor config printvalue CMS_HOST)
Result
The result is flaky. I executed the process several times. I got the theme deployed successfully at times, but mostly the process resulted in a broken theme deployment:
I’d appreciate any ideas or help from anyone who’s gone down this road.
Update: I’m aware that I’m running the tutor local run lms openedx-assets collect
without the --settings=tutor.assets
. The command uses tutor.production
Django settings, according to it’s output. The container does not have access to the tutor.assets
module, but I doubt that this would be the problem because the command collects the static files successfully.