Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd814fdf

Browse files
authored
fix(.devcontainer): add home volume and fix code-server and filebrowser (#18648)
1 parente97540a commitd814fdf

File tree

5 files changed

+55
-40
lines changed

5 files changed

+55
-40
lines changed

‎.devcontainer/devcontainer.json‎

Lines changed: 29 additions & 4 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"],
@@ -43,15 +44,39 @@
4344
"external":true,
4445
"icon":"/icon/zed.svg",
4546
"order":5
47+
},
48+
// Reproduce `code-server` app here from the code-server
49+
// feature so that we can set the correct folder and order.
50+
// Currently, the order cannot be specified via option because
51+
// we parse it as a number whereas variable interpolation
52+
// results in a string. Additionally we set health check which
53+
// is not yet set in the feature.
54+
{
55+
"slug":"code-server",
56+
"displayName":"code-server",
57+
"url":"http://${localEnv:FEATURE_CODE_SERVER_OPTION_HOST:127.0.0.1}:${localEnv:FEATURE_CODE_SERVER_OPTION_PORT:8080}/?folder=${containerWorkspaceFolder}",
58+
"openIn":"${localEnv:FEATURE_CODE_SERVER_OPTION_APPOPENIN:slim-window}",
59+
"share":"${localEnv:FEATURE_CODE_SERVER_OPTION_APPSHARE:owner}",
60+
"icon":"/icon/code.svg",
61+
"group":"${localEnv:FEATURE_CODE_SERVER_OPTION_APPGROUP:Web Editors}",
62+
"order":3,
63+
"healthCheck": {
64+
"url":"http://${localEnv:FEATURE_CODE_SERVER_OPTION_HOST:127.0.0.1}:${localEnv:FEATURE_CODE_SERVER_OPTION_PORT:8080}/healthz",
65+
"interval":5,
66+
"threshold":2
67+
}
4668
}
4769
]
4870
}
4971
},
5072
"mounts": [
73+
// Add a volume for the Coder home directory to persist shell history,
74+
// and speed up dotfiles init and/or personalization.
75+
"source=coder-coder-devcontainer-home,target=/home/coder,type=volume",
5176
// Mount the entire home because conditional mounts are not supported.
5277
// See: https://github.com/devcontainers/spec/issues/132
5378
"source=${localEnv:HOME},target=/mnt/home/coder,type=bind,readonly"
5479
],
55-
"postCreateCommand":"./.devcontainer/postCreateCommand.sh",
56-
"postStartCommand":"sudo service docker start"
80+
"postCreateCommand":["./.devcontainer/scripts/post_create.sh"],
81+
"postStartCommand":["./.devcontainer/scripts/post_start.sh"]
5782
}

‎.devcontainer/filebrowser/devcontainer-feature.json‎

Lines changed: 9 additions & 13 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",
@@ -41,7 +37,7 @@
4137
"healthcheck": {
4238
"url":"http://localhost:${localEnv:FEATURE_FILEBROWSER_OPTION_PORT:13339}/health",
4339
"interval":5,
44-
"threshold":6
40+
"threshold":2
4541
}
4642
}
4743
]

‎.devcontainer/filebrowser/install.sh‎

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,38 +11,29 @@ 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
30-
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}"
29+
filebrowser config init >>\${LOG_PATH} 2>&1
30+
filebrowser users add admin "" --perm.admin=true --viewMode=mosaic >>\${LOG_PATH} 2>&1
4131
fi
4232
43-
set -euo pipefail
33+
filebrowser configset --baseurl=\${BASEURL} --port=\${PORT} --auth.method=noauth --root=\${FOLDER} >>\${LOG_PATH} 2>&1
4434
4535
printf "👷 Starting filebrowser...\n\n"
36+
4637
printf "📂 Serving\${FOLDER} at http://localhost:\${PORT}\n\n"
4738
4839
filebrowser >>\${LOG_PATH} 2>&1 &
@@ -52,5 +43,4 @@ 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"
File renamed without changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
3+
# Start Docker service if not already running.
4+
sudo service docker start

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp