compile varnish tmpl from docker-entrypoint script

also updates kubernetes resources to separate app & varnish into two different deployments
This commit is contained in:
2025-08-26 19:56:52 +02:00
parent d233c8081a
commit 630ceb2473
12 changed files with 188 additions and 150 deletions

View File

@@ -44,14 +44,9 @@ COPY default.vcl.tmpl /etc/varnish/
COPY *.vcl /etc/varnish/
COPY includes /etc/varnish/includes
# Set variables for *.tmpl files
ARG PROXY_HOST=$PROXY_HOST
ARG IMAGE_HOST=$IMAGE_HOST
# Generate VCL
RUN gomplate -f /etc/varnish/default.vcl.tmpl -o /etc/varnish/default.vcl
RUN rm /etc/varnish/default.vcl.tmpl
# Create entrypoint script
COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
EXPOSE 6081
CMD ["varnishd", "-F", "-f", "/etc/varnish/default.vcl", "-a", ":6081", "-s", "malloc,512m"]
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]

View File

@@ -46,17 +46,6 @@ sub vcl_recv {
unset req.http.Cookie;
}
// Svelte-kit needs to distinguish between it's own files and the Host header.
// The X-Forwarded-* headers below are to tell svelte-kit where it's local files are,
// and the Host header is included in the returned html & js referencing the external
// domain or proxy requested by client.
// https://svelte.dev/docs/kit/adapter-node#Environment-variables-ORIGIN-PROTOCOL_HEADER-HOST_HEADER-and-PORT_HEADER
sub vcl_backend_fetch {
set bereq.http.X-Forwarded-Host = "localhost";
set bereq.http.X-Forwarded-Port = "3000";
set bereq.http.X-Forwarded-Proto = "http";
}
sub vcl_synth {
if (resp.status == 204) {
set resp.http.Access-Control-Allow-Origin = "*";

View File

@@ -0,0 +1,8 @@
#!/bin/sh
set -e
# Generate VCL at runtime
gomplate -f /etc/varnish/default.vcl.tmpl -o /etc/varnish/default.vcl
# Execute startup CMD
exec varnishd -F -f /etc/varnish/default.vcl -a :6081 -s malloc,512m