Feature request: clone repository into Docker volume with `devcontainer up`
Right now it seems the only way to start a dev container is to have cloned a repository and then pass the --workspacefolder to each invocation of devcontainer.
Would it be possible to add a feature that clones a repository in a Docker volume or uses an existing repository that was cloned in a Docker volume to run devcontainer commands on?
By way of alternatives, what we do today is create a repository clone script that fetches a repo and checks out a branch:
#! /bin/bash -ex
if [ ! -d .git ] ; then
git init
git remote add origin $1
git fetch
git checkout $2
fi
We use workspaceMount in devcontainer.json to attach a volume to the container:
"workspaceMount": "source=my-build-data,target=/workspace,type=volume"
And a postCreateCommand to ensure the repository gets cloned:
"postCreateCommand": [
"/root/clone-workspace.sh",
"[email protected]:feldspar/anf-toolbox.git",
"develop"
],
You could try creating your own clone feature by taking that script and replacing the argument variables with feature property variables. Once you've published it, reference the feature with your repo and branch as property values.
I realized that I made the unfortunate mistake of confusing a devcontainer feature with a "new feature for the dev container CLI". What I suggested is for the former, sorry about that.
The Dev Containers extension for VS Code adds this functionality on top of devcontainer up by passing a modified config with --override-config.
+1 on this. Our use case is for developers that work in multiple dependent repos. Many of our developers work exclusively in our main app repo which has a devcontainer.json and we clone into a volume for performance. Some more of our developers run the app from within the main repo to support development in their own repos. We would like those developers to be able to run devcontainer up and point --workspaceFolder at the github URL for the main repo and have it cloned into a docker volume so they can have the app running locally with all the performance benefits and without having to manage yet another repo clone on their machines.
This would also be really useful in CI, and cases when the CI runner is docker (and you are using docker-outside-docker).
Currently I'm in a container, and it wants to volume mount a folder, but the docker 'host' is remote, in a different container, so bind mounts fail.
It's also pretty confusing to debug, files that exist in the act/CI container, but dev containers say the mounts fail.
By passing a git url, it would make it nice and easy to spin up a devcontainer in CI, to run the same make commands.