File tree Expand file tree Collapse file tree 4 files changed +84
-12
lines changed Expand file tree Collapse file tree 4 files changed +84
-12
lines changed Original file line number Diff line number Diff line change 1+ # Description: Dockerfile for building libvmod-tinykvm
2+ # Based on Dockerfile written by Laurence Rowe (lrowe)
3+ FROM varnish:7.6.1 AS varnish
4+ FROM varnish AS build_vmod
5+ ENV VMOD_BUILD_DEPS="libcurl4-openssl-dev libpcre3-dev libarchive-dev libjemalloc-dev git cmake build-essential"
6+ USER root
7+ WORKDIR /libvmod-tinykvm
8+ RUN set -e; \
9+ export DEBIAN_FRONTEND=noninteractive; \
10+ apt-get update; \
11+ apt-get -y install /pkgs/*.deb $VMOD_DEPS $VMOD_BUILD_DEPS; \
12+ rm -rf /var/lib/apt/lists/*;
13+ RUN set -e; \
14+ git init; \
15+ git remote add origin https://github.com/varnish/libvmod-tinykvm.git; \
16+ git fetch --depth 1; \
17+ git checkout FETCH_HEAD; \
18+ git submodule update --init --recursive;
19+ RUN set -e; \
20+ mkdir -p .build; \
21+ cd .build; \
22+ cmake .. -DCMAKE_BUILD_TYPE=Release -DVARNISH_PLUS=OFF; \
23+ cmake --build . -j6;
24+
25+ FROM varnish
26+ ENV VMOD_RUN_DEPS="libcurl4 libpcre3 libarchive13 libjemalloc2"
27+ USER root
28+ RUN set -e; \
29+ export DEBIAN_FRONTEND=noninteractive; \
30+ apt-get update; \
31+ apt-get -y install $VMOD_RUN_DEPS; \
32+ rm -rf /var/lib/apt/lists/*;
33+ COPY --from=build_vmod /libvmod-tinykvm/.build/libvmod_*.so /usr/lib/varnish/vmods/
34+ COPY demo/tinykvm.vcl /etc/varnish/default.vcl
35+ USER varnish
Original file line number Diff line number Diff line change @@ -6,6 +6,12 @@ The TinyKVM VMOD processes data in Varnish at native performance using your serv
66
77You can find the complete [ VMOD documentation here] ( docs/README.md ) .
88
9+ ## Demonstration
10+
11+ ``` sh
12+ KVM_GID=$( getent group kvm | cut -d: -f3) docker compose up
13+ ```
14+
915## Building and installing
1016
1117The build dependencies for this VMOD can be found in CI, but briefly:
@@ -43,10 +49,6 @@ There is a build-merge-release CI system that currently only builds for Ubuntu 2
4349
4450[ Packages here] ( https://github.com/varnish/libvmod-tinykvm/releases/download/v0.1/artifacts.zip ) .
4551
46- ## Try it out
47-
48- [ Demonstration VCL here] ( /demo/tinykvm.vcl ) . Use ` run.sh ` in the same directory to try it out.
49-
5052### Example VCL
5153
5254``` vcl
@@ -70,14 +72,11 @@ sub vcl_backend_fetch {
7072 """{
7173 "headers": ["Host: filebin.varnish-software.com"]
7274 }""");
73- # Transcode JPG to AVIF and compress with Zstandard
74- tinykvm.chain("avif");
75- set bereq.backend = tinykvm.program("zstd", "",
76- """{
77- "action": "compress",
78- "level": 6,
79- "resp_headers": ["Content-Disposition: inline; filename=spooky.avif"]
80- }""");
75+ # Transcode JPG to AVIF
76+ set bereq.backend = tinykvm.program("avif", "", """{
77+ "speed": 10,
78+ "quality": 35
79+ }""");
8180}
8281```
8382
Original file line number Diff line number Diff line change 1+ vcl 4.1 ;
2+ import tinykvm;
3+ backend default none;
4+
5+ sub vcl_init {
6+ # Download and activate a Varnish-provided library of compute programs.
7+ # A full list of programs and how they can be used would be on the docs site.
8+ tinykvm.library("https://filebin.varnish-software.com/tinykvm_programs/compute.json" );
9+ #tinykvm.library("file:///home/gonzo/github/kvm_demo/compute.json");
10+
11+ # Tell VMOD compute how to contact Varnish (Unix Socket *ONLY*)
12+ tinykvm.init_self_requests("/tmp/tinykvm.sock" );
13+ }
14+
15+ sub vcl_backend_fetch {
16+ # Fetch a JPG image from a remote server
17+ tinykvm.chain("fetch" ,
18+ "https://filebin.varnish-software.com/tinykvm_programs/spooky.jpg" ,
19+ """{
20+ " headers": [" Host: filebin.varnish-software.com"]
21+ }""" );
22+ # Transcode JPG to AVIF
23+ set bereq.backend = tinykvm.program("avif" , "" , """{
24+ " speed": 10,
25+ " quality": 35
26+ }""" );
27+ }
Original file line number Diff line number Diff line change 1+ services :
2+ tinykvm-docker :
3+ image : vmod-tinykvm:latest
4+ container_name : tinykvm-varnish
5+ ports :
6+ - " 8080:80"
7+ restart : always
8+ group_add :
9+ - " ${KVM_GID:-109}"
10+ devices :
11+ - " /dev/kvm:/dev/kvm"
You can’t perform that action at this time.
0 commit comments