-
Notifications
You must be signed in to change notification settings - Fork 0
refactor(devcontainer): Migrate to template-based project structure #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| .env | ||
| /projects/* | ||
| !/projects/.template |
| 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. | ||
| 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} |
| 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Consider adding While the 🔎 Proposed enhancement "postCreateCommand": "sudo chown vscode ${containerWorkspaceFolder}",
- "overrideCommand": true
+ "overrideCommand": true,
+ "remoteUser": "vscode"
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
| } | ||||||||||||||
| 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 | ||
iplaylf2 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Uh oh!
There was an error while loading. Please reload this page.