8000 feat(.devcontainer): install dotfiles if present (#18606) · coder/coder@872aef3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 872aef3

Browse files
authored
feat(.devcontainer): install dotfiles if present (#18606)
1 parent f2d229e commit 872aef3

File tree

2 files changed

+67
-4
lines changed

2 files changed

+67
-4
lines changed

.devcontainer/devcontainer.json

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "Development environments on your infrastructure",
33
"image": "codercom/oss-dogfood:latest",
4-
54
"features": {
65
// See all possible options here https://github.com/devcontainers/features/tree/main/src/docker-in-docker
76
"ghcr.io/devcontainers/features/docker-in-docker:2": {
@@ -13,10 +12,20 @@
1312
}
1413
},
1514
// SYS_PTRACE to enable go debugging
16-
"runArgs": ["--cap-add=SYS_PTRACE"],
15+
"runArgs": [
16+
"--cap-add=SYS_PTRACE"
17+
],
1718
"customizations": {
1819
"vscode": {
19-
"extensions": ["biomejs.biome"]
20+
"extensions": [
21+
"biomejs.biome"
22+
]
2023
}
21-
}
24+
},
25+
"mounts": [
26+
// Mount the entire home because conditional mounts are not supported.
27+
// See: https://github.com/devcontainers/spec/issues/132
28+
"source=${localEnv:HOME},target=/mnt/home/coder,type=bind,readonly"
29+
],
30+
"postCreateCommand": "./.devcontainer/postCreateCommand.sh"
2231
}

.devcontainer/postCreateCommand.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/sh
2+
3+
install_ssh_config() {
4+
echo "🔑 Installing SSH configuration..."
5+
rsync -a /mnt/home/coder/.ssh/ ~/.ssh/
6+
chmod 0700 ~/.ssh
7+
}
8+
9+
install_git_config() {
10+
echo "📂 Installing Git configuration..."
11+
if [ -f /mnt/home/coder/git/config ]; then
12+
rsync -a /mnt/home/coder/git/ ~/.config/git/
13+
elif [ -d /mnt/home/coder/.gitconfig ]; then
14+
rsync -a /mnt/home/coder/.gitconfig ~/.gitconfig
15+
else
16+
echo "⚠️ Git configuration directory not found."
17+
fi
18+
}
19+
20+
install_dotfiles() {
21+
if [ ! -d /mnt/home/coder/.config/coderv2/dotfiles ]; then
22+
echo "⚠️ Dotfiles directory not found."
23+
return
24+
fi
25+
26+
cd /mnt/home/coder/.config/coderv2/dotfiles || return
27+
for script in install.sh install bootstrap.sh bootstrap script/bootstrap setup.sh setup script/setup; do
28+
if [ -x $script ]; then
29+
echo "📦 Installing dotfiles..."
30+
./$script || {
31+
echo "❌ Error running $script. Please check the script for issues."
32+
return
33+
}
34+
echo "✅ Dotfiles installed successfully."
35+
return
36+
fi
37+
done
38+
echo "⚠️ No install script found in dotfiles directory."
39+
}
40+
41+
personalize() {
42+
# Allow script to continue as Coder dogfood utilizes a hack to
43+
# synchronize startup script execution.
44+
touch /tmp/.coder-startup-script.done
45+
46+
if [ -x /mnt/home/coder/personalize ]; then
47+
echo "🎨 Personalizing environment..."
48+
/mnt/home/coder/personalize
49+
fi
50+
}
51+
52+
install_ssh_config
53+
install_dotfiles
54+
personalize

0 commit comments

Comments
 (0)
0