I'm trying to create a devcontainer that automatically initializes and updates the submodules when the repository is first cloned.
I have a repository on GitLab with different submodules and a devcontainer.json
file:
.
├── submodule1
├── submodule2
├── submodule3
└── .devcontainer
├── devcontainer.json
└── modules.sh
Content of devcontainer.json
:
{
"name": "Ubuntu",
"image": "mcr.microsoft.com/devcontainers/base:jammy",
"postCreateCommand": "while [ -z \"$(ls ~/.vscode-server/extensions | grep gitlab)\" ] ; do sleep 1 ; done && sh ${containerWorkspaceFolder}/.devcontainer/modules.sh",
"customizations": {
"vscode": {
"extensions": [
"gitlab.gitlab-workflow"
]
}
}
Content of modules.sh
:
#!/bin/sh
git submodule init
git submodule update
Usually, I use the VSCode GitLab Workflow extension because it allows me to avoid in typing the credentials every time I want to commit something.
When I start the container, the postCreateCommand
asks for credentials and blocks for input, while if I launch the git submodule init
and update
commands by hand after the container is launched, it works.
How can I get all the environment autometically configured without requiring git to ask for credential?