espresso
The web server behind chromabits.com. Espresso is built to serve static websites in a container cluster.
Object Storage
On boot, Espresso downloads the site its serving from a bucket on a object storage backend (S3 compatible). While running, Espresso will check for updates on the site bundle and download them as necessary.
Espresso expects the whole site to be stored in a single Gzipped TAR archive
named bundle.tar.gz
at the root of the bucket.
Requirements
- S3-compatible: The object storage service should expose an S3-compatible interface. Tested backends are Ceph RGW and Minio.
- ETag Support: Espresso uses ETags to detect changes to the site bundle. The backend service should support these.
Configuration
Espresso supports the following environment variables:
-
SITE_STAGE
(Optional): One ofproduction
,staging
, ordevelopment
(Defaults todevelopment
). This specifies which set of configurations to use as part of thekawaii
package. -
SITE_DOMAIN
: Domain the site will be served from. This will be used to redirect the user if a different domain is used (Defaults tochromabits.com
). -
SITE_404_ROUTE
: Route to redirect a user to if the path requested is not found (Defaults to/404
). -
MINIO_ACCESS_KEY
: Access key for the S3-compatible storage backend. -
MINIO_SECRET_KEY
: Secret key for the S3-compatible storage backend. -
OBJECT_STORAGE_ENDPOINT
: Endpoint to the S3-compatible storage backend. -
BUCKET_NAME
: The name of the bucket where the site bundle will be stored in.
Stages
- Development: Listens on port 9090 and has a minimal set of configurations and middleware enabled.
- Staging: Listens on port 8080 and has a set of configuration closer to the production stage. Enables security middlewares (CSP, Force HTTPS), as well as, GZIP compression and index-less URLs.
- Production: Listens on port 80. Same configuration as the staging stage, but with the addition of HSTS.
Customization
While Espresso was built specifically for chromabits.com, it is able to serve other static sites as long as their requirements are simple.
One of the main limitations you may encounter is the default set of CSP policies. These are not configurable over environment variables and require the server to be recompiled.
Development
stack build --copy-bins
to build the server.