Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions filebrowser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,14 @@ module "filebrowser" {
database_path = ".config/filebrowser.db"
}
```

### Serve from the same domain (no subdomain)

```tf
module "filebrowser" {
source = "registry.coder.com/modules/filebrowser/coder"
agent_id = coder_agent.main.id
subdomain = false
agent_name = "main"
}
```
20 changes: 18 additions & 2 deletions filebrowser/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ variable "agent_id" {
description = "The ID of a Coder agent."
}

data "coder_workspace" "me" {
count = var.subdomain
}

data "coder_workspace_owner" "me" {
count = var.subdomain
}

variable "agent_name" {
type = string
default = ""
description = "The name of the main deployment. (Used to build the subpath for coder_app.)"
}

variable "database_path" {
type = string
description = "The path to the filebrowser database."
Expand Down Expand Up @@ -67,7 +81,9 @@ 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,
SUBDOMAIN : var.subdomain,
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),
})
run_on_start = true
}
Expand All @@ -78,7 +94,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.subdomain
share = var.share
order = var.order
}
3 changes: 3 additions & 0 deletions filebrowser/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ if [ "${DB_PATH}" != "filebrowser.db" ]; then
DB_FLAG=" -d ${DB_PATH}"
fi

# set baseurl to be able to run if sudomain=false; if subdomain=true the SERVER_BASE_PATH value will be ""
filebrowser config set --baseurl "${SERVER_BASE_PATH}" > ${LOG_PATH} 2>&1

printf "📂 Serving $${ROOT_DIR} at http://localhost:${PORT} \n\n"

printf "Running 'filebrowser --noauth --root $ROOT_DIR --port ${PORT}$${DB_FLAG}' \n\n"
Expand Down