mirror of
https://github.com/ChristianLight/tutor.git
synced 2025-01-07 16:04:02 +00:00
Fix assets generation in development
webpack requires the NODE_ENV environment variable which is incorrectly set "paver update_assets" in development mode. To avoid this issue, we split update_assets into its subparts.
This commit is contained in:
parent
080341a32e
commit
274432436f
44
Makefile
44
Makefile
@ -1,4 +1,4 @@
|
|||||||
.PHONY: all android configure build update migrate assets run daemonize
|
.PHONY: all android configure build update migrate run
|
||||||
.DEFAULT_GOAL := help
|
.DEFAULT_GOAL := help
|
||||||
|
|
||||||
|
|
||||||
@ -95,11 +95,43 @@ reindex-courses: ## Refresh course index so they can be found in the LMS search
|
|||||||
|
|
||||||
##################### Static assets
|
##################### Static assets
|
||||||
|
|
||||||
assets: assets-lms assets-cms ## Collect static assets for the LMS and the CMS
|
# To collect assets we don't rely on the "paver update_assets" command because
|
||||||
assets-lms: ## Collect static assets for the LMS
|
# webpack collection incorrectly sets the NODE_ENV variable when using custom
|
||||||
$(DOCKER_COMPOSE_RUN_OPENEDX) -e NO_PREREQ_INSTALL=True lms paver update_assets lms --settings=$(EDX_PLATFORM_SETTINGS)
|
# settings. Thus, each step must be performed separately. This should be fixed
|
||||||
assets-cms: ## Collect static assets for the CMS
|
# in the next edx-platform release thanks to https://github.com/edx/edx-platform/pull/18430/
|
||||||
$(DOCKER_COMPOSE_RUN_OPENEDX) -e NO_PREREQ_INSTALL=True cms paver update_assets cms --settings=$(EDX_PLATFORM_SETTINGS)
|
#assets-lms: ## Collect static assets for the LMS
|
||||||
|
#$(DOCKER_COMPOSE_RUN_OPENEDX) lms -e NO_PREREQ_INSTALL=True lms paver update_assets lms --settings=$(EDX_PLATFORM_SETTINGS)
|
||||||
|
#assets-cms: ## Collect static assets for the CMS
|
||||||
|
#$(DOCKER_COMPOSE_RUN_OPENEDX) cms -e NO_PREREQ_INSTALL=True cms paver update_assets cms --settings=$(EDX_PLATFORM_SETTINGS)
|
||||||
|
|
||||||
|
assets: assets-lms assets-cms ## Generate production-ready static assets
|
||||||
|
assets-development: assets-development-lms assets-development-cms ## Generate static assets for local development
|
||||||
|
|
||||||
|
assets-lms:
|
||||||
|
$(DOCKER_COMPOSE_RUN_OPENEDX) lms bash -c \
|
||||||
|
"NODE_ENV=production ./node_modules/.bin/webpack --config=webpack.prod.config.js \
|
||||||
|
&& ./manage.py lms --settings=$(EDX_PLATFORM_SETTINGS) compile_sass lms \
|
||||||
|
&& python -c \"import pavelib.assets; pavelib.assets.collect_assets(['lms'], '$(EDX_PLATFORM_SETTINGS)')\""
|
||||||
|
assets-cms:
|
||||||
|
$(DOCKER_COMPOSE_RUN_OPENEDX) cms bash -c \
|
||||||
|
"NODE_ENV=production ./node_modules/.bin/webpack --config=webpack.prod.config.js \
|
||||||
|
&& ./manage.py cms --settings=$(EDX_PLATFORM_SETTINGS) compile_sass studio \
|
||||||
|
&& python -c \"import pavelib.assets; pavelib.assets.collect_assets(['studio'], '$(EDX_PLATFORM_SETTINGS)')\""
|
||||||
|
assets-development-lms:
|
||||||
|
$(DOCKER_COMPOSE_RUN_OPENEDX) lms bash -c \
|
||||||
|
"xmodule_assets common/static/xmodule \
|
||||||
|
&& python -c \"import pavelib.assets; pavelib.assets.process_npm_assets()\"
|
||||||
|
&& NODE_ENV=development ./node_modules/.bin/webpack --config=webpack.dev.config.js \
|
||||||
|
&& ./manage.py lms --settings=$(EDX_PLATFORM_SETTINGS) compile_sass lms \
|
||||||
|
&& python -c \"import pavelib.assets; pavelib.assets.collect_assets(['lms'], '$(EDX_PLATFORM_SETTINGS)')\""
|
||||||
|
assets-development-cms:
|
||||||
|
$(DOCKER_COMPOSE_RUN_OPENEDX) cms bash -c \
|
||||||
|
"xmodule_assets common/static/xmodule \
|
||||||
|
&& python -c \"import pavelib.assets; pavelib.assets.process_npm_assets()\"
|
||||||
|
&& NODE_ENV=development ./node_modules/.bin/webpack --config=webpack.dev.config.js \
|
||||||
|
&& ./manage.py cms --settings=$(EDX_PLATFORM_SETTINGS) compile_sass studio \
|
||||||
|
&& python -c \"import pavelib.assets; pavelib.assets.collect_assets(['studio'], '$(EDX_PLATFORM_SETTINGS)')\""
|
||||||
|
|
||||||
|
|
||||||
##################### Information
|
##################### Information
|
||||||
|
|
||||||
|
@ -213,10 +213,13 @@ Then open an LMS shell:
|
|||||||
|
|
||||||
make lms
|
make lms
|
||||||
|
|
||||||
You can then collect assets and run a local web server, as usual:
|
You can then run a local web server, as usual:
|
||||||
|
|
||||||
paver update_assets lms --settings=universal.development
|
paver update_assets lms --settings=universal.development
|
||||||
./manage.py lms runserver 0.0.0.0:8000
|
|
||||||
|
Note that assets collection is made more difficult by the fact that development settings are [incorrectly loaded in hawthorn](https://github.com/edx/edx-platform/pull/18430/files). This should be fixed in the next release. Meanwhile, do not run `paver update_assets` while in development mode. Instead, run on the host:
|
||||||
|
|
||||||
|
make assets-development
|
||||||
|
|
||||||
### Custom devstack
|
### Custom devstack
|
||||||
|
|
||||||
|
@ -36,6 +36,11 @@ RUN pip install --src ../venv/src -r requirements/edx/development.txt
|
|||||||
RUN npm install
|
RUN npm install
|
||||||
ENV PATH ./node_modules/.bin:${PATH}
|
ENV PATH ./node_modules/.bin:${PATH}
|
||||||
|
|
||||||
|
# Some parts of assets collection can be run without relying on specific
|
||||||
|
# settings, nor mounting the staticfiles/ folder
|
||||||
|
RUN xmodule_assets common/static/xmodule
|
||||||
|
RUN python -c "import pavelib.assets; pavelib.assets.process_npm_assets()"
|
||||||
|
|
||||||
# Link configuration files to common /openedx/config folder, which should later
|
# Link configuration files to common /openedx/config folder, which should later
|
||||||
# be mounted as a volume. Note that this image will not be functional until
|
# be mounted as a volume. Note that this image will not be functional until
|
||||||
# config files have been mounted inside the container
|
# config files have been mounted inside the container
|
||||||
@ -63,6 +68,8 @@ COPY ./bin/docker-entrypoint.sh /usr/local/bin/
|
|||||||
# service variant is "lms" or "cms"
|
# service variant is "lms" or "cms"
|
||||||
ENV SERVICE_VARIANT lms
|
ENV SERVICE_VARIANT lms
|
||||||
ENV SETTINGS universal.production
|
ENV SETTINGS universal.production
|
||||||
|
ENV STATIC_ROOT_LMS /openedx/data/staticfiles
|
||||||
|
ENV STATIC_ROOT_CMS /openedx/data/staticfiles/studio
|
||||||
|
|
||||||
# Entrypoint will fix permissiosn of all files and run commands as openedx
|
# Entrypoint will fix permissiosn of all files and run commands as openedx
|
||||||
ENTRYPOINT ["docker-entrypoint.sh"]
|
ENTRYPOINT ["docker-entrypoint.sh"]
|
||||||
|
Loading…
Reference in New Issue
Block a user