I've got a VSCode container that I develop in, with my source code on my local windows machine. Compilation times are 10+x slower with this method compared to having the code in a volume, however having the code in a volume makes it much more difficult to develop as accessing build artefacts and manipulating images can't be done as easily.
Currently, I build the code using the following task;
{
"label": "Build",
"type": "shell",
"promptOnClose": true,
"command": "make",
"args": [
"-j$(nproc)"
],
"problemMatcher": [
"$gcc"
]
},
Considering the speed increase building from a volume, one potential solution I can think of is changing this build task to do the following
- Create and mount a new docker volume to house the source code
- Copy the current workspace into that volume
- Build the code using the copy in the volume
- Copy the artefact back into the main workspace
- Unmount and delete the volume
This should be substantially faster than waiting for the compile with the mounted windows folder, though I can't figure out how to do it.
Every bit of information I can find with regards to mounting a docker volume is to do with setting it up in the dockerfile or devcontainer.json, however I want to do this as a task while connected to the container. I can't figure out a way to run commands as the host through a task, so I can't figure out how to send docker commands to mount the volume.
Is there a way to accomplish what I'm trying to do with a task?