Jpl*_*us2 5 git docker visual-studio-code
因此,我正在使用VS Code 远程容器扩展来设置我的应用程序开发环境。
我能够正确设置它并且工作得很好!但是,似乎无法检测到容器内的 git repo?
所以我认为,它没有检测到 git repo 的原因是git 配置中的工作树仍然指向我的主机路径。
那么我可以做些什么来使工作树动态更改为现在指向容器内的路径吗?一直在谷歌上搜索这个问题但没有成功。
下面是我的设置
devcontainer.json
{
"name": "foobar-dev-env",
"dockerComposeFile": "docker-compose.yml",
"extensions": [
// Git
"github.vscode-pull-request-github",
"eamodio.gitlens",
"mhutchie.git-graph",
// Code
"coenraads.bracket-pair-colorizer-2",
"aaron-bond.better-comments",
"streetsidesoftware.code-spell-checker",
"alefragnani.numbered-bookmarks",
"pflannery.vscode-versionlens",
"visualstudioexptteam.vscodeintellicode",
"redhat.vscode-yaml", // YAML
"kumar-harsh.graphql-for-vscode", // GraphQL
// Prettier
"esbenp.prettier-vscode",
// Todo
"gruntfuggly.todo-tree",
"wayou.vscode-todo-highlight",
// Theme
"pkief.material-icon-theme",
"zhuangtongfa.material-theme"
],
"settings": {
"workbench.colorTheme": "One Dark Pro",
"workbench.iconTheme": "material-icon-theme",
"workbench.sideBar.location": "right",
"oneDarkPro.editorTheme": "Onedark Pro",
"oneDarkPro.bold": true,
"oneDarkPro.vivid": true,
"oneDarkPro.italic": false,
"editor.minimap.enabled": false,
"editor.tabSize": 2,
"editor.wordWrapColumn": 120,
"editor.rulers": [120],
"editor.formatOnSave": true,
"[typescript, javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"typescript.updateImportsOnFileMove.enabled": "always",
"javascript.updateImportsOnFileMove.enabled": "always",
"terminal.integrated.shell.linux": "/bin/bash"
},
"service": "app",
"workspaceFolder": "/workspace",
"shutdownAction": "stopCompose"
}
Run Code Online (Sandbox Code Playgroud)
docker-compose.yml
version: "3.3"
services:
app-db:
image: postgres:12
restart: always
environment:
POSTGRES_USER: postgres
POSTGRES_DB: app_db
POSTGRES_PASSWORD: secret
ports:
- 54321:5432
volumes:
- app-db-data:/var/lib/postgresql/data
app:
image: node:12-stretch
restart: always
depends_on:
- app-db
command: /bin/sh -c "while sleep 1000; do :; done"
ports:
- 4000:4000
volumes:
# Mounts the project folder to '/workspace'. The target path inside the container
# should match what your application expects. In this case, the compose file is
# in a sub-folder, so we will mount '..'. You would then reference this path as the
# 'workspaceFolder' in '.devcontainer/devcontainer.json' so VS Code starts here.
- ..:/workspace:cached
volumes:
app-db-data:
Run Code Online (Sandbox Code Playgroud)
提前致谢。
我在 docker-compose.yml 文件上的图像上使用 node:12-stretch 的原因是,如果我使用 node:12-alpine,它没有安装 git,所以现在 VS Code 抱怨没有安装 git。
node:12-stretch 镜像中预装了 git
如果可以的话,我确实希望使用node:12-alpine,因为我想模仿将要部署此开发环境的产品环境。希望你们也能帮助我。
干杯。
今天我在设置中偶然发现了同样的问题:
正如您所提到的,存储库内的 git 配置文件中有一个绝对 win 路径,这会导致容器内的代表失败。
我的解决方法是,使该路径相对,因此源代码管理现在可以在 docker 容器内运行。
这是我的配置:
.git/配置
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
worktree = ../
symlinks = false
ignorecase = true
Run Code Online (Sandbox Code Playgroud)
devcontainer.json
{
"name": "Tensorflow GPU",
"dockerFile": "Dockerfile",
"settings": {
"git.path": "/usr/bin/git"
},
"extensions": [
"ms-python.python"
]
}
Run Code Online (Sandbox Code Playgroud)
Dockerfile
FROM tensorflow/tensorflow:latest-gpu
RUN apt-get update && apt-get install -y git
Run Code Online (Sandbox Code Playgroud)
PS:不幸的是,使用这种方法,本地存储库会被吓坏,并希望您在离开容器后提交所有文件
| 归档时间: |
|
| 查看次数: |
8718 次 |
| 最近记录: |