Skip to content

Commit f24b4b7

Browse files
author
David Minkovski
committed
Adding lab instructions
1 parent 760f567 commit f24b4b7

15 files changed

+662
-19
lines changed
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
# DevContainer for Java Spring Boot with GitHub Copilot App Modernization
2+
3+
This DevContainer configuration provides a complete development environment for Java Spring Boot applications with support for GitHub Copilot App Modernization for Java.
4+
5+
## Features
6+
7+
### 🐳 Container Base
8+
- **Base Image**: `mcr.microsoft.com/devcontainers/java:1-21-bullseye`
9+
- **Docker-in-Docker**: Enabled for containerization workflows
10+
- **Azure CLI**: Pre-installed for Azure deployment scenarios
11+
- **GitHub CLI**: For GitHub integration and automation
12+
13+
### ☕ Java Development
14+
- **Multiple Java Versions**: Java 8, 11, 17, and 21 via SDKMAN
15+
- **Build Tools**: Maven and Gradle
16+
- **Spring Boot Support**: Complete Spring Boot development stack
17+
18+
### 🚀 GitHub Copilot Extensions
19+
- **GitHub Copilot**: AI-powered code completion
20+
- **GitHub Copilot Chat**: Interactive AI assistance
21+
- **GitHub Copilot App Modernization for Java**: Specialized tools for Java application modernization
22+
23+
### 🛠️ Development Tools
24+
- **Java Extension Pack**: Complete Java development experience
25+
- **Spring Boot Extensions**: Spring Boot dashboard and tools
26+
- **Testing Framework**: JUnit and testing extensions
27+
- **Docker Support**: Docker extension for container management
28+
- **Azure Tools**: Azure development extensions
29+
30+
## Getting Started
31+
32+
### Prerequisites
33+
- [Visual Studio Code](https://code.visualstudio.com/)
34+
- [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)
35+
- [Docker Desktop](https://www.docker.com/products/docker-desktop/)
36+
37+
### Usage
38+
39+
1. **Open in DevContainer**:
40+
- Open the project in VS Code
41+
- Press `Ctrl+Shift+P` (or `Cmd+Shift+P` on Mac)
42+
- Select "Dev Containers: Reopen in Container"
43+
- Wait for the container to build and configure
44+
45+
2. **Verify Setup**:
46+
```bash
47+
# Check Java version
48+
java -version
49+
50+
# Check Maven
51+
mvn -version
52+
53+
# List available Java versions
54+
sdk list java
55+
```
56+
57+
3. **Run the Application**:
58+
```bash
59+
# Using Maven wrapper
60+
./mvnw spring-boot:run
61+
62+
# Or using Maven directly
63+
mvn spring-boot:run
64+
```
65+
66+
## Available Ports
67+
68+
- **8080**: Spring Boot Application (auto-forwarded)
69+
- **3000**: Additional web services
70+
- **5005**: Java Debug Port (for remote debugging)
71+
72+
## Java Version Management
73+
74+
Switch between Java versions using SDKMAN:
75+
76+
```bash
77+
# List installed versions
78+
sdk list java
79+
80+
# Use a specific version for current session
81+
sdk use java 17.0.12-amzn
82+
83+
# Set default version
84+
sdk default java 11.0.24-amzn
85+
```
86+
87+
## Application Modernization Features
88+
89+
This DevContainer is specifically configured for GitHub Copilot App Modernization for Java:
90+
91+
### Assessment Tools
92+
- **AppCAT CLI**: Pre-installed for application assessment
93+
- **Migration Analysis**: Built-in tools for analyzing modernization opportunities
94+
95+
### Modernization Workflows
96+
1. **Assessment**: Use AppCAT to assess the current application
97+
2. **Planning**: Leverage Copilot to plan modernization steps
98+
3. **Implementation**: Use AI-assisted code generation for updates
99+
4. **Testing**: Comprehensive testing with multiple Java versions
100+
101+
### Example Commands
102+
```bash
103+
# Assess application for cloud readiness
104+
appcat assess --source . --target azure
105+
106+
# Run tests with different Java versions
107+
sdk use java 8.0.422-amzn && mvn test
108+
sdk use java 11.0.24-amzn && mvn test
109+
sdk use java 17.0.12-amzn && mvn test
110+
```
111+
112+
## Development Workflow
113+
114+
### Building the Project
115+
```bash
116+
# Clean and compile
117+
mvn clean compile
118+
119+
# Run tests
120+
mvn test
121+
122+
# Package application
123+
mvn clean package
124+
125+
# Run with specific profile
126+
mvn spring-boot:run -Dspring-boot.run.profiles=dev
127+
```
128+
129+
### Docker Integration
130+
```bash
131+
# Build Docker image
132+
docker build -t bus-reservation .
133+
134+
# Run with Docker Compose
135+
docker-compose up -d
136+
```
137+
138+
## Troubleshooting
139+
140+
### Java Version Issues
141+
If you encounter Java version conflicts:
142+
1. Check current version: `java -version`
143+
2. Switch to correct version: `sdk use java <version>`
144+
3. Reload VS Code window if needed
145+
146+
### Extension Issues
147+
If extensions don't load properly:
148+
1. Reload the window: `Ctrl+Shift+P` → "Developer: Reload Window"
149+
2. Rebuild container: `Ctrl+Shift+P` → "Dev Containers: Rebuild Container"
150+
151+
### Port Conflicts
152+
If ports are already in use:
153+
1. Check running processes: `netstat -tulpn | grep :8080`
154+
2. Update port in `application.properties` or use environment variables
155+
156+
## Customization
157+
158+
### Adding Extensions
159+
Edit `.devcontainer/devcontainer.json` and add extensions to the `extensions` array:
160+
161+
```json
162+
"extensions": [
163+
"your.extension.id"
164+
]
165+
```
166+
167+
### Environment Variables
168+
Add environment variables in the `containerEnv` section:
169+
170+
```json
171+
"containerEnv": {
172+
"CUSTOM_VAR": "value"
173+
}
174+
```
175+
176+
### Additional Tools
177+
Modify `.devcontainer/post-create.sh` to install additional tools.
178+
179+
## Support
180+
181+
For issues related to:
182+
- **DevContainer**: Check VS Code Dev Containers documentation
183+
- **Java Development**: Refer to Java Extension Pack documentation
184+
- **GitHub Copilot**: Visit GitHub Copilot documentation
185+
- **App Modernization**: Check GitHub Copilot App Modernization for Java documentation
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
{
2+
"name": "Java Spring Boot with App Modernization",
3+
"image": "mcr.microsoft.com/devcontainers/java:1-21-bullseye",
4+
5+
// Features to add to the dev container
6+
"features": {
7+
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
8+
"ghcr.io/devcontainers/features/azure-cli:1": {},
9+
"ghcr.io/devcontainers/features/github-cli:1": {}
10+
},
11+
12+
// Configure tool-specific properties
13+
"customizations": {
14+
"vscode": {
15+
"extensions": [
16+
// Java Development Extensions
17+
"vscjava.vscode-java-pack",
18+
// GitHub Copilot Extensions
19+
"github.copilot",
20+
"github.copilot-chat",
21+
22+
// GitHub Copilot App Modernization for Java
23+
"vscjava.migrate-java-to-azure",
24+
],
25+
"settings": {
26+
// "java.jdt.ls.java.home": "/usr/local/sdkman/candidates/java/current/bin",
27+
"java.configuration.runtimes": [
28+
/*{
29+
"name": "JavaSE-1.8",
30+
"path": "/usr/local/sdkman/candidates/java/8.0.422-amzn"
31+
},
32+
{
33+
"name": "JavaSE-11",
34+
"path": "/usr/local/sdkman/candidates/java/11.0.24-amzn"
35+
},
36+
{
37+
"name": "JavaSE-17",
38+
"path": "/usr/local/sdkman/candidates/java/17.0.12-amzn"
39+
},*/
40+
{
41+
"name": "JavaSE-21",
42+
"path": "/usr/local/sdkman/candidates/java/21.0.4-amzn"
43+
}
44+
],
45+
"java.compile.nullAnalysis.mode": "automatic",
46+
"spring-boot.ls.checkUpdate": false,
47+
"files.exclude": {
48+
"**/.classpath": true,
49+
"**/.project": true,
50+
"**/.settings": true,
51+
"**/.factorypath": true
52+
}
53+
}
54+
}
55+
},
56+
57+
// Ports to forward
58+
"forwardPorts": [8080, 3000, 5005],
59+
"portsAttributes": {
60+
"8080": {
61+
"label": "Spring Boot Application",
62+
"onAutoForward": "notify"
63+
},
64+
"5005": {
65+
"label": "Java Debug Port",
66+
"onAutoForward": "silent"
67+
}
68+
},
69+
70+
// Use 'postCreateCommand' to run commands after the container is created
71+
"postCreateCommand": "bash .devcontainer/post-create.sh",
72+
73+
// Mount the local file system and docker socket
74+
"mounts": [
75+
"source=/var/run/docker.sock,target=/var/run/docker-host.sock,type=bind"
76+
],
77+
78+
// Set container user
79+
"containerUser": "root",
80+
"remoteUser": "root",
81+
82+
// Enable privileged mode for docker-in-docker
83+
"privileged": true
84+
}
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#!/bin/bash
2+
3+
# Post-create script for Java Spring Boot DevContainer
4+
echo "Setting up Java development environment..."
5+
6+
# Install SDKMAN if not already installed
7+
if [ ! -d "/usr/local/sdkman" ]; then
8+
echo "Installing SDKMAN..."
9+
curl -s "https://get.sdkman.io" | bash
10+
source "/usr/local/sdkman/bin/sdkman-init.sh"
11+
fi
12+
13+
# Source SDKMAN
14+
source "/usr/local/sdkman/bin/sdkman-init.sh"
15+
16+
# Install multiple Java versions for app modernization scenarios
17+
echo "Installing Java version..."
18+
# sdk install java 8.0.422-amzn || true
19+
# sdk install java 11.0.24-amzn || true
20+
# sdk install java 17.0.12-amzn || true
21+
sdk install java 21.0.4-amzn || true
22+
23+
# Set Java 21 as default (can be changed based on project needs)
24+
sdk default java 21.0.4-amzn
25+
26+
# Install Maven (latest version)
27+
echo "Installing Maven..."
28+
sdk install maven || true
29+
30+
# Install Gradle
31+
# echo "Installing Gradle..."
32+
# sdk install gradle || true
33+
34+
# Update package list and install additional tools
35+
echo "Installing additional development tools..."
36+
sudo apt-get update
37+
sudo apt-get install -y \
38+
curl \
39+
wget \
40+
git \
41+
unzip \
42+
jq \
43+
tree \
44+
htop
45+
46+
# Make Maven wrapper executable
47+
if [ -f "./mvnw" ]; then
48+
chmod +x ./mvnw
49+
echo "Maven wrapper made executable"
50+
fi
51+
52+
# Install AppCAT CLI for application assessment (useful for modernization)
53+
echo "Installing AppCAT CLI for application assessment..."
54+
# Prefer a local packaged folder if present, otherwise download and extract the release
55+
if ls azure-migrate-appcat-for-java-cli-linux-amd64-* 1> /dev/null 2>&1; then
56+
APP_DIR=$(ls -d azure-migrate-appcat-for-java-cli-linux-amd64-* 2>/dev/null | head -n1)
57+
else
58+
# Download and extract the release
59+
curl -L https://aka.ms/appcat/azure-migrate-appcat-for-java-cli-linux-amd64.tar.gz | tar -xz
60+
APP_DIR=$(ls -d azure-migrate-appcat-for-java-cli-linux-amd64-* 2>/dev/null | head -n1)
61+
fi
62+
63+
# Move the entire package directory into /usr/local/bin so its subfiles remain available to the tool,
64+
# then create a symlink named 'appcat' in /usr/local/bin pointing to the packaged executable.
65+
if [ -n "$APP_DIR" ] && [ -d "$APP_DIR" ]; then
66+
sudo mv "$APP_DIR" /usr/local/bin/
67+
sudo chmod -R a+rX "/usr/local/bin/$APP_DIR"
68+
if [ -f "/usr/local/bin/$APP_DIR/appcat" ]; then
69+
sudo ln -sf "/usr/local/bin/$APP_DIR/appcat" /usr/local/bin/appcat
70+
sudo chmod +x "/usr/local/bin/$APP_DIR/appcat"
71+
fi
72+
elif [ -f "./appcat" ]; then
73+
sudo mv ./appcat /usr/local/bin/
74+
sudo chmod +x /usr/local/bin/appcat
75+
else
76+
echo "Warning: appcat binary or package not found. You may need to install it manually."
77+
fi
78+
79+
# Ensure /usr/local/bin is added to user's PATH for interactive shells
80+
if ! grep -q '/usr/local/bin' ~/.bashrc; then
81+
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bashrc
82+
fi
83+
84+
# Add a system-wide profile script so non-interactive/other users also see appcat in PATH
85+
sudo bash -c 'cat > /etc/profile.d/appcat.sh <<"EOF"
86+
# Add appcat to PATH
87+
export PATH="/usr/local/bin:\$PATH"
88+
EOF'
89+
sudo chmod +x /etc/profile.d/appcat.sh
90+
91+
# Create development directories
92+
mkdir -p ~/workspace/tools
93+
mkdir -p ~/workspace/scripts
94+
95+
echo "✅ DevContainer setup completed successfully!"
96+
echo ""
97+
echo "Available Java versions:"
98+
sdk list java | grep installed || echo "Run 'sdk list java' to see available versions"
99+
echo ""
100+
echo "Useful commands:"
101+
echo " - sdk use java <version> : Switch Java version"
102+
echo " - mvn spring-boot:run : Run Spring Boot application"
103+
echo " - mvn clean package : Build the application"
104+
echo " - appcat assess : Assess application for modernization"
105+
echo ""
106+
echo "The development environment is ready for GitHub Copilot App Modernization!"

asset-manager/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.github/appmod-java
2+
logs
3+
azure-migrate-appcat-for-java-cli-linux-amd64-*
4+
storage
5+
pids

0 commit comments

Comments
 (0)