[buildout]
parts =
  caddy-service
  caddy-configuration
  public-html
  publish-connection-information


eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true

[directory]
recipe = slapos.cookbook:mkdirectory
etc = $${buildout:directory}/etc
bin = $${buildout:directory}/bin
srv = $${buildout:directory}/srv
var = $${buildout:directory}/var
service = $${:etc}/service
public_html =  $${buildout:directory}/public_html
run = $${:var}/run
log = $${:var}/log

#www = $${:srv}/www
#ssl = $${:etc}/ssl

#################################
# caddy service
#################################
[caddy-service]
recipe = slapos.recipe.template
url = ${template-caddy-service:output}
output = $${directory:service}/caddy
mode = 0700
virtual-depends =
  $${caddy-configuration:ipv6}

[caddy-configuration]
recipe = slapos.recipe.template
url = ${template-caddyfile:output}
output = $${directory:etc}/Caddyfile
mode = 0600
access_log = $${directory:log}/caddy-access.log
error_log = $${directory:log}/caddy-error.log
ipv6 = $${slap-network-information:global-ipv6}
local_ip = $${slap-network-information:local-ipv4}
port = 9443

[public-html]
recipe = slapos.recipe.template
url = ${template-public-html:output}
output = $${directory:public_html}/index.html
mode = 0600

[publish-connection-information]
recipe = slapos.cookbook:publish
url = http://[$${caddy-configuration:ipv6}]:$${caddy-configuration:port}