当前位置: 首页 > news >正文

数值计算引擎:搭建远程容器开发环境

Build VS Code Remote Docker Development Environment

大型CAE软件开发技术栈通常依赖多个第三方库,因此从零开始配置开发、编译、运行等环境通常较为繁琐。但随着公司的发展壮大,却经常需要为新加入的成员配备相应的开发环境;另外,有时候也需要为软件多个不同配置准备相应的环境。这种重复性的工作会消耗团队许多时间成本。

由于容器提供了轻量级的、独立的运行环境,可以考虑将软件开发、编译、运行等环境打包成镜像,然后根据需要生成对应的容器即可。而且,VS Code Remote Developement 插件也提供了针对远程容器的开发支持。

本文以数值仿真引擎开发环境为例记录搭建VS Code远程容器开发环境的流程。

一、服务器端配置

1.1. 下载、配置Docker Desktop

下载并安装Docker Desktop,配置容器镜像位置及镜像源,

{"builder": {"gc": {"defaultKeepStorage": "20GB","enabled": true}},"experimental": false,"registry-mirrors": ["https://registry.docker-cn.com","http://hub-mirror.c.163.com","https://docker.mirrors.ustc.edu.cn","https://dockerhub.azk8s.cn","https://mirror.ccs.tencentyun.com","https://registry.cn-hangzhou.aliyuncs.com","https://docker.mirrors.ustc.edu.cn"]
}

1.2 拉取镜像

docker pull intel/oneapi-hpckit

1.3 生成容器

docker run -itd -p 10022:22 -v /D/Docker/DockerShare:/data --name yqdev01 intel/oneapi-hpckit

1.4 配置容器

运行以下命令,进入容器,

docker exec -it yqdev01 /bin/bash
1.4.1 配置系统镜像源

修改/etc/apt/sources.list文件,增加以下镜像源,

deb https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiversedeb https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiversedeb https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse# deb https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiversedeb https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
1.4.2 安装文本编辑器vim
apt-get install vim
1.4.3 配置SSH服务
apt-get update
apt-get install openssh-server
apt-get install openssh-client
apt-get install ssh

修改sshd配置文件,

vim /etc/ssh/sshd_config

重新启动ssh服务,并将其设为开机自启,

/etc/init.d/ssh restart
1.4.4 安装常用第三方库

安装以下常用第三方库,

build-essential  libgtest-dev libhdf5-serial-dev libeigen3-dev libarpack2-dev petsc-dev

修改配置文件以配置Intel oneAPI环境变量,

vim ~/.bashrc

1.4.5 重新启动容器

Ref. from Developing a Visual Studio Code Project for SSH Development 

It is important to note that the VSCode backend server continues to run after you close the Remote-SSH connection. Therefore, the VSCode backend will not see any changes you make to the vscode-remote-ssh-env-setup.sh script unless the remote VSCode backend is forced to exit.

1.4.6 打包容器镜像

二、客户端配置

2.1 VS Code配置

下载VS Code,然后安装以下插件,便可通过Remote Development插件在Remote Docker Container中进行开发了。

Task Explorer

Output Colorizer

Git Extension Pack

Remote Developement

Remote X11

C/C++ Extension Pack

C++ TestMate

Modern Fortran

FORTRAN InstelliSense

Fortran Breakpoint Support

Extension Pack for Intel Software Developer Tools

2.2 连接Remote Docker Container

VS Code内添加远程主机配置,便可以通过Remote Development插件远程开发了。

Host yqdev01HostName 192.168.0.100Port 10022User rootForwardAgent yes

附录I:CMake Presets for VS Code

{"version": 4,"configurePresets": [{"name": "linux_default","hidden": true,"displayName": "Default Linux Config","description": "Default build using Unix Makefiles generator","generator": "Unix Makefiles","binaryDir": "${sourceDir}/out/build/${presetName}","cacheVariables": {"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}","CMAKE_BUILD_TYPE": "Debug"            }}]
}

参考资料

Docker Desktopicon-default.png?t=N7T8https://www.docker.com/products/docker-desktop

Kubernetesicon-default.png?t=N7T8https://kubernetes.io/

VS Code Remote Developmenticon-default.png?t=N7T8https://code.visualstudio.com/docs/remote/remote-overview

Using Visual Studio Code* to Develop Intel® oneAPI Applicationsicon-default.png?t=N7T8https://www.intel.com/content/www/us/en/docs/oneapi/user-guide-vs-code/2024-2/overview.html

CMake Presetsicon-default.png?t=N7T8https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html


http://www.mrgr.cn/news/1851.html

相关文章:

  • 【数据结构】关于冒泡排序,选择排序,插入排序,希尔排序,堆排序你到底了解多少???(超详解)
  • 蒟蒻的尊严被打得一败涂地17
  • QT翻金币小游戏(含音频图片文件资源)
  • 探索数字媒体产业园区的未来之路
  • 每日OJ_牛客_反转部分单向链表
  • 二叉树详解(1)
  • [星瞳科技]OpenMV有哪些合适的配件?
  • 【网络】UDP和TCP之间的差别和回显服务器
  • VSCode插件离线安装
  • 负载均衡详解
  • SDK游戏盾有什么作用?APP被攻击使用游戏盾SDK如何防护?
  • Spring Security之登录跳转
  • 【1.0】vue3的创建
  • LMA——基于 LM 的游戏和挑战代理架构探索
  • 设计模式-中介者模式
  • Monaco Editor组件使用详解
  • 记录一次搭建uniapp-vue3的基础项目
  • HCIE冲刺-----------论述解析
  • 【音视频 | YUV格式】深入理解 YUV 数据格式,一文弄懂
  • 双向链表复习(C语言版)