Created
February 24, 2015 18:37
-
-
Save bradvogel/c2e1e6e26522216f6bdb to your computer and use it in GitHub Desktop.
Uploading to a CDN with Demeteorizer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm install -g modulus | |
# Redirect to CDN. | |
echo "WebAppInternals.setBundledJsCssPrefix('https://d14ym0a63kner.cloudfront.net/${GITSHA}');" > server/cdn.js | |
# This script is a hack to upload static assets generated by the "modulus deploy" command to our | |
# CDN, Amazon Cloudfront. This script should be run in the background prior to "modulus deploy" | |
# being called. It watches for a file named ./demeteorized/programs/web.browser/program.json to be | |
# created, then it uses gulp to upload assets to S3. | |
( | |
# Seatbelts so it doesn't run forever. | |
((end_time=${SECONDS}+600)) | |
while ((${SECONDS} < ${end_time})) | |
do | |
if [[ -f .demeteorized/programs/web.browser/program.json ]] | |
then | |
echo "Found build folder. Saving a copy to ./${GITSHA}." | |
cp -R .demeteorized/programs/web.browser private/build/${GITSHA} | |
# Upload static assets. | |
cd private/build/ | |
npm install | |
npm install -g gulp | |
gulp upload --directory=${GITSHA} | |
rm -rf ${GITSHA} | |
echo "DONE uploading static assets." | |
exit 0 | |
fi | |
sleep 1 # Run every second. | |
done | |
echo "Didn't find build folder after a minute. Did something fail?" | |
)& | |
modulus deploy ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment