From 1027a37ec5c8c45adf335306d0153550cf3cf14b Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Thu, 26 Jun 2025 12:15:55 +0000 Subject: [PATCH 1/2] feat(devcontainer): install dotfiles if present --- .devcontainer/devcontainer.json | 17 +++++++--- .devcontainer/postCreateCommand.sh | 54 ++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 4 deletions(-) create mode 100755 .devcontainer/postCreateCommand.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index a9339f7e0cf7e..8d16afcda362a 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,7 +1,6 @@ { "name": "Development environments on your infrastructure", "image": "codercom/oss-dogfood:latest", - "features": { // See all possible options here https://github.com/devcontainers/features/tree/main/src/docker-in-docker "ghcr.io/devcontainers/features/docker-in-docker:2": { @@ -13,10 +12,20 @@ } }, // SYS_PTRACE to enable go debugging - "runArgs": ["--cap-add=SYS_PTRACE"], + "runArgs": [ + "--cap-add=SYS_PTRACE" + ], "customizations": { "vscode": { - "extensions": ["biomejs.biome"] + "extensions": [ + "biomejs.biome" + ] } - } + }, + "mounts": [ + // Mount the entire home because conditional mounts are not supported. + // See: https://github.com/devcontainers/spec/issues/132 + "source=${localEnv:HOME},target=/mnt/home/coder,type=bind,readonly" + ], + "postCreateCommand": "./.devcontainer/postCreateCommand.sh" } diff --git a/.devcontainer/postCreateCommand.sh b/.devcontainer/postCreateCommand.sh new file mode 100755 index 0000000000000..320d41dbfbccb --- /dev/null +++ b/.devcontainer/postCreateCommand.sh @@ -0,0 +1,54 @@ +#!/bin/sh + +install_ssh_config() { + echo "🔑 Installing SSH configuration..." + rsync -a /mnt/home/coder/.ssh/ ~/.ssh/ + chmod 0700 ~/.ssh +} + +install_git_config() { + echo "📂 Installing Git configuration..." + if [ -f /mnt/home/coder/git/config ]; then + rsync -a /mnt/home/coder/git/ ~/.config/git/ + elif [ -d /mnt/home/coder/.gitconfig ]; then + rsync -a /mnt/home/coder/.gitconfig ~/.gitconfig + else + echo "⚠️ Git configuration directory not found." + fi +} + +install_dotfiles() { + if [ ! -d /mnt/home/coder/.config/coderv2/dotfiles ]; then + echo "⚠️ Dotfiles directory not found." + return + fi + + cd /mnt/home/coder/.config/coderv2/dotfiles + for script in install.sh install bootstrap.sh bootstrap script/bootstrap setup.sh setup script/setup; do + if [ -x $script ]; then + echo "📦 Installing dotfiles..." + ./$script || { + echo "❌ Error running $script. Please check the script for issues." + return + } + echo "✅ Dotfiles installed successfully." + return + fi + done + echo "⚠️ No install script found in dotfiles directory." +} + +personalize() { + # Allow script to continue as Coder dogfood utilizes a hack to + # synchronize startup script execution. + touch /tmp/.coder-startup-script.done + + if [ -x /mnt/home/coder/personalize ]; then + echo "🎨 Personalizing environment..." + /mnt/home/coder/personalize + fi +} + +install_ssh_config +install_dotfiles +personalize From cdd45ea4ea4b253e64b05aa23522dc9fbe8291af Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Thu, 26 Jun 2025 12:37:55 +0000 Subject: [PATCH 2/2] shellchecked --- .devcontainer/postCreateCommand.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/postCreateCommand.sh b/.devcontainer/postCreateCommand.sh index 320d41dbfbccb..bad584e85bea9 100755 --- a/.devcontainer/postCreateCommand.sh +++ b/.devcontainer/postCreateCommand.sh @@ -23,7 +23,7 @@ install_dotfiles() { return fi - cd /mnt/home/coder/.config/coderv2/dotfiles + cd /mnt/home/coder/.config/coderv2/dotfiles || return for script in install.sh install bootstrap.sh bootstrap script/bootstrap setup.sh setup script/setup; do if [ -x $script ]; then echo "📦 Installing dotfiles..." pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy