Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
27 changes: 27 additions & 0 deletions .github/DEVCONTAINER_README.md
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.
28 changes: 28 additions & 0 deletions .github/devcontainer.json
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",
"// 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"
}
17 changes: 17 additions & 0 deletions .github/scripts/setup-devcontainer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
set -e

echo "Setting up ApplicationInsights-Java development environment..."

# Set up Gradle with proper JVM options
export GRADLE_OPTS="-Dorg.gradle.daemon=true -Dorg.gradle.parallel=true -Dorg.gradle.caching=true -XX:MaxMetaspaceSize=512m"

# 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!"
28 changes: 28 additions & 0 deletions .github/scripts/validate-devcontainer.sh
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!"