wissel.net

Usability - Productivity - Business - The web - Singapore & Twins

By Date: June 2023

Docker, nginx, SPA and brotli compression


Contemporary web development separates front-end and back-end, resulting in the front-end being a few static files. Besides setting long cache headers, pre-compression is one way to speed up delivery

Setting the stage

  • we have a NodeJS project that outputs our SPA in /usr/dist directory. Highly recommended here: VITE. Works for multi-page applications too.
  • We target only modern browsers that understand brotli (Sorry not IE). Legacy will have to deal with uncompressed files
  • We want to go light on CPU, so we compress at build time, not runtime

Things to know

  • When nginx is configured for brotli and the file index.html gets requested, the file index.html.br gets served if present and the browser indicated (what it does by default) that it can accept br
  • There are tons of information about the need to compile nginx due to the lack of brotli support out of the box. That's not necessary (see below)
  • brotli is both OpenSource and the open standard RFC 7932
  • brotli currently lacks gzip's -r flag, so some bash magic is needed

Moving parts

  • DockerFile
  • nginx configuration

The Dockerfile will handle the brotli generation


Read more

Posted by on 24 June 2023 | Comments (0) | categories: Docker nginx WebDevelopment

Deploy a TypeScript app using Docker


An application developed in TypeScript actually runs as JavaScript application. When deploying into a Docker image, wwe want to keep it small, here's how.

Docker with a side of Docker

Deployment has a few steps:

  • Compile to JavaScript
  • Successfully run all test
  • Run code quality (e.g. Sonar)
  • Finally package all up into the smallest of containers

Using last weeks example these are the moving parts.


Read more

Posted by on 04 June 2023 | Comments (0) | categories: Docker JavaScript TypeScript