Skip to content

Commit e5dc378

Browse files
refactor: Update setup instructions and improve service startup guidance in setup scripts
1 parent fe60b9d commit e5dc378

6 files changed

Lines changed: 145 additions & 233 deletions

File tree

docs/AutomatedLocalSetup.md

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -152,23 +152,32 @@ The script automatically grants your user account the following roles (skips if
152152
153153
## After Setup
154154
155-
Once the script finishes, start the three services in separate terminals:
155+
Once the script finishes, start the three services in separate terminals (Backend first, then MCP, then Frontend):
156156
157-
```bash
158-
# Terminal 1 — Backend (port 8000)
159-
cd src/backend
160-
source .venv/Scripts/activate # Windows Git Bash
161-
# source .venv/bin/activate # Linux / macOS
162-
uvicorn app:app --reload --host 0.0.0.0 --port 8000
163-
164-
# Terminal 2 — MCP Server (port 9000)
165-
cd src/mcp_server
166-
source .venv/Scripts/activate
167-
python mcp_server.py
168-
169-
# Terminal 3 — Frontend (port 3000)
170-
cd src/App
171-
npm run dev
157+
```
158+
Terminal 1 — Backend (port 8000):
159+
cd src/backend
160+
Activate virtual environment:
161+
PowerShell : .\.venv\Scripts\Activate.ps1
162+
Git Bash : source .venv/Scripts/activate
163+
Linux/macOS: source .venv/bin/activate
164+
python app.py
165+
166+
Terminal 2 — MCP Server (port 9000):
167+
cd src/mcp_server
168+
Activate virtual environment:
169+
PowerShell : .\.venv\Scripts\Activate.ps1
170+
Git Bash : source .venv/Scripts/activate
171+
Linux/macOS: source .venv/bin/activate
172+
python mcp_server.py --transport streamable-http --host 0.0.0.0 --port 9000
173+
174+
Terminal 3 — Frontend (port 3000):
175+
cd src/App
176+
Activate virtual environment:
177+
PowerShell : .\.venv\Scripts\Activate.ps1
178+
Git Bash : source .venv/Scripts/activate
179+
Linux/macOS: source .venv/bin/activate
180+
python frontend_server.py
172181
```
173182
174183
Then open [http://localhost:3000](http://localhost:3000).

docs/DeployLocalChanges.md

Lines changed: 24 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Deploy Local Changes to Azure
22

3-
Two scripts — one for each platform — that build only the Docker images you changed, push them to ACR, and update the live Azure resources.
3+
Two scripts — one for each platform — that build Docker images for the services you specify (or all by default), push them to ACR, and update the live Azure resources.
44

55
| Platform | Script |
66
|---|---|
@@ -11,11 +11,10 @@ Two scripts — one for each platform — that build only the Docker images you
1111

1212
## Prerequisites
1313

14-
| Tool | Purpose |
15-
|---|---|
16-
| [Azure CLI](https://learn.microsoft.com/cli/azure/install-azure-cli) | Manage Azure resources |
17-
| [Docker Desktop](https://www.docker.com/products/docker-desktop/) | Build and push images |
18-
| Git | Detect which services changed |
14+
| Tool | Required? | Purpose |
15+
|---|---|---|
16+
| [Azure CLI](https://learn.microsoft.com/cli/azure/install-azure-cli) | **Yes** | Manage Azure resources, ACR login |
17+
| [Docker Desktop](https://www.docker.com/products/docker-desktop/) | **Yes** | Build and push Docker images |
1918

2019
You must be logged in before running:
2120
```bash
@@ -26,12 +25,12 @@ az login
2625

2726
## What It Does (in order)
2827

29-
1. **Checks prerequisites**Docker, Azure CLI, Git
28+
1. **Checks prerequisites** — Azure CLI and Docker (both required)
3029
2. **Discovers Azure resources** — finds the backend/MCP Container Apps and frontend App Service in your resource group
3130
3. **Resolves ACR** — lists ACRs in the resource group and asks which one to use; prompts to create a new one if needed
32-
4. **Detects changed services**uses `git diff` to find which of `src/backend/`, `src/mcp_server/`, `src/App/` have changed; only those services are built and deployed
33-
5. **Generates an image tag** — auto-generates `YYYYMMDD-HHMMSS-<git-sha>` or uses your custom tag
34-
6. **Builds & pushes images**`docker build` + `docker push` to ACR for each changed service
31+
4. **Determines services**deploys all services by default, or only the ones you specify with `--services`
32+
5. **Generates an image tag** — auto-generates `YYYYMMDD-HHMMSS` or uses your custom tag
33+
6. **Builds & pushes images**builds locally with Docker, pushes to ACR
3534
7. **Updates Azure resources** — updates the Container App / App Service to the new image tag
3635
8. **Prints a summary** with rollback commands
3736

@@ -41,16 +40,16 @@ az login
4140

4241
```bash
4342
# bash (Linux/macOS/WSL)
44-
bash infra/scripts/deploy_to_azure.sh -g <resource-group>
43+
bash infra/scripts/deploy_to_azure.sh --resource-group <resource-group>
4544

4645
# PowerShell (Windows)
4746
.\infra\scripts\deploy_to_azure.ps1 -ResourceGroup <resource-group>
4847
```
4948

5049
The script will:
51-
- Auto-detect which services you changed via git
50+
- Deploy all services by default (use `--services` to pick specific ones)
51+
- Build images locally with Docker and push to ACR
5252
- Ask which ACR to use (or offer to create one)
53-
- Ask for confirmation before deploying if no changes are detected
5453

5554
---
5655

@@ -59,14 +58,14 @@ The script will:
5958
### Bash
6059

6160
```bash
62-
./infra/scripts/deploy_to_azure.sh -g <resource-group> [options]
61+
./infra/scripts/deploy_to_azure.sh --resource-group <resource-group> [options]
6362

6463
Required:
6564
-g, --resource-group <name> Azure Resource Group name
6665

6766
Options:
6867
--acr <name> Skip the ACR prompt; use this ACR directly
69-
--services <list> Skip change detection; deploy only these services
68+
--services <list> Deploy only these services (default: all)
7069
Values: backend, mcp, frontend (comma-separated)
7170
--tag <tag> Use a custom image tag instead of auto-generated
7271
--dry-run Preview all steps without making any changes
@@ -86,7 +85,7 @@ Required:
8685
8786
Options:
8887
-Acr <name> Skip the ACR prompt; use this ACR directly
89-
-Services <list> Skip change detection; deploy only these services
88+
-Services <list> Deploy only these services (default: all)
9089
Values: "backend,mcp,frontend"
9190
-Tag <tag> Use a custom image tag instead of auto-generated
9291
-DryRun Preview all steps without making any changes
@@ -100,30 +99,30 @@ Options:
10099
## Examples
101100
102101
```bash
103-
# Deploy only what changed (auto-detected)
104-
bash infra/scripts/deploy_to_azure.sh -g rg-macae-dev
102+
# Deploy all services (default)
103+
bash infra/scripts/deploy_to_azure.sh --resource-group rg-macae-dev
105104

106105
# Deploy only the frontend
107-
bash infra/scripts/deploy_to_azure.sh -g rg-macae-dev --services frontend
106+
bash infra/scripts/deploy_to_azure.sh --resource-group rg-macae-dev --services frontend
108107

109108
# Deploy backend and MCP with a specific ACR
110-
bash infra/scripts/deploy_to_azure.sh -g rg-macae-dev --services backend,mcp --acr myregistry
109+
bash infra/scripts/deploy_to_azure.sh --resource-group rg-macae-dev --services backend,mcp --acr myregistry
111110

112111
# Preview without making changes
113-
bash infra/scripts/deploy_to_azure.sh -g rg-macae-dev --dry-run
112+
bash infra/scripts/deploy_to_azure.sh --resource-group rg-macae-dev --dry-run
114113

115114
# Build images only (no Azure update)
116-
bash infra/scripts/deploy_to_azure.sh -g rg-macae-dev --build-only
115+
bash infra/scripts/deploy_to_azure.sh --resource-group rg-macae-dev --build-only
117116

118117
# Update Azure only (images already pushed)
119-
bash infra/scripts/deploy_to_azure.sh -g rg-macae-dev --deploy-only --tag 20260506-120000-abc1234
118+
bash infra/scripts/deploy_to_azure.sh --resource-group rg-macae-dev --deploy-only --tag 20260506-120000-abc1234
120119

121120
# Skip AcrPull role assignment (roles already exist)
122-
bash infra/scripts/deploy_to_azure.sh -g rg-macae-dev --skip-role-assignment
121+
bash infra/scripts/deploy_to_azure.sh --resource-group rg-macae-dev --skip-role-assignment
123122
```
124123
125124
```powershell
126-
# Deploy only what changed
125+
# Deploy all services (default)
127126
.\infra\scripts\deploy_to_azure.ps1 -ResourceGroup rg-macae-dev
128127

129128
# Deploy only backend
@@ -138,25 +137,6 @@ bash infra/scripts/deploy_to_azure.sh -g rg-macae-dev --skip-role-assignment
138137
139138
---
140139
141-
## Change Detection Logic
142-
143-
When `--services` is not specified, the script runs `git diff` to determine what to build:
144-
145-
| Files changed in | Service built |
146-
|---|---|
147-
| `src/backend/` | backend |
148-
| `src/mcp_server/` | mcp |
149-
| `src/App/` | frontend |
150-
151-
It checks only **uncommitted changes** (staged and unstaged vs the last commit, i.e. `git diff HEAD`). Commits that are already committed but not yet pushed are intentionally excluded to avoid false positives from unrelated branch work.
152-
153-
If no changes are detected in any service directory, the script asks:
154-
```
155-
No changes detected. Deploy all services anyway? [y/N]:
156-
```
157-
158-
---
159-
160140
## ACR Selection
161141
162142
If `--acr` / `-Acr` is not provided, the script **always prompts first**:

infra/scripts/deploy_to_azure.ps1

Lines changed: 19 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -80,63 +80,48 @@ function Check-Prerequisites {
8080

8181
$missing = @()
8282

83-
if (Get-Command docker -ErrorAction SilentlyContinue) {
84-
Write-LogSuccess "Docker found: $(docker --version)"
85-
} else {
86-
$missing += "docker"
87-
}
88-
8983
if (Get-Command az -ErrorAction SilentlyContinue) {
9084
Write-LogSuccess "Azure CLI found"
9185
} else {
9286
$missing += "azure-cli"
9387
}
9488

95-
if (Get-Command git -ErrorAction SilentlyContinue) {
96-
Write-LogSuccess "Git found"
89+
if (Get-Command docker -ErrorAction SilentlyContinue) {
90+
$dockerInfo = docker info 2>&1
91+
if ($LASTEXITCODE -eq 0) {
92+
Write-LogSuccess "Docker found and running"
93+
} else {
94+
Write-LogError "Docker found but daemon not running. Please start Docker Desktop."
95+
exit 1
96+
}
9797
} else {
98-
$missing += "git"
98+
$missing += "docker"
9999
}
100100

101101
if ($missing.Count -gt 0) {
102102
Write-LogError "Missing prerequisites: $($missing -join ', ')"
103103
Write-Host ""
104104
foreach ($tool in $missing) {
105105
switch ($tool) {
106-
"docker" {
107-
Write-Host " ┌─ Docker ──────────────────────────────────────────────────────"
108-
Write-Host " │ Download: https://www.docker.com/products/docker-desktop"
109-
Write-Host " │ Or: winget install Docker.DockerDesktop"
110-
Write-Host " │ Verify: docker --version"
111-
Write-Host " └──────────────────────────────────────────────────────────────"
112-
}
113106
"azure-cli" {
114107
Write-Host " ┌─ Azure CLI ───────────────────────────────────────────────────"
115108
Write-Host " │ Download: https://aka.ms/installazurecliwindows"
116109
Write-Host " │ Or: winget install Microsoft.AzureCLI"
117110
Write-Host " │ Verify: az --version"
118111
Write-Host " └──────────────────────────────────────────────────────────────"
119112
}
120-
"git" {
121-
Write-Host " ┌─ Git ─────────────────────────────────────────────────────────"
122-
Write-Host " │ Download: https://git-scm.com/download/win"
123-
Write-Host " │ Or: winget install Git.Git"
124-
Write-Host " │ Verify: git --version"
113+
"docker" {
114+
Write-Host " ┌─ Docker Desktop ──────────────────────────────────────────────"
115+
Write-Host " │ Download: https://www.docker.com/products/docker-desktop"
116+
Write-Host " │ Or: winget install Docker.DockerDesktop"
117+
Write-Host " │ Verify: docker --version"
125118
Write-Host " └──────────────────────────────────────────────────────────────"
126119
}
127120
}
128121
}
129122
exit 1
130123
}
131124

132-
# Check Docker daemon
133-
$dockerInfo = docker info 2>&1
134-
if ($LASTEXITCODE -ne 0) {
135-
Write-LogError "Docker daemon is not running. Please start Docker Desktop and retry."
136-
exit 1
137-
}
138-
Write-LogSuccess "Docker daemon is running"
139-
140125
# Check Azure login
141126
$azAccount = az account show 2>&1
142127
if ($LASTEXITCODE -ne 0) {
@@ -408,20 +393,6 @@ function Assign-AcrPullRoles {
408393
# Step 4: Determine Services
409394
# ==============================================================================
410395

411-
function Get-ChangedServices {
412-
# Only detect uncommitted changes (staged + unstaged vs last commit).
413-
# We intentionally skip 'commits ahead of origin/main' to avoid false positives
414-
# from other work on the feature branch that the user hasn't actively changed.
415-
$changed = git diff --name-only HEAD 2>$null
416-
if (-not $changed) { return @() }
417-
418-
$services = @()
419-
if ($changed -match '^src/backend/') { $services += "backend" }
420-
if ($changed -match '^src/mcp_server/') { $services += "mcp" }
421-
if ($changed -match '^src/App/') { $services += "frontend" }
422-
return $services
423-
}
424-
425396
function Determine-Services {
426397
Write-LogStep "Step 4: Determining Services to Deploy"
427398

@@ -440,32 +411,10 @@ function Determine-Services {
440411
}
441412
}
442413
} else {
443-
# Auto-detect changed services from git
444-
Write-LogInfo "No -Services specified — detecting changed services via git..."
445-
$detected = Get-ChangedServices
446-
447-
if ($detected.Count -gt 0) {
448-
Write-LogInfo "Git detected changes in: $($detected -join ', ')"
449-
foreach ($svc in $detected) {
450-
switch ($svc) {
451-
"backend" { $script:DeployBackend = $true }
452-
"mcp" { $script:DeployMcp = $true }
453-
"frontend" { $script:DeployFrontend = $true }
454-
}
455-
}
456-
} else {
457-
Write-LogWarn "No service-specific changes detected (no uncommitted changes vs HEAD)."
458-
Write-Host ""
459-
$confirm = Read-Host "No changes detected. Deploy all services anyway? [y/N]"
460-
if ($confirm -match '^[Yy](es)?$') {
461-
$script:DeployBackend = $true
462-
$script:DeployMcp = $true
463-
$script:DeployFrontend = $true
464-
} else {
465-
Write-LogInfo "Nothing to deploy. Exiting."
466-
exit 0
467-
}
468-
}
414+
Write-LogInfo "No -Services specified — deploying all services"
415+
$script:DeployBackend = $true
416+
$script:DeployMcp = $true
417+
$script:DeployFrontend = $true
469418
}
470419

471420
Write-Host " Services to deploy:"
@@ -485,9 +434,7 @@ function Generate-Tag {
485434
$script:ImageTag = $Tag
486435
} else {
487436
$timestamp = (Get-Date).ToString("yyyyMMdd-HHmmss")
488-
$gitSha = git rev-parse --short=7 HEAD 2>$null
489-
if (-not $gitSha) { $gitSha = "unknown" }
490-
$script:ImageTag = "$timestamp-$gitSha"
437+
$script:ImageTag = $timestamp
491438
}
492439

493440
Write-LogSuccess "Image tag: $script:ImageTag"
@@ -505,7 +452,6 @@ function Build-AndPush {
505452
return
506453
}
507454

508-
# Login to ACR
509455
Write-LogInfo "Logging into ACR: $script:AcrName..."
510456
az acr login --name $script:AcrName
511457
Write-LogSuccess "ACR login successful"

0 commit comments

Comments
 (0)