VS Code Remote实战: 基于Vagrant搭建开发环境

基于容器还是基于虚拟机效果都差不多,这里以虚拟机为例,真香

安装 Visual Studio Code Insiders

下载链接地址: Visual Studio Code Insiders

扩展

安装完成后需要安装Remote 开发扩展

Remote SSH - Connect to any location by opening folders on a remote machine/VM using SSH.
Remote Containers - Work with a sandboxed toolchain or container-based application inside (or mounted into) a container.

配置VM

启动虚拟机

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|

  config.vm.box = "ysicing/debian"

  config.vm.network "private_network", ip: "10.250.250.250"

  config.vm.network "public_network"

  config.vm.provider "virtualbox" do |vb|
     vb.gui = false
     vb.memory = "1024"
  end

end

方便调试,指定了host模式和桥接模式

配置remote ssh

➜  remote cat ~/.ssh/config
Host 10.250.250.250
    HostName 10.250.250.250
    User root
    IdentityFile /Users/ysicing/.ssh/vscode

最后成品

真香

推荐阅读