doriansmiley / codestrap

0 stars 0 forks source link

Create static website generator in fly.io #4

Open doriansmiley opened 2 years ago

doriansmiley commented 2 years ago
  1. Deploy the website as a fly app
  2. Proxy requests through the proxy app. Setup a http cache using this example 1. Check this cache before proceeding.
  3. Use the global Fly Redis cluster to store the hashed path as a key
  4. The proxy should check for this key using the incoming URL by hashing it and doing a get
    1. If not found
      1. proxy pass to the origin server
      2. The origin server should render the page, spit the rendered file to the output directory, and put the output path into reds, then return the resulting HTML
    2. If found
      1. get the URL of the associated static file
      2. proxy pass to that URL caching the output
      3. figure out how to test the cache is working correctly on the Fly CDN
doriansmiley commented 2 years ago

I ran into an issue starting my docker container in fly. I opened an issue here.

I think I am going to have to modify my setup for fly. Note from the ticket is below.

I think what is going on here is my setup starts puppeteer with Chrome using CMD ["google-chrome-stable"]. This enables full media support. However your example app uses:

const browser = await puppeteer.launch(
      {
        executablePath: process.env.CHROME_BIN,

Does fly.io provide a Chrome bin? If so I can modify my setup for fly. However, it would be cool to be able to use the best practice container provided by Google.

doriansmiley commented 2 years ago

Useful links:

  1. Connecting to Redis from NGINX lau script
  2. Background on Redis in fly
  3. Setting up a HTML/Image cache for rendered pages with NGINX
  4. Building an imaging service
  5. Connecting to Redis from a node application
  6. Puppeteer Launch Options
  7. MD5 Checksums for NGINX