filebrowser: allow to use subdomain = false

pull/286/head
Seppdo 11 months ago committed by GitHub
parent 4c45d69994
commit b0b0d55a1a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -44,3 +44,16 @@ module "filebrowser" {
database_path = ".config/filebrowser.db"
}
```
### Serve from the same domain (no subdomain)
Make sure to set both workspace_name and owner_name.
```tf
module "filebrowser" {
source = "registry.coder.com/modules/filebrowser/coder"
agent_id = coder_agent.main.id
workspace_name = data.coder_workspace.me.name
owner_name = data.coder_workspace_owner.me.name
}
```

@ -14,6 +14,24 @@ variable "agent_id" {
description = "The ID of a Coder agent."
}
variable "workspace_name" {
type = string
default = ""
description = "Set this and owner_name to serve filebrowser from subdirectory."
}
variable "owner_name" {
type = string
default = ""
description = "Set this and workspace_name to serve filebrowser from subdirectory."
}
variable "resource_name" {
type = string
default = "main"
description = "The name of the main deployment. (Used to build the subdirectory of the module.)"
}
variable "database_path" {
type = string
description = "The path to the filebrowser database."
@ -67,7 +85,10 @@ resource "coder_script" "filebrowser" {
PORT : var.port,
FOLDER : var.folder,
LOG_PATH : var.log_path,
DB_PATH : var.database_path
DB_PATH : var.database_path,
WORKSPACE_NAME : var.workspace_name,
OWNER_NAME : var.owner_name,
RESOURCE_NAME : var.resource_name
})
run_on_start = true
}
@ -78,7 +99,7 @@ resource "coder_app" "filebrowser" {
display_name = "File Browser"
url = "http://localhost:${var.port}"
icon = "https://raw.githubusercontent.com/filebrowser/logo/master/icon_raw.svg"
subdomain = true
subdomain = var.owner_name == "" && var.workspace_name == ""
share = var.share
order = var.order
}

@ -17,6 +17,13 @@ if [ "${DB_PATH}" != "filebrowser.db" ]; then
DB_FLAG=" -d ${DB_PATH}"
fi
# set baseurl if subdomain = false (owner_name and workspace_name is set), else reset to "" for use with subdomain = true
if [ "${OWNER_NAME}" != "" ] && [ "${WORKSPACE_NAME}" != "" ]; then
filebrowser config set --baseurl "/@${OWNER_NAME}/${WORKSPACE_NAME}.${RESOURCE_NAME}/apps/filebrowser" > ${LOG_PATH} 2>&1
else
filebrowser config set --baseurl "" > ${LOG_PATH} 2>&1
fi
printf "📂 Serving $${ROOT_DIR} at http://localhost:${PORT} \n\n"
printf "Running 'filebrowser --noauth --root $ROOT_DIR --port ${PORT}$${DB_FLAG}' \n\n"

Loading…
Cancel
Save