Open geiseri opened 1 year ago
@geiseri if you have the VS Code Dev Containers extension do the customizations automatically install?
I've been using this snippet of code in the devcontainer startup script to install VS Code extensions specified in devcontainer.json
. It's a pretty gross hack and you may well be able to come up with something better, but it might be useful as an example:
if ! which code-server > /dev/null; then
curl -fsSL https://code-server.dev/install.sh | sh | tee code-server-install.log
fi
CODE_CLI=code-server
if code -v > /dev/null; then
CODE_CLI=code
fi
mkdir -p ~/.vscode-server/extensions
set +e
extensions=( $(sed 's/\/\/.*$//g' */.devcontainer/devcontainer.json | jq -r -M '[.customizations.vscode.extensions[]?, .extensions[]?] | .[]' ) )
if [ "$${extensions[0]}" != "" ] && [ "$${extensions[0]}" != "null" ]; then
for extension in "$${extensions[@]}"; do
$CODE_CLI --extensions-dir ~/.vscode-server/extensions --install-extension "$extension"
done
fi
Ended up doing something very similar, would be nice to have this built in
curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.22.0
CODE_CLI=/tmp/code-server/bin/code-server
DEVCONTAINER_JSON=".devcontainer/devcontainer.json"
if [[ -f "$DEVCONTAINER_JSON" ]]; then
EXTENSIONS=$(sed '/^ *\/\//d' "$DEVCONTAINER_JSON" | jq -r '.customizations.vscode.extensions[]?')
if [[ -n "$EXTENSIONS" ]]; then
# Loop over each extension and install it
for EXTENSION in $EXTENSIONS; do
$CODE_CLI --install-extension $EXTENSION
done
fi
fi
$CODE_CLI --auth none --port 13337 >/tmp/code-server.log 2>&1 &
The devcontainer spec has a section that covers the support of VS Code specific properties. I am not sure how reasonable the
customizations.vscode.settings
are for the remote since those are stored in a local user session. (In the case of coder could be in a different volume). This might actually be a better issue for them to solve on that side then. If that is your opinion please feel free to close this issue and I will move it to the coder project.