{"id":23381271,"url":"https://github.com/bvis/docker-varnish-consul-template","last_synced_at":"2025-10-15T17:32:46.557Z","repository":{"id":149012797,"uuid":"60275563","full_name":"bvis/docker-varnish-consul-template","owner":"bvis","description":"Launches the varnish daemon and allows to define dynamic backend configuration of services registered in consul.","archived":false,"fork":false,"pushed_at":"2016-06-03T10:41:31.000Z","size":21,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-14T05:29:51.973Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bvis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-06-02T15:29:17.000Z","updated_at":"2019-08-26T19:25:03.000Z","dependencies_parsed_at":"2023-08-14T09:02:54.200Z","dependency_job_id":null,"html_url":"https://github.com/bvis/docker-varnish-consul-template","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bvis%2Fdocker-varnish-consul-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bvis%2Fdocker-varnish-consul-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bvis%2Fdocker-varnish-consul-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bvis%2Fdocker-varnish-consul-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bvis","download_url":"https://codeload.github.com/bvis/docker-varnish-consul-template/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247803235,"owners_count":20998728,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-21T20:48:38.481Z","updated_at":"2025-10-15T17:32:41.524Z","avatar_url":"https://github.com/bvis.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"# basi/varnish-consul-template\nFrom the alpine distribution it installs a Varnish daemon and Consul Template.\n\n### Consul Template\nThanks to consul-template you can define dynamically the backends that uses your varnish cluster.\nYou just need to overwrite in your image or container the template `15-backend.vcl.ctmpl` with the desired service\npreviously registered in Consul.\n\nThere's a default configuration for consul-template, you can override it as well. The default configuration\nsearches for consul in its localhost:8500.\n\nAs the provided default template does not have any service declared you can use this image in development\nenvironments without consul.\n\n\n### Varnish\nIt allows you to use an specific VCL file when you provide an environment variable named: `$VCL_CONFIG`. But\nyou can provide a directory instead of a file and the system internally will merge all the \"vcl\" files found in\nthe directory to create the VCL file that will be used by Varnish.\n\nThis approach is useful when you have complicated Varnish logic, and it allows to use small consul-template templates.\n\nAs the provided VCL is split in pieces you can overwrite each piece individually in your container or the entire\ndirectory.\n\n## Example of use\n\n### Provide a directory with the logic split in files\n\nYou can override in your image or container the provided template by something like this:\n\n    # Backends director\n\n    {{range service \"my-web\"}}\n    backend {{.Name}}_{{.ID}} { # Define one backend\n      .host = \"{{.Address}}\"; # IP or Hostname of backend\n      .port = \"{{.Port}}\";    # Port Apache or whatever is listening\n      .max_connections = 300; # That's it\n    }{{end}}\n\n    sub vcl_init {\n      # Called when VCL is loaded, before any requests pass through it.\n      # Typically used to initialize VMODs.\n\n      new vdir = directors.round_robin();\n    {{range service \"my-web\"}}\n      vdir.add_backend({{.Name}}_{{.ID}});{{end}}\n    }\n\nYou can launch it as:\n\n    docker run --rm -it -P \\\n        -v $PWD/rootfs/etc/varnish/conf.d/:/etc/varnish/conf.d/ \\\n        -e VCL_CONFIG=/etc/varnish/conf.d \\\n        basi/varnish-consul-template\n\nIt will use the VCL files contained in the volume instead of the originally available files provided by the image.\nIf you want to change one VCL status you just need to to it with:\n\n    docker run --rm -it -P \\\n        -v $PWD/rootfs/etc/varnish/conf.d/30-vcl_deliver.vcl:/etc/varnish/conf.d/30-vcl_deliver.vcl \\\n        -e VCL_CONFIG=/etc/varnish/conf.d \\\n        basi/varnish-consul-template\n\nAnd it will just switch just the logic executed in the vcl_deliver status by yours.\n\n### Provide a full VCL file\n\nAnother possibility is just give to the system a full VCL file, this has the drawback that makes you lose the\nservice discovery embedded, or at least enforces to you to provide a `consul-template` template with all the VCL and a\ndifferent `consul-template` config file to change the references to your file instead of the default\nused `20-backend_and_vcl_init.vcl.ctmpl`.\n\nThe needed parameters would be something similar to:\n\ndocker run --rm -it -P \\\n        -v $PWD/rootfs/etc/varnish/default.vcl:/etc/varnish/default.vcl \\\n        -v $PWD/rootfs/etc/consul-template/templates/default.vcl.ctmpl:/etc/consul-template/templates/default.vcl.ctmpl \\ # Your template here\n        -v $PWD/rootfs/etc/consul-template/config.d/init.cfg:/etc/consul-template/config.d/init.cfg \\ # Your reference to the template here\n        -e VCL_CONFIG=/etc/varnish/default.vcl \\\n        basi/varnish-consul-template\n\n### Other supported parameters:\n\n`$CACHE_SIZE`:      Determines the cache size used by varnish\n`$VARNISHD_PARAMS`: Other parameters you want to pass to the varnish daemon\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbvis%2Fdocker-varnish-consul-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbvis%2Fdocker-varnish-consul-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbvis%2Fdocker-varnish-consul-template/lists"}