Skip to content

Conversation

@neekolas
Copy link
Contributor

@neekolas neekolas commented Apr 18, 2025

tl;dr

  • Adds devcontainer configuration that allows the container to access Docker on the host machine

Give it a try. I could use feedback. I am able to run all the tests from inside the container, and VSCode works normally for me.

TODO

  • I need to figure out how to pass through Graphite configuration to the devcontainer
  • Ideally we would not use host networking at all, and have all containers use docker internal networking. That's a bigger refactor

Summary by CodeRabbit

  • New Features

    • Introduced a development container configuration for Go projects, including pre-installed tools and VS Code extensions for enhanced development experience.
    • Added a custom Dockerfile to set up Go development tools and utilities such as golangci-lint, shellcheck, and jq.
    • Provided a Bash script for streamlined Docker Compose management with environment variable support.
  • Chores

    • Updated Docker Compose configuration to allow customizable Prometheus configuration file paths using environment variables.

@neekolas neekolas requested a review from a team as a code owner April 18, 2025 22:37
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 18, 2025

Walkthrough

A development container configuration for Go projects has been introduced, including a new .devcontainer/devcontainer.json and a custom Dockerfile for the container environment. The Dockerfile installs additional development tools such as golangci-lint, shellcheck, and jq. A new Bash script for running Docker Compose with preset options and environment variables has been added. The Docker Compose YAML has been updated to use an environment variable for the Prometheus configuration file path, allowing greater flexibility in specifying its location.

Changes

File(s) Change Summary
.devcontainer/devcontainer.json Added configuration for a Go development container, specifying build context, Dockerfile, environment variables, VS Code settings, extensions, and post-create commands.
dev/docker/devcontainer.Dockerfile New Dockerfile for the development container, based on VS Code Go image, installs golangci-lint, shellcheck, and jq.
dev/docker/compose Added a Bash script to run docker compose with a specific YAML file, environment file, and project name, forwarding additional arguments.
dev/docker/docker-compose.yml Updated Prometheus service volume mount to use an environment variable (HOST_DOCKER_DEV_FOLDER) for the config file path.

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant VSCode
    participant DevContainer
    participant Docker
    participant Host

    Developer->>VSCode: Open project with devcontainer config
    VSCode->>Docker: Build devcontainer using devcontainer.Dockerfile
    Docker->>DevContainer: Start container with specified environment
    DevContainer->>DevContainer: Run post-create command (go mod tidy)
    VSCode->>DevContainer: Install extensions (Go, SQLTools, etc.)
    Developer->>DevContainer: Develop using Go tools and extensions
    Developer->>Host: Run dev/docker/compose script
    Host->>Docker: Execute docker compose with env and config
    Docker->>DevContainer: Mount Prometheus config using env variable
Loading

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@macroscopeapp
Copy link

macroscopeapp bot commented Apr 18, 2025

Configure VS Code development environment by adding DevContainer setup with Go 1.24, Docker integration, and standardized tooling

  • Introduces VS Code DevContainer configuration in devcontainer.json with Go development environment, Docker integration, and preconfigured extensions
  • Creates development container Dockerfile in devcontainer.Dockerfile based on Go 1.24 with golangci-lint, shellcheck, and jq tools
  • Adds Docker Compose wrapper script compose for standardized container orchestration
  • Updates Prometheus service volume mount in docker-compose.yml to use environment variable path

📍Where to Start

Start with the DevContainer configuration in devcontainer.json which defines the core development environment setup and references the other new files.


Macroscope summarized 8e6d3ed.

@neekolas neekolas requested review from Copilot and removed request for a team April 18, 2025 22:37
Copy link

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 pull request adds a DevContainer configuration that allows the container to access Docker on the host machine.

  • Updates the volume mapping in docker-compose.yml to use an environment variable for the host folder.
  • Prepares a configuration that supports in-container testing and development via VSCode.
Files not reviewed (3)
  • .devcontainer/devcontainer.json: Language not supported
  • dev/docker/compose: Language not supported
  • dev/docker/devcontainer.Dockerfile: Language not supported

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (6)
dev/docker/docker-compose.yml (1)

33-33: Validate Prometheus config path and enforce HOST_DOCKER_DEV_FOLDER.
The fallback ${HOST_DOCKER_DEV_FOLDER:-.} may resolve to an unintended directory if the environment variable is not set. Consider requiring HOST_DOCKER_DEV_FOLDER or updating the fallback to a known path (e.g., $PWD/dev/docker) to prevent silent misconfiguration.

dev/docker/devcontainer.Dockerfile (2)

4-4: Pin and verify the golangci-lint installer source for reproducibility.
Downloading the install script from HEAD can introduce unpredictability; pin to a tagged commit or add checksum verification to ensure the exact v2.0.2 binary and guard against upstream changes.


7-9: Optimize image layer size and caching.
Combine apt-get update and install into a single RUN, add --no-install-recommends, and clean up apt caches to reduce image bloat:

RUN apt-get update && \
    apt-get install -y --no-install-recommends shellcheck jq && \
    rm -rf /var/lib/apt/lists/*
dev/docker/compose (1)

4-7: Handle missing dev/local.env and ensure executability.
Add a guard to verify that dev/local.env exists before passing it to --env-file and confirm the script is marked executable (chmod +x dev/docker/compose):

if [ ! -f dev/local.env ]; then
  echo "Error: dev/local.env not found." >&2
  exit 1
fi
.devcontainer/devcontainer.json (2)

26-26: Reconsider using host networking for the devcontainer.
--network=host reduces isolation and can introduce security risks. As noted, migrating to Docker’s bridge/internal networks is preferable—consider removing this once you tackle the larger refactor.


28-30: Pin the Docker feature version for stability.
Using docker-outside-of-docker:1 may bring in minor updates unexpectedly. Consider specifying a more granular tag (e.g., :1.0.0) to lock the feature version for reproducible builds.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3a7c641 and 8e6d3ed.

📒 Files selected for processing (4)
  • .devcontainer/devcontainer.json (1 hunks)
  • dev/docker/compose (1 hunks)
  • dev/docker/devcontainer.Dockerfile (1 hunks)
  • dev/docker/docker-compose.yml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Push Docker Images to GitHub Packages (xmtpd-cli)
  • GitHub Check: Test (Node)
  • GitHub Check: Upgrade Tests
  • GitHub Check: Push Docker Images to GitHub Packages (xmtpd)
🔇 Additional comments (2)
.devcontainer/devcontainer.json (2)

3-8: Validate build context and Dockerfile path resolution.
Ensure that "context": ".." and "dockerfile": "../dev/docker/devcontainer.Dockerfile" correctly resolve in single-root and multi-root scenarios so the Dockerfile is always found.


9-9:

Details

❓ Verification inconclusive

Verify property for container environment variables.
The key remoteEnv may not inject variables into the container; the devcontainer specification uses containerEnv. Please confirm or switch to containerEnv to ensure LOCAL_WORKSPACE_FOLDER and HOST_DOCKER_DEV_FOLDER are set.


🌐 Web query:

Does VS Code devcontainer.json support `remoteEnv` or `containerEnv` for setting container environment variables?

💡 Result:

Yes, Visual Studio Code's devcontainer.json file supports both containerEnv and remoteEnv properties for setting environment variables in development containers.

Comparison: containerEnv vs. remoteEnv

Property Scope When to Use Update Behavior
containerEnv Sets variables for the entire container (all processes) For variables all processes need, or when static values Requires a full container rebuild to change
remoteEnv Sets variables only for VS Code server/sub-processes For variables needed just by VS Code or its sub-tools Can be updated by relaunching VS Code server

Details

  • containerEnv:

    • Sets or overrides environment variables for the entire container.
    • Variables are accessible to any process inside the container.
    • The variables are static for the container's life—updating them requires a container rebuild.
    • Use for application-wide or system-wide environment variables[1][2][3][5].
  • remoteEnv:

    • Sets or overrides environment variables only for VS Code server and supporting processes (terminals, tasks, debuggers, etc.).
    • These do not affect processes running directly in the container outside the VS Code environment.
    • Values can be changed more dynamically, usually requiring only a server process restart, not a container rebuild[1][3][5].
    • Useful for customizing the environment specifically for your development tools[1][3][5].

Examples

// In devcontainer.json
"containerEnv": {
  "DATABASE_URL": "postgresql://user:password@db:5432/mydb",
  "NODE_ENV": "development"
},
"remoteEnv": {
  "PATH": "${containerEnv:PATH}:/custom/bin",
  "JAVA_HOME": "/docker-java-home"
}
  • In this example, DATABASE_URL and NODE_ENV will be available to all container processes.
  • PATH (with the custom addition) and JAVA_HOME will affect only VS Code and its related tools[1][3][5].

Recommendations

  • Prefer containerEnv for variables needed container-wide.
  • Use remoteEnv for variables required only by VS Code or when you want to avoid rebuilding the container for each change[2][3][5].
  • If you use Docker Compose, only remoteEnv is supported in devcontainer.json. For container-wide variables in that case, use the environment property in your docker-compose.yml[1].

Key Documentation and References

  • [Visual Studio Code: Environment variables in dev containers][1]
  • [Dev Container specification: containerEnv vs remoteEnv][3][5]

In summary, both containerEnv and remoteEnv are officially supported for setting environment variables in a VS Code development container, each serving different scopes and update mechanisms[1][3][5].

Citations:


Clarify environment variable scope in devcontainer.json
The remoteEnv property is valid but only injects variables into the VS Code server and its sub‑processes (terminals, tasks, debuggers). It does not affect other processes running in the container. In contrast, containerEnv sets environment variables container‑wide (all processes) but requires a full rebuild to take effect.

Please confirm your intended scope for LOCAL_WORKSPACE_FOLDER and HOST_DOCKER_DEV_FOLDER and adjust accordingly:

  • If you need these variables in all container processes (application code, build scripts, Docker Compose services), move them to containerEnv.
  • If you only need them for VS Code’s integrated tools (terminals, debug sessions), keeping them in remoteEnv is sufficient.

.devcontainer/devcontainer.json (around line 9)

- "remoteEnv": {
-   "LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}",
-   "HOST_DOCKER_DEV_FOLDER": "${localWorkspaceFolder}/dev/docker"
- },
+ // For container‑wide variables (all processes), use:
+ "containerEnv": {
+   "LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}",
+   "HOST_DOCKER_DEV_FOLDER": "${localWorkspaceFolder}/dev/docker"
+ },
+ 
+ // Or retain remoteEnv if only VS Code processes need these:
+ // "remoteEnv": { … }

Comment on lines +1 to +2
#!/bin/bash
set -eo pipefail
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add explicit execution context.
docker compose will look for files relative to the current working directory. To avoid failures when invoked from elsewhere, change into the repo root at the top of the script:

cd "$(dirname "$0")/../.." || exit 1

Copy link
Collaborator

@mkysel mkysel left a comment

Choose a reason for hiding this comment

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

I dont use these but they can't hurt

@neekolas neekolas merged commit f55a1f1 into main Apr 23, 2025
9 checks passed
@neekolas neekolas deleted the add-devcontainer branch April 23, 2025 15:19
@neekolas
Copy link
Contributor Author

I still haven't taken this to a place where I can use it daily (need the Graphite config). But it's a start.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants