diff --git a/tutor/templates/build/openedx/bin/pip-install-mounted b/tutor/templates/build/openedx/bin/pip-install-mounted new file mode 100755 index 0000000000..f02f7bc374 --- /dev/null +++ b/tutor/templates/build/openedx/bin/pip-install-mounted @@ -0,0 +1,21 @@ +#!/bin/sh +# Whenever edx-platform or installable packages (e.g., xblocks) are mounted, +# during the image build, they are copied over to container and installed. This +# results in egg_info generation for the mounted directories. However, the +# egg_info is not carried over to host. When the containers are launched, the +# host directories without egg_info are mounted on runtime and disappear from +# pip list. To fix this, we `pip install` edx-platform and every mounted +# package ("/mnt/*") again, re-generating the egg-infos. This script is called +# during LMS initialization, and can also be called separately by users. + +set -eu +set -x # Echo out executed lines + +for mounted_dir in /openedx/edx-platform /mnt/*; do + if [ -f $mounted_dir/setup.py ] && ! ls $mounted_dir/*.egg-info >/dev/null 2>&1 ; then + echo "Unable to locate egg-info in $mounted_dir -- generating now." + pip install -e $mounted_dir + fi +done + +set +x diff --git a/tutor/templates/jobs/init/mounted-directories.sh b/tutor/templates/jobs/init/mounted-directories.sh index c3343c69f3..07b626c553 100644 --- a/tutor/templates/jobs/init/mounted-directories.sh +++ b/tutor/templates/jobs/init/mounted-directories.sh @@ -1,29 +1,15 @@ -# The initialization job contains various re-install operations needed to be done -# on mounted directories (edx-platform, /mnt/*xblock, /mnt/) +# The initialization job contains various re-install and asset-symlinking +# operations needed to be done on mounted directories (edx-platform, +# /mnt/*xblock, /mnt/) echo "Performing additional setup for bind-mounted directories." set -x # Echo out executed lines -cd /openedx/edx-platform || exit 1 +cd /openedx/edx-platform || exit 1 # Fail early if edx-platform is missing -# Whenever edx-platform or installable packages (e.g., xblocks) are mounted, -# during the image build, they are copied over to container and installed. This -# results in egg_info generation for the mounted directories. However, the -# egg_info is not carried over to host. When the containers are launched, the -# host directories without egg_info are mounted on runtime and disappear from -# pip list. To fix this, we `pip install` edx-platform (".") and every mounted -# package ("./mnt/*") again, re-generating the egg-infos. -for mounted_dir in . /mnt/*; do - if [ -f $mounted_dir/setup.py ] && ! ls $mounted_dir/*.egg-info >/dev/null 2>&1 ; then - echo "Unable to locate egg-info in $mounted_dir -- generating now." - pip install -e $mounted_dir - fi -done +pip-install-mounted -# The same problem exists for edx-platform's compiled frontend assets, but recompiling -# them is very slow. So, instead of re-compiling, we create symlinks to an alternate -# directory in which we expect them to have been cached (/openedx/assets). ln-assets /openedx/assets /openedx/edx-platform -set -x +set +x echo "Done setting up bind-mounted directories."