This repository holds all the tools necessary to interact with the Interflux CDN.
On the CDN we store all images, videos, PDFs served on our multiple websites and email signatures. This CDN helps us seperate concerns. Our rapidly changing Ember (Javascript) front end apps and Rails (Ruby) back needn't be concerned with these highly cacheable static resources.
We use:
- Digital Ocean's S3-like CDN.
s3cmdcommands to interact with the CDN.cwebpcommands for converting WEBPs.convertcommands for converting PNGs and JPGs.- Gulp task runner for serving on localhost:9000.
Set up repo:
git clone git@github.com:interflux-electronics/interflux-cdn.git
cd interflux-cdn
nvm install
npm install
npm run devInstall and configure s3cmd for interacting with the CDN:
brew install s3cmd
s3cmd --configureThe sync files DOWN from the CDN to public/:
bin/sync-down.shTo sync file UP from public/ to CDN:
bin/sync-up.shIMPORTANT: Syncing treats either your local or the CDN as source-of-truth and deletes all files that
are not found in the source of truth. Syncing up to the CDN from an empty public/ folder would
literally 🔥 wipe the entire CDN 🔥.
Serve all files in public/ locally (for development):
npm run devThen http://localhost:9000/some.png is equivalent to https://cdn.interflux.com/some.png
The other frontends pull images from this CDN.
Scan for PNGs and convert them to into JPGs and WEBPs, each in 14 sizes:
bin/convert.shConvert 1 PNG to a JPG and WEBP of the same size + base64 20x smaller (for loading states):
bin/convert-png.sh public/images/public/hero-circuit-board-3/hero-circuit-boards-3@2400x640.pngChemistry + Metallurgy + Electronics