Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions .devcontainer/devcontainer.json

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.env
/projects/*
!/projects/.template
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# VS Code Dev Container Playground

This repository keeps a minimal VS Code Dev Container setup that runs on top of Docker. With parameterized environment variables consumed by `.devcontainer/devcontainer.json`, the same workflow can prepare a baseline container environment for different development needs.
This repository provides a template-based workflow for VS Code Dev Containers. Shared settings live under `compose-base/`, and each local dev container is created by copying `projects/.template/` into `projects/`.

## Getting Started

Prerequisites: Docker is available on the host, and VS Code has the `ms-vscode-remote.remote-containers` extension installed.

1. Download the repository (e.g., `git clone https://github.com/iplaylf2/vscode-container.git`).
2. Set the required environment variables (for example `VSCODE_CONTAINER_PROJECT`, `DOCKER_FILE_PATH`, `SDK_VERSION`).
3. Open the folder in VS Code and run `Dev Containers: Reopen in Container`.
2. Copy `projects/.template/` to `projects/<your-project-name>`.
3. Edit `projects/<your-project-name>/docker-compose.yaml` as needed.
4. Set `VSCODE_CONTAINER_PROJECT` in the host environment that will launch VS Code.
5. Open `projects/<your-project-name>` in VS Code and run `Dev Containers: Reopen in Container`.

After the container is created, VS Code reopens the workspace inside the container. When the volume is freshly created, that directory starts empty.
After the container is created, VS Code opens the workspace at `/mnt/${VSCODE_CONTAINER_PROJECT}`. The data lives in a Docker volume named `${VSCODE_CONTAINER_PROJECT}`.

## Configuration Notes

- `VSCODE_CONTAINER_PROJECT` controls both the Docker volume name and the `/mnt/<project>` path inside the container.
- Keep `DOCKER_FILE_PATH` and `SDK_VERSION` as environment variables so switching Dockerfiles or toolchains only requires updating those values.
- The default container user is `vscode`; `postCreateCommand` ensures that account owns the workspace directory.
- `VSCODE_CONTAINER_PROJECT` provides the project identity (volume name and `/mnt/<project>` path); it is an environment variable because `devcontainer.json` cannot pass variables into Docker Compose.
12 changes: 12 additions & 0 deletions compose-base/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: ${VSCODE_CONTAINER_PROJECT}

services:
devcontainer:
build:
context: ..
volumes:
- devcontainer-workspace:/mnt/${VSCODE_CONTAINER_PROJECT}

volumes:
devcontainer-workspace:
name: ${VSCODE_CONTAINER_PROJECT}
11 changes: 11 additions & 0 deletions projects/.template/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "${localEnv:VSCODE_CONTAINER_PROJECT}",
"dockerComposeFile": [
"../../../compose-base/docker-compose.yaml",
"../docker-compose.yaml"
],
"service": "devcontainer",
"workspaceFolder": "/mnt/${localEnv:VSCODE_CONTAINER_PROJECT}",
"postCreateCommand": "sudo chown vscode ${containerWorkspaceFolder}",
"overrideCommand": true
Comment on lines +9 to +10
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Consider adding remoteUser property for clarity.

While the postCreateCommand implies the container uses the vscode user, explicitly specifying "remoteUser": "vscode" would make the configuration clearer and ensure VS Code connects as the intended user.

🔎 Proposed enhancement
 	"postCreateCommand": "sudo chown vscode ${containerWorkspaceFolder}",
-	"overrideCommand": true
+	"overrideCommand": true,
+	"remoteUser": "vscode"
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"postCreateCommand": "sudo chown vscode ${containerWorkspaceFolder}",
"overrideCommand": true
"postCreateCommand": "sudo chown vscode ${containerWorkspaceFolder}",
"overrideCommand": true,
"remoteUser": "vscode"
}
🤖 Prompt for AI Agents
In @projects/.template/.devcontainer/devcontainer.json around lines 9 - 10, The
devcontainer.json uses "postCreateCommand": "sudo chown vscode
${containerWorkspaceFolder}" and relies on the vscode user implicitly; add an
explicit "remoteUser": "vscode" property to the devcontainer configuration so VS
Code connects as that user, keeping "postCreateCommand" and "overrideCommand"
intact; update the JSON to include remoteUser so the intended user is clear and
connection behavior is consistent.

}
9 changes: 9 additions & 0 deletions projects/.template/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
services:
devcontainer:
# Base settings come from ../../compose-base/docker-compose.yaml via dockerComposeFile.
build:
# Pick the Dockerfile that matches your dev environment.
dockerfile: images/base/Dockerfile
args:
# Optional: toolchain version for Dockerfiles that accept SDK_VERSION.
SDK_VERSION: 0
Loading