Describe The Issue
So I am playing around with VS Code Remote Container extension to setup my app development environment.
I was able to set it up ok and it is working great! However, it seems it can't detect the git repo inside the container?
So the reason, I think, why it didn't detect the git repo is the worktree in the git config is still pointing to my hosts machine path.
So is there anything I can do to make the worktree dynamically change to pointing now into the path inside the container? Been googling about this problem with no success.
Configuration
Below is my setup
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"
}
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:
Thanks in advance.
Note
Reason why I used node:12-stretch on my image on docker-compose.yml file is if I use node:12-alpine, it does not have git installed with it, so now VS Code complains of not having git installed.
node:12-stretch image have git pre-installed in it
I do wish to use node:12-alpine tho if I can coz I want to mimic the prod env which this dev env is going to be deployed. Hope you guys can help me with that as well.
Cheers.
Env
- Docker Desktop Version 2.3.0.3 (Using WSL 2 based engine)
- Windows 10 Pro Version 2004