job "[[ .instance ]]" { [[- $c := merge .bookstack . ]] [[ template "common/job_start" $c ]] group "bookstack" { count = [[ $c.count ]] network { mode = "bridge" } [[ template "common/volumes" $c ]] service { name = "[[ .instance ]][[ .consul.suffix ]]" port = 8080 [[ template "common/connect" $c ]] tags = [ [[ template "common/traefik_tags" $c ]] ] } task "bookstack" { driver = "[[ $c.nomad.driver ]]" config { image = "[[ $c.image ]]" pids_limit = 100 readonly_rootfs = true volumes = ["secrets/bookstack.env:/app/.env"] [[ template "common/tmpfs" dict "size" "5000000" "target" "/tmp" ]] } [[ template "common/vault.policies" $c ]] env { # Fix PDF export as the font cache must be writeable HOME = "/tmp" } [[ template "common/file_env" $c ]] # Ensure only the first allocation runs the database initialization / upgrades template { data = <<_EOT {{- if eq (env "NOMAD_ALLOC_INDEX") "0" }} BOOKSTACK_INIT_DB=true {{- else }} MINIT_DISABLE=bookstack-queue BOOKSTACK_INIT_DB=false {{- end }} _EOT destination = "secrets/bookstack_initdb.env" env = true } # BookStack won't work with env vars because PHP clears env # So, publish BookStack settings here template { data =<<_EOT [[- range $k, $v := $c.settings ]] [[ $k ]]=[[ $v ]] [[- end ]] _EOT destination = "secrets/bookstack.env" uid = 100100 gid = 100000 perms = 400 } volume_mount { volume = "data" destination = "/data" } [[ template "common/resources" $c ]] } } }