Skip to content

Commit e51c667

Browse files
committed
fix filebrowser
1 parent e3de0d9 commit e51c667

File tree

3 files changed

+24
-37
lines changed

3 files changed

+24
-37
lines changed

.devcontainer/devcontainer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22
"name": "Development environments on your infrastructure",
33
"image": "codercom/oss-dogfood:latest",
44
"features": {
5-
// See all possible options here https://github.com/devcontainers/features/tree/main/src/docker-in-docker
65
"ghcr.io/devcontainers/features/docker-in-docker:2": {
76
"moby": "false"
87
},
98
"ghcr.io/coder/devcontainer-features/code-server:1": {
109
"auth": "none",
1110
"port": 13337
1211
},
13-
"./filebrowser": {}
12+
"./filebrowser": {
13+
"folder": "${containerWorkspaceFolder}"
14+
}
1415
},
1516
// SYS_PTRACE to enable go debugging
1617
"runArgs": ["--cap-add=SYS_PTRACE"],

.devcontainer/filebrowser/devcontainer-feature.json

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,15 @@
99
"default": "13339",
1010
"description": "The port to run filebrowser on"
1111
},
12-
// "folder": {
13-
// "type": "string",
14-
// "default": "${containerWorkspaceFolder}",
15-
// "description": "The root directory for filebrowser to serve"
16-
// },
17-
"auth": {
12+
"folder": {
1813
"type": "string",
19-
"enum": [
20-
"none",
21-
"password"
22-
],
23-
"default": "none",
24-
"description": "Authentication method (none or password)"
14+
"default": "",
15+
"description": "The root directory for filebrowser to serve"
16+
},
17+
"baseUrl": {
18+
"type": "string",
19+
"default": "",
20+
"description": "The base URL for filebrowser (e.g., /filebrowser)"
2521
}
2622
},
2723
"entrypoint": "/usr/local/bin/filebrowser-entrypoint",

.devcontainer/filebrowser/install.sh

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,46 +11,36 @@ if ! command -v filebrowser &>/dev/null; then
1111
curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh | bash
1212
fi
1313

14-
printf "🥳 Installation complete!\n\n"
15-
16-
# Create run script.
14+
# Create entrypoint.
1715
cat >/usr/local/bin/filebrowser-entrypoint <<EOF
18-
#!/bin/bash
19-
20-
printf "🛠️ Configuring filebrowser\n\n"
16+
#!/usr/bin/env bash
2117
22-
AUTH="${AUTH}"
2318
PORT="${PORT}"
24-
FOLDER="$(pwd)"
19+
FOLDER="${FOLDER:-}"
20+
FOLDER="\${FOLDER:-\$(pwd)}"
21+
BASEURL="${BASEURL:-}"
2522
LOG_PATH=/tmp/filebrowser.log
26-
export FB_DATABASE="/tmp/filebrowser.db"
23+
export FB_DATABASE="\${HOME}/.filebrowser.db"
24+
25+
printf "🛠️ Configuring filebrowser\n\n"
2726
2827
# Check if filebrowser db exists.
2928
if [[ ! -f "\${FB_DATABASE}" ]]; then
3029
filebrowser config init
31-
if [[ "\$AUTH" == "password" ]]; then
32-
filebrowser users add admin admin --perm.admin=true --viewMode=mosaic
33-
fi
34-
fi
35-
36-
# Configure filebrowser.
37-
if [[ "\$AUTH" == "none" ]]; then
38-
filebrowser config set --port="\${PORT}" --auth.method=noauth --root="\${FOLDER}"
39-
else
40-
filebrowser config set --port="\${PORT}" --auth.method=json --root="\${FOLDER}"
30+
filebrowser users add admin "" --perm.admin=true --viewMode=mosaic
4131
fi
4232
43-
set -euo pipefail
33+
filebrowser config set --baseurl=\${BASEURL} --port=\${PORT} --auth.method=noauth --root=\${FOLDER}
4434
4535
printf "👷 Starting filebrowser...\n\n"
36+
4637
printf "📂 Serving \${FOLDER} at http://localhost:\${PORT}\n\n"
4738
48-
filebrowser >>\${LOG_PATH} 2>&1 &
39+
filebrowser >>\${LOG_PATH} &
4940
5041
printf "📝 Logs at \${LOG_PATH}\n\n"
5142
EOF
5243

5344
chmod +x /usr/local/bin/filebrowser-entrypoint
5445

55-
printf "✅ File Browser installed!\n\n"
56-
printf "🚀 Run 'filebrowser-entrypoint' to start the service\n\n"
46+
printf "🥳 Installation complete!\n\n"

0 commit comments

Comments
 (0)