Comments (2)
I hacked together a solution which works within coder using bash and jq that extracts the stuff and puts it into a settings.json file. I will share it as soon as I am at home.
from envbuilder.
Ran into this as well but while I was trying to add extensions through customizations.vscode.extensions
Would be great to get this functionality native but in the meantime I whipped up a startup script that applies the customizations using python.
startup_script = <<-EOT
curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server
code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 &
# for whatever reason the /tmp code-server doesn't install plugins where we want, find the correct code-server
export PATH="$${HOME}/.vscode-server/bin/${"$"}( ls $${HOME}/.vscode-server/bin*)/bin/:$${PATH}"
# we typically only work on one repo per workspace, use the git folder to find repo
cd /workspaces/*/.git/..
# Parse devcontainer.json and apply settings and extensions using Python
python3 -c "
import json, os, sys
# Define the possible paths for the devcontainer.json file
POSSIBLE_PATHS = ['.devcontainer.json', '.devcontainer/devcontainer.json']
# Find the actual path of the devcontainer.json file
DEVCONTAINER_FILE = None
for path in POSSIBLE_PATHS:
if os.path.isfile(path):
DEVCONTAINER_FILE = path
break
if not DEVCONTAINER_FILE:
print('devcontainer.json file not found in the expected locations.')
sys.exit(1)
# Load the devcontainer.json file
with open(DEVCONTAINER_FILE) as f:
data = json.load(f).get('customizations',{}).get('vscode',{})
# Apply VS Code extensions
extensions = data.get('extensions', [])
if extensions:
for extension in extensions:
print(f'Installing extension: {extension}')
os.system(f'code-server --install-extension {extension}')
else:
print(f'No extensions found in {DEVCONTAINER_FILE}')
# Apply VS Code settings
settings = data.get('settings', {})
if settings:
CONFIG_DIR = '$${HOME}/.vscode-server/data/Machine'
os.makedirs(CONFIG_DIR, exist_ok=True)
with open(f'{CONFIG_DIR}/settings.json', 'w') as f:
json.dump(settings, f, indent=4)
print('VS Code settings applied.')
else:
print(f'No settings found in {DEVCONTAINER_FILE}')
"
code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 &
EOT
I had a version of this working in bash locally with grep and sed, but couldn't get it through terraform without it getting mangled. If someone doesn't work in python I imagine you could get around it by putting the bash script in a configmap, mounting it to all workspaces and adding it as a part of the startup script, but I mostly work in python so this does the job for me.
from envbuilder.
Related Issues (20)
- Dev Containers: Support volume mounts of devcontainer spec HOT 2
- Dev Containers: Script init and Entrypoint
- Error running devcontainer with container registry kubernetes secret volume mounted HOT 2
- Add support for feature order definition in devcontainer definitions
- usability: fix ownership of Docker volume mounts to /home HOT 1
- coder/kaniko: support multi-stage builds with DoCacheProbe HOT 1
- devcontainer: support multi-stage build with dangling build stage
- devcontainer: support docker-compose
- Implement devcontainer-lock.json
- Envbuilder create git repo folder with a trailing `.git`
- bug: lifecycle script `OnCreateCommand` is not executed.
- coder/kaniko: support caching ENV and ARG directives HOT 1
- Stop using deprecated codersdk.LogsSender function
- 401 error for requests to coder.example.com after "Update" option following template change HOT 3
- question: Ability to add features and/or modify feature parameters HOT 3
- feat: Add a way to select a specific branch before building the devcontainer HOT 2
- kubernetes: build with an initContainer or a Job HOT 2
- envbuilder - pass ssh key HOT 1
- envbuilder: fetch upstream changes from repo if local copy is not dirty HOT 5
- Add support for starting envbuilder from a built image
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from envbuilder.