From 45e5f1e3b434e8ad3a1cd1f8594b3af93cea0a71 Mon Sep 17 00:00:00 2001 From: Guillaume Quintard Date: Fri, 14 Jul 2023 22:20:28 -0700 Subject: [PATCH] more examples --- vmod-examples/Dockerfile.custom.redis | 39 +++++++++++++++++++++++++++ vmod-examples/README.md | 1 + vmod-examples/examples.sh | 19 +++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 vmod-examples/Dockerfile.custom.redis diff --git a/vmod-examples/Dockerfile.custom.redis b/vmod-examples/Dockerfile.custom.redis new file mode 100644 index 0000000000..179e2f573e --- /dev/null +++ b/vmod-examples/Dockerfile.custom.redis @@ -0,0 +1,39 @@ +FROM varnish:7.3 + +ARG VMOD_URL= +ARG VMOD_BUILD_DEPS= +ARG VMOD_RUN_DEPS= +ARG SKIP_CHECK= + +USER root +# follow https://github.com/carlosabalde/libvmod-redis/blob/master/.github/workflows/main.yml +# for most of the install logic +RUN set -e; \ + # get the dependencies + apt-get update; \ + apt-get -y install /pkgs/*.deb $VMOD_DEPS $VMOD_BUILD_DEPS $VMOD_RUN_DEPS; \ + # compile hiredis with TLS support from source + cd /tmp; \ + curl -L https://github.com/redis/hiredis/archive/v1.2.0.zip -o hiredis.zip; \ + unzip hiredis.zip; \ + cd hiredis-*/; \ + make USE_SSL=1; \ + make USE_SSL=1 PREFIX='/usr/local' install; \ + ldconfig; \ + # compile redis from source + cd /tmp; \ + curl -L http://download.redis.io/releases/redis-7.0.9.tar.gz -o redis.tar.gz; \ + tar zxvf redis.tar.gz; \ + cd redis-*/; \ + make BUILD_TLS=yes; \ + make BUILD_TLS=yes PREFIX='/usr/local' install; \ + ldconfig; \ + # get, compile and install the cmod + mkdir /tmp/module_to_build; \ + cd /tmp/module_to_build; \ + curl -L -o - $VMOD_URL | tar xazvf - --strip 1; \ + # clean up and set the user back to varnish + apt-get -y purge --auto-remove $VMOD_DEPS varnish-dev $VMOD_BUILD_DEPS; \ + # don't forget to clean the redis/hiredis sources + rm -rf /var/lib/apt/lists/* /tmp/varnish-cache /tmp/hiredis* /tmp/redis* +USER varnish diff --git a/vmod-examples/README.md b/vmod-examples/README.md index 3741c087a7..3ef6c57067 100644 --- a/vmod-examples/README.md +++ b/vmod-examples/README.md @@ -12,6 +12,7 @@ This directory hopes to fix remedy this by doing two things. The first one is pr Thankfully, there's a relatively small number of types of vmods: - `C` vmods that just need the `dev` package of Varnish and a few classic dependencies (`make`, `autotools`, etc.) - same as the first group, but those need access to the source of the exact version of Varnish that we build against +- same as the first group, but we need to compile some dependencies from sources - `rust` vmods Each type of vmod is represented by the a `Dockerfile.*` you'll find in this here directory. and you can have a look at the `build()` in the [examples.sh](./examples.sh) script to see how to use them. diff --git a/vmod-examples/examples.sh b/vmod-examples/examples.sh index bc9d5260fb..be3c448f4d 100755 --- a/vmod-examples/examples.sh +++ b/vmod-examples/examples.sh @@ -31,6 +31,8 @@ build() { # - cfg: https://github.com/carlosabalde/libvmod-cfg # - blobdigest: https://gitlab.com/uplex/varnish/libvmod-blobdigest # - brotli: https://gitlab.com/uplex/varnish/libvfp-brotli +# - geoip2: https://github.com/varnishcache-friends/libvmod-geoip2 +# - redis: https://github.com/carlosabalde/libvmod-redis # - uuid: https://github.com/otto-de/libvmod-uuid build \ regular \ @@ -66,6 +68,14 @@ build \ "libcurl4-openssl-dev libjemalloc-dev libluajit-5.1-dev vim-common" \ "libjemalloc2" +build \ + regular \ + geoip2 \ + https://github.com/varnishcache-friends/libvmod-geoip2/archive/refs/heads/devel.tar.gz \ + "libmaxminddb-dev" \ + "libmaxminddb0" \ + true # the tarball doesn't include the maxmind database used by the tests, so skip them + build \ regular \ uuid \ @@ -92,6 +102,15 @@ build \ "" \ true +# C vmod, but we need to build some dependencies from sources, so we use +# a custom Dockerfile +# - redit: https://github.com/carlosabalde/libvmod-redis +build \ + custom.redis \ + redis \ + http://github.com/carlosabalde/libvmod-redis/archive/refs/heads/7.3.tar.gz \ + "libev-dev libssl-dev unzip" + # rust vmods: # - fileserver: https://github.com/gquintard/vmod_fileserver # - reqwest: https://github.com/gquintard/vmod_reqwest