Skip to content

Commit

Permalink
build: switch to new edx-platform asset build
Browse files Browse the repository at this point in the history
TODO:
* Test dev & prod builds one last time
* Test watching again

Part of: openedx/edx-platform#31895
  • Loading branch information
kdmccormick committed Mar 18, 2024
1 parent eb69d3e commit 2b08425
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 241 deletions.
Empty file added docs/__init__.py
Empty file.
4 changes: 2 additions & 2 deletions docs/dev.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ To open a python shell in the LMS or CMS, run::

You can then import edx-platform and django modules and execute python code.

To rebuild assets, you can use the ``openedx-assets`` command that ships with Tutor::
To rebuild assets, you can run the ``build-dev`` NPM script that comes with edx-plaform::

tutor dev run lms openedx-assets build --env=dev
tutor dev run lms npm run build-dev


.. _specialized for developer usage:
Expand Down
31 changes: 12 additions & 19 deletions tutor/templates/build/openedx/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -199,26 +199,19 @@ ENV PATH /openedx/bin:${PATH}

{{ patch("openedx-dockerfile-pre-assets") }}

# Collect production assets. By default, only assets from the default theme
# Build & collect production assets. By default, only assets from the default theme
# will be processed. This makes the docker image lighter and faster to build.
# Only the custom themes added to /openedx/themes will be compiled.
# Here, we don't run "paver update_assets" which is slow, compiles all themes
# and requires a complex settings file. Instead, we decompose the commands
# and run each one individually to collect the production static assets to
# /openedx/staticfiles.
ENV NO_PYTHON_UNINSTALL 1
ENV NO_PREREQ_INSTALL 1
# We need to rely on a separate openedx-assets command to accelerate asset processing.
# For instance, we don't want to run all steps of asset collection every time the theme
# is modified.
RUN openedx-assets xmodule \
&& openedx-assets npm \
&& openedx-assets webpack --env=prod \
&& openedx-assets common
RUN npm run compile-sass -- --skip-themes
RUN npm run webpack

# Now that the default theme is built, build any custom themes in /openedx/themes.
COPY --chown=app:app ./themes/ /openedx/themes/
RUN openedx-assets themes \
&& openedx-assets collect --settings=tutor.assets \
# De-duplicate static assets with symlinks
RUN npm run compile-sass -- --theme-dir /openedx/themes

# and finally, collect assets for the production image.
RUN ./manage.py lms collectstatic --noinput && \
./manage.py cms collectstatic --noinput && \
# De-duplicate static assets with symlinks \
&& rdfind -makesymlinks true -followsymlinks true /openedx/staticfiles/

# Create a data directory, which might be used (or not)
Expand Down Expand Up @@ -272,7 +265,7 @@ ENV PYTHONBREAKPOINT=ipdb.set_trace
# static assets, then production assets will be served instead.
RUN rm -r /openedx/staticfiles && \
mkdir /openedx/staticfiles && \
openedx-assets webpack --env=dev
npm run build-dev

{{ patch("openedx-dev-dockerfile-post-python-requirements") }}

Expand Down
218 changes: 0 additions & 218 deletions tutor/templates/build/openedx/bin/openedx-assets

This file was deleted.

2 changes: 1 addition & 1 deletion tutor/templates/dev/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ services:
# Additional service for watching theme changes
watchthemes:
<<: *openedx-service
command: openedx-assets watch-themes --env dev
command: npm run watch-sass
restart: unless-stopped

{% if RUN_ELASTICSEARCH and is_docker_rootless() %}
Expand Down
2 changes: 1 addition & 1 deletion tutor/templates/jobs/init/mounted-edx-platform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pip install -e .
npm clean-install

# Regenerate static assets.
openedx-assets build --env=dev
npm run build-dev

set -x
echo "Done setting up bind-mounted edx-platform."

0 comments on commit 2b08425

Please sign in to comment.