template varnish config using gomplate

This commit is contained in:
2025-08-22 00:59:44 +02:00
parent 7d1f536af5
commit 75355c43a8
8 changed files with 43 additions and 32 deletions

View File

@@ -21,7 +21,19 @@ RUN git clone https://github.com/varnish/libvmod-digest.git /opt/libvmod-digest
./configure VARNISHSRC=/usr/include/varnish && \
make && make install
COPY . /etc/varnish/
COPY --from=hairyhenderson/gomplate:stable /gomplate /bin/gomplate
ARG HASS_HOST
ARG FRONTEND_HOST
ENV HASS_HOST=$HASS_HOST
ENV FRONTEND_HOST=$FRONTEND_HOST
COPY default.vcl.tmpl /etc/varnish/
COPY *.vcl /etc/varnish/
COPY includes /etc/varnish/includes
RUN gomplate -f /etc/varnish/default.vcl.tmpl -o /etc/varnish/default.vcl
RUN rm /etc/varnish/default.vcl.tmpl
EXPOSE 6081

View File

@@ -3,20 +3,18 @@ vcl 4.0;
import std;
import digest;
# include "handlers/ttl-override-handler.vcl";
include "includes/x-cache-header.vcl";
include "vcl_deliver.vcl";
# Define backend pointing to Home Assistant IP
backend hass_backend {
.host = "10.0.0.82";
.host = "{{ getenv `HASS_HOST` `homeassistant.local` }}";
.port = "8123";
}
backend app_frontend {
.host = "host.docker.internal";
.port = "5173";
.host = "{{ getenv `FRONTEND_HOST` `localhost` }}";
.port = "3000";
}
sub vcl_recv {