Skip to content

Commit 2ce9ee5

Browse files
authored
Merge pull request #2 from hunterjam/psl-contentgen
Infra code updates, docker file addition for frontend
2 parents 1fbca26 + c5569c6 commit 2ce9ee5

40 files changed

Lines changed: 947 additions & 3944 deletions

.devcontainer/devcontainer.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "azd-template",
3+
"image": "mcr.microsoft.com/devcontainers/python:3.11-bullseye",
4+
"forwardPorts": [3000, 5000],
5+
"features": {
6+
"ghcr.io/devcontainers/features/node:1": {
7+
"nodeGypDependencies": true,
8+
"installYarnUsingApt": true,
9+
"version": "lts",
10+
"pnpmVersion": "latest",
11+
"nvmVersion": "latest"
12+
},
13+
"ghcr.io/devcontainers/features/azure-cli:1": {
14+
"installBicep": true,
15+
"version": "latest",
16+
"bicepVersion": "latest"
17+
},
18+
"ghcr.io/azure/azure-dev/azd:0": {
19+
"version": "stable"
20+
}
21+
},
22+
"customizations": {
23+
"vscode": {
24+
"extensions": [
25+
"ms-azuretools.azure-dev",
26+
"ms-azuretools.vscode-bicep",
27+
"ms-python.python",
28+
"ms-toolsai.jupyter",
29+
"GitHub.vscode-github-actions"
30+
]
31+
}
32+
},
33+
"postCreateCommand": "bash ./.devcontainer/setup_env.sh",
34+
"remoteUser": "vscode",
35+
"hostRequirements": {
36+
"memory": "4gb"
37+
}
38+
}

.devcontainer/setup_env.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
git fetch
4+
git pull

Dockerfile

Lines changed: 0 additions & 23 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Follow the quick deploy steps on the deployment guide to deploy this solution to
7272
[Click here to launch the deployment guide](./content-gen/docs/DEPLOYMENT.md)
7373
<br/><br/>
7474

75-
| [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/microsoft/document-generation-solution-accelerator) | [![Open in Dev Containers](https://img.shields.io/static/v1?style=for-the-badge&label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/microsoft/document-generation-solution-accelerator) | [![Open in Visual Studio Code Web](https://img.shields.io/static/v1?style=for-the-badge&label=Visual%20Studio%20Code%20(Web)&message=Open&color=blue&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/azure/?vscode-azure-exp=foundry&agentPayload=eyJiYXNlVXJsIjogImh0dHBzOi8vcmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbS9taWNyb3NvZnQvZG9jdW1lbnQtZ2VuZXJhdGlvbi1zb2x1dGlvbi1hY2NlbGVyYXRvci9yZWZzL2hlYWRzL21haW4vaW5mcmEvdnNjb2RlX3dlYiIsICJpbmRleFVybCI6ICIvaW5kZXguanNvbiIsICJ2YXJpYWJsZXMiOiB7ImFnZW50SWQiOiAiIiwgImNvbm5lY3Rpb25TdHJpbmciOiAiIiwgInRocmVhZElkIjogIiIsICJ1c2VyTWVzc2FnZSI6ICIiLCAicGxheWdyb3VuZE5hbWUiOiAiIiwgImxvY2F0aW9uIjogIiIsICJzdWJzY3JpcHRpb25JZCI6ICIiLCAicmVzb3VyY2VJZCI6ICIiLCAicHJvamVjdFJlc291cmNlSWQiOiAiIiwgImVuZHBvaW50IjogIiJ9LCAiY29kZVJvdXRlIjogWyJhaS1wcm9qZWN0cy1zZGsiLCAicHl0aG9uIiwgImRlZmF1bHQtYXp1cmUtYXV0aCIsICJlbmRwb2ludCJdfQ==) |
75+
| [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/hunterjam/content-generation-solution-accelerator) | [![Open in Dev Containers](https://img.shields.io/static/v1?style=for-the-badge&label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/hunterjam/content-generation-solution-accelerator) | [![Open in Visual Studio Code Web](https://img.shields.io/static/v1?style=for-the-badge&label=Visual%20Studio%20Code%20(Web)&message=Open&color=blue&logo=visualstudiocode&logoColor=white)](https://vscode.dev/azure/?vscode-azure-exp=foundry&agentPayload=eyJiYXNlVXJsIjogImh0dHBzOi8vcmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbS9odW50ZXJqYW0vY29udGVudC1nZW5lcmF0aW9uLXNvbHV0aW9uLWFjY2VsZXJhdG9yL3JlZnMvaGVhZHMvbWFpbi9jb250ZW50LWdlbi9pbmZyYS92c2NvZGVfd2ViIiwgImluZGV4VXJsIjogIi9pbmRleC5qc29uIiwgInZhcmlhYmxlcyI6IHsiYWdlbnRJZCI6ICIiLCAiY29ubmVjdGlvblN0cmluZyI6ICIiLCAidGhyZWFkSWQiOiAiIiwgInVzZXJNZXNzYWdlIjogIiIsICJwbGF5Z3JvdW5kTmFtZSI6ICIiLCAibG9jYXRpb24iOiAiIiwgInN1YnNjcmlwdGlvbklkIjogIiIsICJyZXNvdXJjZUlkIjogIiIsICJwcm9qZWN0UmVzb3VyY2VJZCI6ICIiLCAiZW5kcG9pbnQiOiAiIn0sICJjb2RlUm91dGUiOiBbImFpLXByb2plY3RzLXNkayIsICJweXRob24iLCAiZGVmYXVsdC1henVyZS1hdXRoIiwgImVuZHBvaW50Il19) |
7676
|---|---|---|
7777

7878
<br/>

content-gen/azure.yaml

Lines changed: 3 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -46,46 +46,12 @@ infra:
4646
path: ./infra
4747
module: main
4848

49-
# Custom workflow:
50-
# 1. First provision creates infrastructure (skips ACI for private networking)
51-
# 2. Build container image to ACR
52-
# 3. Second provision creates ACI with the now-available image
5349
workflows:
5450
up:
5551
steps:
5652
- azd: provision
5753

5854
hooks:
59-
preprovision:
60-
windows:
61-
run: |
62-
Write-Host "Preparing Content Generation Solution Accelerator deployment..." -ForegroundColor Cyan
63-
Write-Host "Checking Azure CLI authentication..."
64-
az account show --query "{name:name, id:id}" -o table
65-
66-
# For private networking on first run, skip ACI (image not yet in ACR)
67-
$currentSkip = azd env get-value skipContainerDeployment 2>$null
68-
if ($env:enablePrivateNetworking -eq 'true' -and -not $env:ACR_NAME -and $currentSkip -ne 'false') {
69-
Write-Host "Private networking enabled - skipping container deployment until image is built" -ForegroundColor Yellow
70-
azd env set skipContainerDeployment true
71-
}
72-
shell: pwsh
73-
continueOnError: false
74-
posix:
75-
run: |
76-
echo "Preparing Content Generation Solution Accelerator deployment..."
77-
echo "Checking Azure CLI authentication..."
78-
az account show --query "{name:name, id:id}" -o table
79-
80-
# For private networking on first run, skip ACI (image not yet in ACR)
81-
current_skip=$(azd env get-value skipContainerDeployment 2>/dev/null || echo "")
82-
if [ "$enablePrivateNetworking" = "true" ] && [ -z "$ACR_NAME" ] && [ "$current_skip" != "false" ]; then
83-
echo "Private networking enabled - skipping container deployment until image is built"
84-
azd env set skipContainerDeployment true
85-
fi
86-
shell: sh
87-
continueOnError: false
88-
8955
postprovision:
9056
windows:
9157
run: |
@@ -116,81 +82,14 @@ hooks:
11682
Write-Host " Cosmos DB role may already be assigned" -ForegroundColor Yellow
11783
}
11884
119-
# Build container image and deploy ACI if ACR exists and ACI was skipped
120-
$skipContainer = azd env get-value skipContainerDeployment 2>$null
121-
if ($env:ACR_NAME -and $skipContainer -eq 'true') {
122-
Write-Host ""
123-
Write-Host "===== Building Container Image =====" -ForegroundColor Yellow
124-
Write-Host "Building and pushing image to ACR: $env:ACR_NAME" -ForegroundColor Cyan
125-
126-
az acr build --registry $env:ACR_NAME --image content-gen-app:latest --file ./src/WebApp.Dockerfile ./src
127-
128-
if ($LASTEXITCODE -eq 0) {
129-
Write-Host "Container image built and pushed successfully!" -ForegroundColor Green
130-
131-
# Enable container deployment and re-provision
132-
Write-Host ""
133-
Write-Host "===== Deploying Container Instance =====" -ForegroundColor Yellow
134-
azd env set skipContainerDeployment false
135-
136-
Write-Host "Re-running provision to deploy ACI..." -ForegroundColor Cyan
137-
azd provision --no-prompt
138-
139-
if ($LASTEXITCODE -eq 0) {
140-
Write-Host "Container Instance deployed successfully!" -ForegroundColor Green
141-
} else {
142-
Write-Host "Container Instance deployment failed" -ForegroundColor Red
143-
}
144-
} else {
145-
Write-Host "Failed to build container image" -ForegroundColor Red
146-
}
147-
} elseif ($env:CONTAINER_INSTANCE_NAME) {
85+
if ($env:CONTAINER_INSTANCE_NAME) {
14886
Write-Host ""
14987
Write-Host "Container Instance: " -NoNewline
15088
Write-Host "$env:CONTAINER_INSTANCE_NAME" -ForegroundColor Cyan
15189
Write-Host "Container Private IP: " -NoNewline
15290
Write-Host "$env:CONTAINER_INSTANCE_PRIVATE_IP" -ForegroundColor Cyan
153-
} elseif ($env:ACR_NAME) {
154-
Write-Host ""
155-
Write-Host "Container Registry: " -NoNewline
156-
Write-Host "$env:ACR_NAME" -ForegroundColor Cyan
15791
}
15892
159-
# Build and deploy frontend to App Service
160-
Write-Host ""
161-
Write-Host "===== Building Frontend =====" -ForegroundColor Yellow
162-
Push-Location ./src/frontend
163-
npm install
164-
npm run build
165-
166-
if ($LASTEXITCODE -eq 0) {
167-
Write-Host "Frontend build completed!" -ForegroundColor Green
168-
169-
# Copy build to frontend-server
170-
Copy-Item -Path ../static/* -Destination ../frontend-server/static/ -Recurse -Force -ErrorAction SilentlyContinue
171-
172-
Push-Location ../frontend-server
173-
174-
# Create deployment package
175-
Write-Host "Creating deployment package..."
176-
Remove-Item -Path frontend-deploy.zip -Force -ErrorAction SilentlyContinue
177-
Compress-Archive -Path static, server.js, package.json, package-lock.json -DestinationPath frontend-deploy.zip -Force
178-
179-
Write-Host ""
180-
Write-Host "===== Deploying Frontend to App Service =====" -ForegroundColor Yellow
181-
az webapp deploy --resource-group $env:RESOURCE_GROUP_NAME --name $env:APP_SERVICE_NAME --src-path frontend-deploy.zip --type zip
182-
183-
if ($LASTEXITCODE -eq 0) {
184-
Write-Host "Frontend deployed successfully!" -ForegroundColor Green
185-
} else {
186-
Write-Host "Frontend deployment failed" -ForegroundColor Red
187-
}
188-
189-
Pop-Location
190-
} else {
191-
Write-Host "Frontend build failed" -ForegroundColor Red
192-
}
193-
Pop-Location
19493
19594
# Run post-deploy script to upload sample data and create search index
19695
Write-Host ""
@@ -252,73 +151,14 @@ hooks:
252151
--principal-id "$signed_user_id" \
253152
--scope "/" 2>/dev/null && echo " Cosmos DB role assigned successfully" || echo " Cosmos DB role may already be assigned"
254153
255-
# Build container image and deploy ACI if ACR exists and ACI was skipped
256-
skip_container=$(azd env get-value skipContainerDeployment 2>/dev/null || echo "")
257-
if [ -n "$ACR_NAME" ] && [ "$skip_container" = "true" ]; then
258-
echo ""
259-
echo "===== Building Container Image ====="
260-
echo "Building and pushing image to ACR: $ACR_NAME"
261-
262-
if az acr build --registry "$ACR_NAME" --image content-gen-app:latest --file ./src/WebApp.Dockerfile ./src; then
263-
echo "Container image built and pushed successfully!"
264-
265-
# Enable container deployment and re-provision
266-
echo ""
267-
echo "===== Deploying Container Instance ====="
268-
azd env set skipContainerDeployment false
269-
270-
echo "Re-running provision to deploy ACI..."
271-
if azd provision --no-prompt; then
272-
echo "Container Instance deployed successfully!"
273-
else
274-
echo "Container Instance deployment failed"
275-
fi
276-
else
277-
echo "Failed to build container image"
278-
fi
279-
elif [ -n "$CONTAINER_INSTANCE_NAME" ]; then
154+
if [ -n "$CONTAINER_INSTANCE_NAME" ]; then
280155
echo ""
281156
echo "Container Instance: $CONTAINER_INSTANCE_NAME"
282157
echo "Container Private IP: $CONTAINER_INSTANCE_PRIVATE_IP"
283-
elif [ -n "$ACR_NAME" ]; then
284-
echo ""
285-
echo "Container Registry: $ACR_NAME"
286158
fi
287159
288-
# Build and deploy frontend to App Service
289160
echo ""
290-
echo "===== Building Frontend ====="
291-
cd ./src/frontend
292-
if npm install && npm run build; then
293-
echo "Frontend build completed!"
294-
295-
# Copy build to frontend-server
296-
cp -r ../static/* ../frontend-server/static/ 2>/dev/null || true
297-
298-
cd ../frontend-server
299-
300-
# Create deployment package
301-
echo "Creating deployment package..."
302-
rm -f frontend-deploy.zip
303-
zip -r frontend-deploy.zip static/ server.js package.json package-lock.json
304-
305-
echo ""
306-
echo "===== Deploying Frontend to App Service ====="
307-
if az webapp deploy \
308-
--resource-group "$RESOURCE_GROUP_NAME" \
309-
--name "$APP_SERVICE_NAME" \
310-
--src-path frontend-deploy.zip \
311-
--type zip; then
312-
echo "Frontend deployed successfully!"
313-
else
314-
echo "Frontend deployment failed"
315-
fi
316-
317-
cd ../..
318-
else
319-
echo "Frontend build failed"
320-
cd ../..
321-
fi
161+
echo "Container Registry: $ACR_NAME"
322162
323163
# Run post-deploy script to upload sample data and create search index
324164
echo ""

content-gen/docs/AZD_DEPLOYMENT.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,6 @@ azd up --debug
360360

361361
If deployment gets into a bad state:
362362
```bash
363-
# Clear environment values
364-
azd env set skipContainerDeployment ""
365-
366363
# Re-run provisioning
367364
azd provision
368365
```

0 commit comments

Comments
 (0)