0

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?

Jademalo
  • 323
  • 1
  • 8

1 Answers1

0

I haven't found a way to do the specific solution you're asking for, but the main two alternatives to it are:

  1. move VSCode into wsl - you should be able to host VSCode.dev in wsl following something along the following lines. But is VSCode in the browser really a price worth paying?

https://medium.com/geekculture/3-steps-to-code-from-anywhere-45401247f479

  1. The solution I've settled on - to run a Linux VM on your Windows machine and run VSCode inside inside the Linux VM along with docker for the devcontainers. This got me a massive time saving from 2m50s to 7s to spin up a server - it's game changing for me. more details here:

https://stackoverflow.com/a/72787362/183005

Dave Amphlett
  • 1,922
  • 1
  • 15
  • 17