Skip to content

Commit

Permalink
perf: globally install node_modules
Browse files Browse the repository at this point in the history
WIP
  • Loading branch information
kdmccormick committed Dec 22, 2022
1 parent 3807862 commit 2502fe0
Show file tree
Hide file tree
Showing 2 changed files with 327 additions and 37 deletions.
28 changes: 14 additions & 14 deletions tutor/templates/build/openedx/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ ENV PATH /openedx/nodeenv/bin:/openedx/venv/bin:${PATH}
RUN pip install nodeenv==1.7.0
RUN nodeenv /openedx/nodeenv --node=16.14.0 --prebuilt

# Install nodejs requirements
# Install nodejs requirements to /openedx/node_modules
ARG NPM_REGISTRY={{ NPM_REGISTRY }}
COPY --from=code /openedx/edx-platform/package.json /openedx/edx-platform/package.json
COPY --from=code /openedx/edx-platform/package-lock.json /openedx/edx-platform/package-lock.json
WORKDIR /openedx/edx-platform
COPY --from=code /openedx/edx-platform/package.json /openedx/package.json
COPY --from=code /openedx/edx-platform/package-lock.json /openedx/package-lock.json
WORKDIR /openedx
RUN npm install --verbose --registry=$NPM_REGISTRY

###### Production image with system and python requirements
Expand All @@ -139,9 +139,9 @@ COPY --chown=app:app --from=python /opt/pyenv /opt/pyenv
COPY --chown=app:app --from=python-requirements /openedx/venv /openedx/venv
COPY --chown=app:app --from=python-requirements /openedx/requirements /openedx/requirements
COPY --chown=app:app --from=nodejs-requirements /openedx/nodeenv /openedx/nodeenv
COPY --chown=app:app --from=nodejs-requirements /openedx/edx-platform/node_modules /openedx/edx-platform/node_modules
COPY --chown=app:app --from=nodejs-requirements /openedx/node_modules /openedx/node_modules

ENV PATH /openedx/venv/bin:./node_modules/.bin:/openedx/nodeenv/bin:${PATH}
ENV PATH /openedx/venv/bin:/openedx/node_modules/.bin:/openedx/nodeenv/bin:${PATH}
ENV VIRTUAL_ENV /openedx/venv/
WORKDIR /openedx/edx-platform

Expand Down Expand Up @@ -190,15 +190,15 @@ 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 openedx-assets xmodule
RUN openedx-assets npm
RUN openedx-assets webpack --env=prod
RUN openedx-assets common
COPY --chown=app:app ./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/
RUN openedx-assets themes
RUN openedx-assets collect --settings=tutor.assets
# De-duplicate static assets with symlinks
RUN rdfind -makesymlinks true -followsymlinks true /openedx/staticfiles/

# Create a data directory, which might be used (or not)
RUN mkdir /openedx/data
Expand Down
Loading

0 comments on commit 2502fe0

Please sign in to comment.