Skip to content

Commit

Permalink
temp: revert: attempt at copying assets from container
Browse files Browse the repository at this point in the history
This reverts commit 59088a78747e189971877319a7ff9a6d8f18a21a.
  • Loading branch information
kdmccormick committed Aug 2, 2023
1 parent 1217809 commit ab2fe22
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 28 deletions.
17 changes: 0 additions & 17 deletions tutor/commands/compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,23 +114,6 @@ def launch(
click.echo(fmt.title("Docker image updates"))
context.invoke(dc_command, command="pull")

# TODO: Find a way to do this that doesn't hard-code understanding of lms and the edx-platform repo?
asset_targets = [
"node_modules",
"lms/static/css",
"lms/static/certificates/css",
"cms/static/css",
"common/static/bundles",
]
if not run_for_prod:
if "edx-platform" in bindmount.get_mounts(config):
_, host_path, container_path = bindmount.parse_mount("edx-platform")[0]
click.echo(fmt.title("Copying generated assets from image to bind-mounted repo."))
for target in asset_targets:
context.invoke(f"echo bash -c 'if [[ -d {target} ]] ; then mv {target} {target.bak} ; fi'")
context.invoke(dc_command, command="cp", args=["--dry-run", f"lms:{host_path}/{target}", f"{host_path}/{target}"])
return

click.echo(fmt.title("Starting the platform in detached mode"))
context.invoke(start, detach=True)

Expand Down
26 changes: 17 additions & 9 deletions tutor/templates/build/openedx/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ FROM minimal as code
###### Checkout edx-platform code
ARG EDX_PLATFORM_REPOSITORY={{ EDX_PLATFORM_REPOSITORY }}
ARG EDX_PLATFORM_VERSION={{ EDX_PLATFORM_VERSION }}
RUN echo break cache 200
RUN mkdir -p /openedx/edx-platform && \
git clone $EDX_PLATFORM_REPOSITORY --branch $EDX_PLATFORM_VERSION --depth 1 /openedx/edx-platform
WORKDIR /openedx/edx-platform
Expand Down Expand Up @@ -425,10 +426,10 @@ FROM application as production

# Copy in and collect production static assets.
COPY --chown=app:app --from=bundles-production /openedx/staticfiles /openedx/staticfiles
COPY --chown=app:app --from=bundles-production /openedx/edx-platform/common/static/bundles common/static/bundles
COPY --chown=app:app --from=css-production /openedx/edx-platform/lms/static/css lms/static/css
COPY --chown=app:app --from=css-production /openedx/edx-platform/lms/static/certificates/css ms/static/certificates/css
COPY --chown=app:app --from=css-production /openedx/edx-platform/cms/static/css cms/static/css
COPY --chown=app:app --from=bundles-production /openedx/edx-platform/common/static/bundles /openedx/edx-platform/common/static/bundles
COPY --chown=app:app --from=css-production /openedx/edx-platform/lms/static/css /openedx/edx-platform/lms/static/css
COPY --chown=app:app --from=css-production /openedx/edx-platform/lms/static/certificates/css /openedx/edx-platform/lms/static/certificates/css
COPY --chown=app:app --from=css-production /openedx/edx-platform/cms/static/css /openedx/edx-platform/cms/static/css
RUN ./manage.py lms collectstatic --noinput --settings=tutor.assets
RUN ./manage.py cms collectstatic --noinput --settings=tutor.assets

Expand Down Expand Up @@ -475,13 +476,20 @@ RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared \
ENV PYTHONBREAKPOINT=ipdb.set_trace

# Copy in development static assets.
# In development mode, edx-platform expects the files to be in the repo, and pointed to by webpack-stats.json.
# In development mode, edx-platform expects the files to be in the repo, and pointed to by webpack-stats.json...
COPY --chown=app:app --from=bundles-development /openedx/staticfiles/webpack-stats.json /openedx/staticfiles/webpack-stats.json
COPY --chown=app:app --from=bundles-development /openedx/staticfiles/studio/webpack-stats.json /openedx/staticfiles/studio/webpack-stats.json
COPY --chown=app:app --from=bundles-development /openedx/edx-platform/common/static/bundles common/static/bundles
COPY --chown=app:app --from=css-development /openedx/edx-platform/lms/static/css lms/static/css
COPY --chown=app:app --from=css-development /openedx/edx-platform/lms/static/certificates/css lms/static/certificates/css
COPY --chown=app:app --from=css-development /openedx/edx-platform/cms/static/css cms/static/css

# ...however, we instead copy the files into the /openedx/devcache directory; otherwise, bind-mounting edx-platform
# would clobber them and force the user to rebuild assets.
COPY --chown=app:app --from=bundles-development /openedx/edx-platform/common/static/bundles /openedx/devcache/common/static/bundles
COPY --chown=app:app --from=css-development /openedx/edx-platform/lms/static/css /openedx/devcache/lms/static/css
COPY --chown=app:app --from=css-development /openedx/edx-platform/lms/static/certificates/css /openedx/devcache/lms/static/certificates/css
COPY --chown=app:app --from=css-development /openedx/edx-platform/cms/static/css /openedx/devcache/cms/static/css
RUN mv node_modules /openedx/devcache/node_modules

# Create links for static dirs from edx-platform to devcache.
RUN link-static-to-devcache

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

Expand Down
12 changes: 12 additions & 0 deletions tutor/templates/build/openedx/bin/link-static-to-devcache
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

cd /openedx/edx-platform

for path in node_modules common/static/bundles lms/static/css lms/static/certificates/css cms/static/css ; do
if [[ -L "$path" ]] ; then
rm -rf "$path"
elif [[ -e "$path" ]] ; then
mv "$path" "${path}.bak"
fi
ln -s "/openedx/devcache/$path" "$path"
done
7 changes: 5 additions & 2 deletions tutor/templates/jobs/init/mounted-edx-platform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ set -x # Echo out executed lines
# Regenerate Open_edX.egg-info
pip install -e .

# Regenerate node_copies
npm postinstall
# Regenerate node_modules
npm clean-install

# Link to static assets in dev image.
link-static-to-devcache

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

0 comments on commit ab2fe22

Please sign in to comment.