Skip to content

Commit 0338bd7

Browse files
committed
served over the subdomain by default, and then fallback to localhost
1 parent 6319e67 commit 0338bd7

File tree

1 file changed

+10
-7
lines changed
  • registry/AJ0070/modules/pgadmin

1 file changed

+10
-7
lines changed

registry/AJ0070/modules/pgadmin/main.tf

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,31 @@ variable "port" {
1717
default = 5050
1818
}
1919

20-
variable "log_path" {
21-
type = string
22-
description = "The path to the log file."
23-
default = "/tmp/pgadmin.log"
20+
variable "subdomain" {
21+
type = bool
22+
description = "If true, the app will be served on a subdomain."
23+
default = true
2424
}
2525

26+
data "coder_workspace" "me" {}
27+
2628
resource "coder_app" "pgadmin" {
29+
count = data.coder_workspace.me.start_count
2730
agent_id = var.agent_id
2831
display_name = "pgAdmin"
2932
slug = "pgadmin"
3033
icon = "/icon/postgres.svg"
31-
url = "http://localhost:${var.port}"
34+
url = var.subdomain ? "https://pgadmin-${data.coder_workspace.me.id}.${data.coder_workspace.me.access_url}" : "http://localhost:${var.port}"
3235
share = "owner"
3336
}
3437

3538
resource "coder_script" "pgadmin" {
3639
agent_id = var.agent_id
37-
display_name = "Install pgAdmin"
40+
display_name = "Install and run pgAdmin"
3841
icon = "/icon/postgres.svg"
3942
run_on_start = true
4043
script = templatefile("${path.module}/run.sh", {
4144
PORT = var.port,
42-
LOG_PATH = var.log_path,
45+
LOG_PATH = "/tmp/pgadmin.log"
4346
})
4447
}

0 commit comments

Comments
 (0)