Skip to content

Commit

Permalink
more examples
Browse files Browse the repository at this point in the history
  • Loading branch information
gquintard committed Jul 15, 2023
1 parent 2eb823f commit 45e5f1e
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
39 changes: 39 additions & 0 deletions vmod-examples/Dockerfile.custom.redis
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions vmod-examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
19 changes: 19 additions & 0 deletions vmod-examples/examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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 \
Expand All @@ -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
Expand Down

0 comments on commit 45e5f1e

Please sign in to comment.