From 1cd83d0e3d6b5b9f8e53295d1ad2c68d07f6a5c1 Mon Sep 17 00:00:00 2001 From: Issei Hiraoka Date: Fri, 8 May 2026 17:46:34 +0900 Subject: [PATCH] Add GitHub Codespaces devcontainer configuration for Starter Lab This PR adds a `.devcontainer` configuration to enable GitHub Codespaces support for the Starter Lab (`labs/starter-lab/`). ## What's included - `.devcontainer/devcontainer.json`: Dev container configuration with the following Dev Container Features: - Azure CLI (with Bicep) - Azure Developer CLI (azd) - GitHub CLI (for Scenario 3: issue triage) - `.devcontainer/post-create.sh`: Installs `python3-yaml` and `jq` via apt (pre-compiled binaries, no pip build time) - `.devcontainer/post-start.sh`: Displays a brief welcome message with Azure login instructions on each terminal open ## VS Code extensions installed - `ms-azuretools.vscode-bicep` - `ms-azuretools.azure-dev` - `ms-azuretools.vscode-azure-github-copilot` - `ms-vscode.azurecli` - `ms-python.python` - `redhat.vscode-yaml` - `github.copilot-chat` ## Design decisions - Uses `mcr.microsoft.com/devcontainers/base:ubuntu` as the base image; system Python 3 is sufficient (no Python Feature needed) - Docker-in-Docker is not required since the Starter Lab uses ACR Tasks - Host requirements set to 2-core / 4 GB to minimize Codespaces billing - Azure credential mount configured for local Dev Container reuse --- .devcontainer/devcontainer.json | 55 +++++++++++++++++++++++++++++++++ .devcontainer/post-create.sh | 13 ++++++++ .devcontainer/post-start.sh | 21 +++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 .devcontainer/devcontainer.json create mode 100755 .devcontainer/post-create.sh create mode 100755 .devcontainer/post-start.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..40e67a3df --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,55 @@ +{ + "name": "Azure SRE Agent Lab", + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + + // --- Dev Container Features --- + "features": { + // Azure CLI + Bicep + "ghcr.io/devcontainers/features/azure-cli:1": { + "installBicep": true, + "version": "latest" + }, + // Azure Developer CLI (azd) + "ghcr.io/azure/azure-dev/azd:latest": {}, + // Python: system python3 from base image is sufficient (pyyaml via apt) + // GitHub CLI (Scenario 3: issue triage) + "ghcr.io/devcontainers/features/github-cli:1": { + "version": "latest" + } + }, + + // --- VS Code Extensions --- + "customizations": { + "vscode": { + "extensions": [ + "ms-azuretools.vscode-bicep", + "ms-azuretools.azure-dev", + "ms-azuretools.vscode-azure-github-copilot", + "ms-vscode.azurecli", + "ms-python.python", + "redhat.vscode-yaml", + "github.copilot-chat" + ], + "settings": { + "terminal.integrated.defaultProfile.linux": "bash" + } + } + }, + + // --- Lifecycle Hooks --- + "postCreateCommand": "bash .devcontainer/post-create.sh", + "postStartCommand": "bash .devcontainer/post-start.sh", + + // --- Azure credentials mount (for local Dev Container use) --- + "mounts": [ + "source=${localEnv:HOME}${localEnv:USERPROFILE}/.azure,target=/home/vscode/.azure,type=bind,consistency=cached" + ], + + // --- Recommended Codespaces machine type --- + "hostRequirements": { + "cpus": 2, + "memory": "4gb" + }, + + "remoteUser": "vscode" +} diff --git a/.devcontainer/post-create.sh b/.devcontainer/post-create.sh new file mode 100755 index 000000000..d68d81dfc --- /dev/null +++ b/.devcontainer/post-create.sh @@ -0,0 +1,13 @@ +#!/bin/bash +# ============================================================================= +# Post-Create Script for Azure SRE Agent Lab Dev Container +# Runs once when the container is first created. +# ============================================================================= +set -e + +echo "Setting up Azure SRE Agent Lab environment..." + +# Install system packages (python3-yaml is pre-compiled, much faster than pip) +sudo apt-get update && sudo apt-get install -y --no-install-recommends python3-yaml jq + +echo "Setup complete." diff --git a/.devcontainer/post-start.sh b/.devcontainer/post-start.sh new file mode 100755 index 000000000..4e5458203 --- /dev/null +++ b/.devcontainer/post-start.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# ============================================================================= +# Post-Start Script — runs each time the container starts. +# ============================================================================= + +echo "" +echo "========================================" +echo " Azure SRE Agent Lab" +echo "========================================" +echo " Docs: https://aka.ms/sreagent/lab" +echo "========================================" +echo "" + +# Check Azure login status +if az account show &>/dev/null; then + ACCOUNT=$(az account show --query 'name' -o tsv) + echo "Azure: Logged in ($ACCOUNT)" +else + echo "Azure: Not logged in. Run 'az login --use-device-code' to authenticate." +fi +echo ""