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
* Print warning in openedx-assets
* Add REMOVE-AFTER-VXX comments
* Update docs

Part of: openedx/edx-platform#31895
  • Loading branch information
kdmccormick committed Oct 17, 2023
1 parent 551c631 commit ff320c6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 21 deletions.
31 changes: 12 additions & 19 deletions tutor/templates/build/openedx/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -206,26 +206,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 @@ -273,7 +266,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
4 changes: 4 additions & 0 deletions tutor/templates/build/openedx/bin/openedx-assets
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#! /usr/bin/env python

# This script has been replaced by `npm run build`, et al, in edx-platform.
# REMOVE-AFTER-V17

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

{{ patch("local-docker-compose-dev-services")|indent(2) }}
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 ff320c6

Please sign in to comment.