Skip to content

Add devcontainer configuration#129

Open
dracco1993 wants to merge 11 commits into
wpilibsuite:mainfrom
dracco1993:add-devcontainer
Open

Add devcontainer configuration#129
dracco1993 wants to merge 11 commits into
wpilibsuite:mainfrom
dracco1993:add-devcontainer

Conversation

@dracco1993
Copy link
Copy Markdown

Description

Add configuration for docker vscode devconatienr

BONUS:

  • Add .dockerignore to decrease synced file traffic and improve performance when using docker
  • Add .gitattributes to tell git to use the correct linefeeds, regardless of platform
  • Add .github/PULL_REQUEST_TEMPLATE.md to maintain a reasonable standard for PRs
    • This was shamelessly pulled from another project I help work on, The Blue Alliance (template)
    • It doesn't have anything to do with the rest of this PR, so I can pull it out if desired; I really just included it as a potential starting point

Motivation and Context

It helps makes development more straight forward for new contributors.


VsCode devContainer:

Bottom left, click the blue "Open a Remote Window" icon:
image
Next click "Reopen in Container":
image


GitHub Codespaces:

This configuration also allows for 1-click style setup using GitHub Codespaces!
After clicking the + Codespace button here you'll be up and running!
image

Hosted codespace automatically installs dependencies and starts the project:
image
image

How Has This Been Tested?

Locally, and through GitHub Codespaces.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would change API specifications or require data migrations)

@alan412
Copy link
Copy Markdown
Collaborator

alan412 commented Jun 30, 2025

Thank you for this, but right now we are focused on getting to MVP (minimum viable product) so it can go into the hands of teams for testing.

Until we have that, things are changing so fast that we won't be pulling in PRs for other features. I am keeping this open so that we can look at it after we have an MVP out to teams.

@alan412 alan412 added this to the after_mvp milestone Jun 30, 2025
@alan412 alan412 removed this from the after_mvp milestone Jun 30, 2025
Copilot AI review requested due to automatic review settings April 4, 2026 14:22
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a VS Code devcontainer + Docker Compose setup to streamline local development and enable GitHub Codespaces usage, along with a few repo hygiene files to standardize contributions and git behavior.

Changes:

  • Add .devcontainer/ configuration (Dockerfile, compose, devcontainer.json) to support containerized development.
  • Update Vite dev server configuration to be reachable from outside the container.
  • Add supporting repo files: .dockerignore, .gitattributes, and a GitHub PR template.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
vite.config.mts Makes Vite dev server bind to all interfaces to support container access.
.devcontainer/Dockerfile Defines the container image used for devcontainer/Codespaces.
.devcontainer/compose.yml Defines the app service and workspace mount for devcontainer usage.
.devcontainer/devcontainer.json Configures VS Code devcontainer behavior, extensions, port forwarding, and startup commands.
.dockerignore Reduces Docker build context size by excluding common large/unneeded paths.
.gitattributes Normalizes line endings across platforms.
.github/PULL_REQUEST_TEMPLATE.md Introduces a standardized PR template for contributors.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread vite.config.mts
Comment on lines 27 to 30
server: {
host: true,
port: 3000,
},
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

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

Setting server.host: true makes the dev server bind to all interfaces (0.0.0.0), which can unintentionally expose the app to the local network when running vite outside a container. Consider scoping this to devcontainer/Codespaces only (e.g., conditional on an env var) or explicitly documenting that the dev server will be network-accessible.

Copilot uses AI. Check for mistakes.
Comment thread .devcontainer/compose.yml
Comment on lines +8 to +12
- ..:/app:cached
command: sleep infinity

volumes:
node_modules:
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

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

node_modules is declared as a named volume but never mounted, so dependencies installed via postCreateCommand will land in the bind-mounted workspace and get synced (slow) and can differ by host OS. Mount the named volume at /app/node_modules (or use devcontainer mounts) to keep installs container-local and improve performance.

Copilot uses AI. Check for mistakes.
Comment thread .devcontainer/Dockerfile
@@ -0,0 +1,13 @@
FROM mcr.microsoft.com/devcontainers/typescript-node:18
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

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

The devcontainer base image pins Node 18, but the current dependency tree includes packages that declare Node >= 20 in their engines (see package-lock.json). Using Node 18 can lead to install/runtime failures (or strict engine errors). Please update the devcontainer image to a supported Node LTS that matches the project’s requirements (e.g., 20/22).

Suggested change
FROM mcr.microsoft.com/devcontainers/typescript-node:18
FROM mcr.microsoft.com/devcontainers/typescript-node:20

Copilot uses AI. Check for mistakes.
Comment thread .devcontainer/Dockerfile
Comment on lines +9 to +10
RUN npm install

Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

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

RUN npm install during image build is likely wasted work because compose.yml bind-mounts the workspace over /app, which hides the image’s node_modules. Either mount a dedicated node_modules volume so the build-layer install is usable, or remove the build-time install and rely on postCreateCommand (optionally using npm ci for reproducibility).

Suggested change
RUN npm install

Copilot uses AI. Check for mistakes.
3000
],
"postCreateCommand": "npm install",
"postAttachCommand": "npm run start"
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

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

postAttachCommand runs on every attach/re-attach and may start multiple dev servers (or fail due to port already in use). Prefer postStartCommand (runs once per container start) or add a guard so npm run start only launches if it’s not already running.

Suggested change
"postAttachCommand": "npm run start"
"postStartCommand": "npm run start"

Copilot uses AI. Check for mistakes.
@alan412
Copy link
Copy Markdown
Collaborator

alan412 commented Apr 27, 2026

@dracco1993 - I wanted to make sure you saw that I ran copilot on your PR and it had some suggestions. We are now at a point we could pull this in, if you are still interested. If I haven't heard from you by next week, then I'll close this.

@dracco1993
Copy link
Copy Markdown
Author

dracco1993 commented Apr 27, 2026

@alan412 I hadn't seen that yet; I can check that out and get some changes made.
I'll be in Houston this week for CMP, so I probably won't have time to look at it until I get back. 🙂

@alan412
Copy link
Copy Markdown
Collaborator

alan412 commented Apr 27, 2026

@dracco1993 - @lizlooney and I will also be in Houston volunteering for CMP. Find us if you get a chance. We'll both be at the conference talks on the new control system

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants