C
Coder.com•4mo ago
Beast1396

Code-server as feature in devcontainer-cli setup not inheriting Git Credentials injection

Hi all, I'm trying to create a template using the devcontainers-cli module. Coder agent is properly injecting the GIT_ASKPASS to the devcontainer's environment, but when I run a terminal from code-server (installed using the feature version in devcontainer.json), all environment variables are wiped for some reason. The same is not true for the devcontainer terminal launched directly from the Coder UI, which has all the env variables properly. Any idea how I can make sure the same env variables are present in the code-server terminal?
10 Replies
Codercord
Codercord•4mo ago
Codercord
Codercord•4mo ago
<#1409342337800470659>
Category
Help needed
Product
code-server
Platform
Linux
Logs
Please post any relevant logs/error messages.
matifali
matifali•4mo ago
cc: @Danielle
Danielle
Danielle•4mo ago
Hey 👋 Just got a few questions to clarify your setup: - What does your devcontainer.json look like? - Where are your environment variables defined? - Are you using the coder_devcontainer resource, or starting the dev container yourself?
Beast1396
Beast1396OP•4mo ago
THis is the devcontainer.json. Right now the only env variables I'm setting are for configuration of GCloud and Git so they work properly in code server (but they still don't). I've tried also setting GIT_ASKPASS from the localEnv, but that didn't work either. I am using
coder_devcontainer
coder_devcontainer
resource.
{
"name": "Dev Env",
"image": "codercom/enterprise-base:ubuntu",
"features": {
"ghcr.io/coder/devcontainer-features/code-server:1": {
"port": 13337,
"host": "0.0.0.0",
"auth": "none",
},
"ghcr.io/devcontainers/features/node:1": {},
"ghcr.io/devcontainers/features/python:1": {
"installTools": true
},
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/jajera/features/gcloud-cli:1": {}
},
"postCreateCommand": "python3 -m venv .venv && echo 'source /workspaces/**REPONAME**/.venv/bin/activate' >> ~/.bashrc && npm install -g prettier eslint",
"containerEnv": {
"CLOUDSDK_PYTHON": "/usr/local/python/current/bin/python3",
"GIT_AUTHOR_NAME": "${localEnv:GIT_AUTHOR_NAME}",
"GIT_AUTHOR_EMAIL": "${localEnv:GIT_AUTHOR_EMAIL}",
"GIT_COMMITTER_NAME": "${localEnv:GIT_COMMITTER_NAME}",
"GIT_COMMITTER_EMAIL": "${localEnv:GIT_COMMITTER_EMAIL}"
},
"appPort": ["13337:13337"],
"customizations": {
"vscode": {
"settings": {
"workbench.colorTheme": "Default Dark Modern"
}
}
}
}
{
"name": "Dev Env",
"image": "codercom/enterprise-base:ubuntu",
"features": {
"ghcr.io/coder/devcontainer-features/code-server:1": {
"port": 13337,
"host": "0.0.0.0",
"auth": "none",
},
"ghcr.io/devcontainers/features/node:1": {},
"ghcr.io/devcontainers/features/python:1": {
"installTools": true
},
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/jajera/features/gcloud-cli:1": {}
},
"postCreateCommand": "python3 -m venv .venv && echo 'source /workspaces/**REPONAME**/.venv/bin/activate' >> ~/.bashrc && npm install -g prettier eslint",
"containerEnv": {
"CLOUDSDK_PYTHON": "/usr/local/python/current/bin/python3",
"GIT_AUTHOR_NAME": "${localEnv:GIT_AUTHOR_NAME}",
"GIT_AUTHOR_EMAIL": "${localEnv:GIT_AUTHOR_EMAIL}",
"GIT_COMMITTER_NAME": "${localEnv:GIT_COMMITTER_NAME}",
"GIT_COMMITTER_EMAIL": "${localEnv:GIT_COMMITTER_EMAIL}"
},
"appPort": ["13337:13337"],
"customizations": {
"vscode": {
"settings": {
"workbench.colorTheme": "Default Dark Modern"
}
}
}
}
Also this is less important, but code server, whether it's as a module in the terraform (when using EnvBuilder), or as a feature in the devcontainer.json (when using devcontainer-cli), doesn't respect the customization settings that I set in the devcontainer.json (e.g. theme isn't set to Dark Modern).
Danielle
Danielle•4mo ago
I'll take a look at this during my office hours tomorrow, thanks for all the information :thanks:
Beast1396
Beast1396OP•4mo ago
ok thanks. For reference, I'm trying a workaroudn right now to avoid the code-server feature entirely by installing code-server and VS Code Web modules directly in the template so that they're installed in the outer container. The problem is if I want to access the devcontainer with either of those, I need to pass the subagent that's running in the devcontainer to their modules, but I don't see a way to access the subagents id
Danielle
Danielle•4mo ago
at the moment there isn't any way to access the subagent id from within the template Unfortunately I was too busy today to get around to this, I'm hoping I'll have some time tomorrow
tsá
tsá•3mo ago
any update on this?
Danielle
Danielle•3mo ago
I’ve been very busy with other task and haven’t been able to recreate yet in the spare time I’ve had I’m on PTO next week

Did you find this page helpful?