Skip to content

Commit

Permalink
Add remote asset listing to build (#1502)
Browse files Browse the repository at this point in the history
## Motivation for the change, related issues

This PR adds a remote asset listing to minified WP builds so we can
later tell which files are expected to exist remotely and which should
be considered missing if they are not present locally.

This was originally part of request routing PRs #1417 and #1490, but
since there are some sensitive edge cases around the routing changes and
browser storage, I am breaking the build changes into their own PR so
the more sensitive changes can be reviewed more easily on their own.

## Implementation details

This PR updates the minified WP build process to generate a
wordpress-remote-asset-paths file containing the WP-relative paths of
all assets not included in the minified build. That way, we have the
necessary information to judge whether a requested resource can be
requested from playground.wordpress.net when it does not exist locally.

We include this listing with new minified WP builds.

In case browser storage has already cached a minified WP build without
this listing, we also make it available remotely so it can be retrieved
as needed.

## Testing Instructions (or ideally a Blueprint)

- CI tests
  • Loading branch information
brandonpayton authored Jun 10, 2024
1 parent 3176a19 commit 17f166c
Show file tree
Hide file tree
Showing 306 changed files with 106,044 additions and 70,220 deletions.
13 changes: 13 additions & 0 deletions packages/playground/wordpress-builds/build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ RUN cp -r wordpress wordpress-static && \
# Remove all empty directories
find . -type d -empty -delete

# Remove the sqlite database integration from the static files
RUN rm -rf wordpress-static/wp-content/mu-plugins

# List assets that will be available to remotely so Playground can judge whether
# to request a remote asset or delegate the request for a missing file to PHP.
RUN find wordpress-static -type f | sed 's#^wordpress-static/##'> wordpress-remote-asset-paths

# Make the remote asset listing available remotely so it can be downloaded
# directly in cases where an older minified WordPress build without this file
# has been saved to browser storage.
RUN cp wordpress-remote-asset-paths wordpress-static/

# Move the static files to the final output directory
RUN mkdir /root/output/$OUT_FILENAME
RUN mv wordpress-static/* /root/output/$OUT_FILENAME/
Expand Down Expand Up @@ -122,6 +134,7 @@ RUN cd wordpress && \

# Build the final wp.zip file
RUN mv wordpress /wordpress && \
cp wordpress-remote-asset-paths /wordpress/ && \
cd /wordpress && \
zip /root/output/$OUT_FILENAME.zip -r .

Loading

0 comments on commit 17f166c

Please sign in to comment.