-
Notifications
You must be signed in to change notification settings - Fork 207
Add devcontainer configuration to reduce Copilot agent build time from 5+ minutes to under 1 minute #4342
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
Merged
trask
merged 13 commits into
main
from
copilot/fix-6303a14d-75a1-4bc8-a768-8d2497ff6a51
Jul 17, 2025
Merged
Add devcontainer configuration to reduce Copilot agent build time from 5+ minutes to under 1 minute #4342
Changes from 4 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
0853c54
Initial plan
Copilot 215ed2b
Add devcontainer configuration for faster Copilot agent builds
Copilot 180dedd
Address PR feedback: simplify devcontainer setup and remove redundant…
Copilot 3593679
Remove redundant GRADLE_OPTS export since it's already set in contain…
Copilot 7c265e5
Move devcontainer.json to standard .devcontainer directory
Copilot a541c37
Move devcontainer scripts and documentation to .devcontainer directory
Copilot f7de410
Address PR feedback: Add volume mount for Gradle cache, rename README…
Copilot 52b5775
Remove redundant GRADLE_OPTS and improve Gradle wrapper description
Copilot 67b3f81
Address PR feedback: remove README.md and validate script, simplify d…
Copilot 6bec43b
Remove setup script and postCreateCommand as requested in PR feedback
Copilot 118b51c
up
trask cc908f9
up
trask d901951
up
trask File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # Devcontainer Setup for Application Insights Java | ||
|
|
||
| This devcontainer configuration is designed to optimize the development environment for GitHub Copilot agents by pre-installing tools and dependencies to reduce build time from over 5 minutes to under 1 minute. | ||
|
|
||
| ## What's Included | ||
|
|
||
| - **Java 17 (Temurin)**: Pre-installed Java Development Kit | ||
| - **Gradle 8.11.1**: Pre-installed build tool matching project requirements | ||
| - **Docker in Docker**: For containerized smoke tests | ||
| - **VS Code Extensions**: Java development extensions | ||
|
|
||
| ## Setup Process | ||
|
|
||
| The `setup-devcontainer.sh` script performs the following optimizations: | ||
|
|
||
| 1. **Pre-compiles buildSrc**: Avoids recompilation during regular builds | ||
| 2. **Downloads Gradle wrapper**: Ensures Gradle is immediately available | ||
| 3. **Caches dependencies**: Pre-downloads common dependencies for faster builds | ||
| 4. **Optimizes JVM settings**: Configures Gradle with appropriate memory settings | ||
|
|
||
| ## Usage | ||
|
|
||
| This devcontainer is automatically used by GitHub Copilot agents when working on this repository. The configuration is located at `.github/devcontainer.json` as per GitHub's requirements. | ||
|
|
||
| ## Validation | ||
|
|
||
| Run `.github/scripts/validate-devcontainer.sh` to verify the setup is working correctly. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| { | ||
| "name": "Application Insights Java Development Environment", | ||
| "image": "mcr.microsoft.com/vscode/devcontainers/java:17-bullseye", | ||
| "features": { | ||
| "ghcr.io/devcontainers/features/java:1": { | ||
| "version": "17", | ||
| "jdkDistro": "tem" | ||
| }, | ||
| "ghcr.io/devcontainers/features/docker-in-docker:2": { | ||
| "version": "latest" | ||
| } | ||
| }, | ||
| "customizations": { | ||
| "vscode": { | ||
| "extensions": [ | ||
| "vscjava.vscode-java-pack", | ||
| "vscjava.vscode-gradle", | ||
| "ms-vscode.vscode-json" | ||
| ] | ||
| } | ||
| }, | ||
| "containerEnv": { | ||
| "GRADLE_OPTS": "-Dorg.gradle.daemon=true -Dorg.gradle.parallel=true -Dorg.gradle.caching=true -XX:MaxMetaspaceSize=512m" | ||
| }, | ||
| "postCreateCommand": "bash .github/scripts/setup-devcontainer.sh", | ||
| "remoteUser": "vscode", | ||
trask marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "// comment": "This devcontainer pre-installs Java 17 and Docker-in-Docker. The remoteUser sets the default user for the container. The setup script builds the project to pre-download dependencies and populate the build cache, reducing initial build time for Copilot agents from 5+ minutes to under 1 minute" | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #!/bin/bash | ||
| set -e | ||
|
|
||
| echo "Setting up ApplicationInsights-Java development environment..." | ||
|
|
||
| # GRADLE_OPTS is already set via containerEnv in devcontainer.json | ||
|
|
||
| # Pre-download Gradle wrapper and dependencies | ||
| echo "Pre-downloading Gradle wrapper and dependencies..." | ||
| ./gradlew --version | ||
|
|
||
| # Build project to download dependencies and populate build cache | ||
| echo "Building project to download dependencies and populate build cache..." | ||
| ./gradlew build --quiet || true | ||
|
|
||
| echo "Development environment setup complete!" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| #!/bin/bash | ||
| # Validation script to verify devcontainer setup is working | ||
|
|
||
| set -e | ||
|
|
||
| echo "Validating devcontainer setup..." | ||
|
|
||
| # Check Java version | ||
| echo "Java version:" | ||
| java -version | ||
|
|
||
| # Check Gradle version | ||
| echo -e "\nGradle version:" | ||
| ./gradlew --version | ||
|
|
||
| # Test a simple Gradle command | ||
| echo -e "\nTesting Gradle daemon is running..." | ||
| ./gradlew help --quiet | ||
|
|
||
| # Test that buildSrc is compiled | ||
| echo -e "\nTesting buildSrc is compiled..." | ||
| ./gradlew :buildSrc:tasks --quiet > /dev/null | ||
|
|
||
| # Test a simple module build | ||
| echo -e "\nTesting agent-bootstrap build..." | ||
| ./gradlew :agent:agent-bootstrap:build -x test --quiet | ||
|
|
||
| echo -e "\nDevcontainer setup validation complete!" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.