Utilities for serving static sites and blogs with Wai/Warp
from https://github.com/etcinit/kawaii
----------------------------------------------------------------------------
Minimalistic static-site fileserver。
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 can be configured via a TOML configuration file. Simply create a
config.toml file and place it on the working directory.
[server]
address = "127.0.0.1:8088"
run_dir = "run"
auto_cleanup = true
[stats]
address = "127.0.0.1:8089"
[bundle]
type = "LocalBundle"
dir = "/tmp/"
[unbundler]
poll_seconds = 10
Customization
While Espresso was built specifically for chromabits.com, it is able to serve
other static sites as long as their requirements are simple.
Deployment
A Kubernetes Helm chart is provided for deployment.
# Set up a Minikube cluster (if you don't already have one).
minikube start
# Create a values.yaml file and customize configuration.
#
# Note: Set the service type to `NodePort`.
nvim values.yaml
# Install espresso.
helm install espresso ./contrib/chart --namespace=default -f values.yaml
# Get the service URL.
minikube service --url espresso
Development
RUST_LOG=info cargo run to build and run the server.
RUST_LOG=info cargo test to run all tests.
tokio-console:
Support for tokio-console can be enabled with the console-subscriber flag:
RUSTFLAGS="--cfg tokio_unstable" cargo run -F console-subscriber
from https://gitlab.chromabits.com/etcinit/espresso
源码包的下载地址:
https://drive.google.com/file/d/1I1isneBRBW_2N-z6vw1WW57qCGuAmAIC/view
(Minimalistic static-site server
Espresso is a static website server with a minimalistic feature set focused on
running in a containerized environment.
While many web servers focus on serving sites from a local filesystem, I built
Espresso with the goal of making it easier to deploy static websites within a
containerized environment, which may not always have persistent storage
available (or even be a desirable feature in some cases).
On startup, Espresso fetches a bundle of the latest version of the site from an
S3-compatible bucket and begins serving it. Espresso continues to
monitor the bucket for changes to the bundle, re-deploying the site if a new
version becomes available. This allows Espresso to be scaled to multiple instances in
a container cluster without having to worry about persistent storage needs,
providing better availability and redundancy.
Espresso was originally built using Haskell and the Warp server library,
however, it later underwent a re-write in Rust as I ventured to learn the
language.
The Rust implementation has the following features:
- Declarative server configuration via TOML files and environment variables.
- Multi-threaded design using Tokio.
- Downloads site bundle from S3-compatible buckets or can serve a local directory.
- Health check endpoint support.
- Built-in fallback error pages and directory listings.
- Kubernetes Helm chart.
- CLI utility for uploading site bundles to S3 buckets.)