@@ -20,13 +20,8 @@ data "coder_workspace_owner" "me" {}
2020
2121variable "agent_name" {
2222 type = string
23- description = " The name of the main deployment. (Used to build the subpath for coder_app.)"
24- default = " "
25- validation {
26- # If subdomain is false, then agent_name must be set.
27- condition = var. subdomain || var. agent_name != " "
28- error_message = " The agent_name must be set."
29- }
23+ description = " The name of the coder_agent resource. (Only required if subdomain is false and the template uses multiple agents.)"
24+ default = null
3025}
3126
3227variable "database_path" {
@@ -73,6 +68,12 @@ variable "order" {
7368 default = null
7469}
7570
71+ variable "slug" {
72+ type = string
73+ description = " The slug of the coder_app resource."
74+ default = " filebrowser"
75+ }
76+
7677variable "subdomain" {
7778 type = bool
7879 description = <<- EOT
@@ -85,26 +86,38 @@ variable "subdomain" {
8586resource "coder_script" "filebrowser" {
8687 agent_id = var. agent_id
8788 display_name = " File Browser"
88- icon = " https://raw.githubusercontent.com/ filebrowser/logo/master/icon_raw .svg"
89+ icon = " /icon/ filebrowser.svg"
8990 script = templatefile (" ${ path . module } /run.sh" , {
9091 LOG_PATH : var.log_path,
9192 PORT : var.port,
9293 FOLDER : var.folder,
9394 LOG_PATH : var.log_path,
9495 DB_PATH : var.database_path,
9596 SUBDOMAIN : var.subdomain,
96- SERVER_BASE_PATH : var.subdomain ? " " : format ( " /@%s/%s.%s/apps/filebrowser " , data . coder_workspace_owner . me . name , data . coder_workspace . me . name , var . agent_name ),
97+ SERVER_BASE_PATH : local.server_base_path
9798 })
9899 run_on_start = true
99100}
100101
101102resource "coder_app" "filebrowser" {
102103 agent_id = var. agent_id
103- slug = " filebrowser "
104+ slug = var . slug
104105 display_name = " File Browser"
105- url = " http://localhost: ${ var . port } "
106- icon = " https://raw.githubusercontent.com/ filebrowser/logo/master/icon_raw .svg"
106+ url = local . url
107+ icon = " /icon/ filebrowser.svg"
107108 subdomain = var. subdomain
108109 share = var. share
109110 order = var. order
111+
112+ healthcheck {
113+ url = local. healthcheck_url
114+ interval = 5
115+ threshold = 6
116+ }
110117}
118+
119+ locals {
120+ server_base_path = var. subdomain ? " " : format (" /@%s/%s%s/apps/%s" , data. coder_workspace_owner . me . name , data. coder_workspace . me . name , var. agent_name != null ? " .${ var . agent_name } " : " " , var. slug )
121+ url = " http://localhost:${ var . port } ${ local . server_base_path } "
122+ healthcheck_url = " http://localhost:${ var . port } ${ local . server_base_path } /health"
123+ }
0 commit comments