Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ The TinyKVM VMOD processes data in Varnish at native performance using your serv

You can find the complete [VMOD documentation here](docs/README.md).

## Demonstration

```sh
KVM_GID=$(getent group kvm | cut -d: -f3) docker compose up
```

## Building and installing

The build dependencies for this VMOD can be found in CI, but briefly:
Expand Down Expand Up @@ -43,10 +49,6 @@ There is a build-merge-release CI system that currently only builds for Ubuntu 2

[Packages here](https://github.com/varnish/libvmod-tinykvm/releases/download/v0.1/artifacts.zip).

## Try it out

[Demonstration VCL here](/demo/tinykvm.vcl). Use `run.sh` in the same directory to try it out.

### Example VCL

```vcl
Expand All @@ -70,14 +72,11 @@ sub vcl_backend_fetch {
"""{
"headers": ["Host: filebin.varnish-software.com"]
}""");
# Transcode JPG to AVIF and compress with Zstandard
tinykvm.chain("avif");
set bereq.backend = tinykvm.program("zstd", "",
"""{
"action": "compress",
"level": 6,
"resp_headers": ["Content-Disposition: inline; filename=spooky.avif"]
}""");
# Transcode JPG to AVIF
set bereq.backend = tinykvm.program("avif", "", """{
"speed": 10,
"quality": 35
}""");
}
```

Expand Down
27 changes: 27 additions & 0 deletions demo/demo.vcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
vcl 4.1;
import tinykvm;
backend default none;

sub vcl_init {
# Download and activate a Varnish-provided library of compute programs.
# A full list of programs and how they can be used would be on the docs site.
tinykvm.library("https://filebin.varnish-software.com/tinykvm_programs/compute.json");
#tinykvm.library("file:///home/gonzo/github/kvm_demo/compute.json");

# Tell VMOD compute how to contact Varnish (Unix Socket *ONLY*)
tinykvm.init_self_requests("/tmp/tinykvm.sock");
}

sub vcl_backend_fetch {
# Fetch a JPG image from a remote server
tinykvm.chain("fetch",
"https://filebin.varnish-software.com/tinykvm_programs/spooky.jpg",
"""{
"headers": ["Host: filebin.varnish-software.com"]
}""");
# Transcode JPG to AVIF
set bereq.backend = tinykvm.program("avif", "", """{
"speed": 10,
"quality": 35
}""");
}
13 changes: 13 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
services:
tinykvm-docker:
image: vmod-tinykvm:latest
container_name: tinykvm-varnish
ports:
- "8080:80"
restart: always
group_add:
- "${KVM_GID:-109}"
devices:
- "/dev/kvm:/dev/kvm"
volumes:
- ./demo/tinykvm.vcl:/etc/varnish/default.vcl