@@ -123,7 +123,7 @@ hooks:
123123 Write-Host "===== Building Container Image =====" -ForegroundColor Yellow
124124 Write-Host "Building and pushing image to ACR: $env:ACR_NAME" -ForegroundColor Cyan
125125
126- az acr build --registry $env:ACR_NAME --image content-gen-app:latest ./src
126+ az acr build --registry $env:ACR_NAME --image content-gen-app:latest --file ./src/WebApp.Dockerfile ./src
127127
128128 if ($LASTEXITCODE -eq 0) {
129129 Write-Host "Container image built and pushed successfully!" -ForegroundColor Green
@@ -156,12 +156,66 @@ hooks:
156156 Write-Host "$env:ACR_NAME" -ForegroundColor Cyan
157157 }
158158
159+ # Build and deploy frontend to App Service
159160 Write-Host ""
160- Write-Host "===== Next Steps =====" -ForegroundColor Yellow
161- Write-Host "1. Upload product data:"
162- Write-Host " python ./scripts/product_ingestion.py --data-path ./sample_data" -ForegroundColor Cyan
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
194+
195+ # Run post-deploy script to upload sample data and create search index
196+ Write-Host ""
197+ Write-Host "===== Running Post-Deploy Script =====" -ForegroundColor Yellow
198+ Write-Host "This will upload sample data and create the search index..."
199+
200+ if (Test-Path "./scripts/post_deploy.py") {
201+ python ./scripts/post_deploy.py `
202+ --resource-group $env:RESOURCE_GROUP_NAME `
203+ --app-name $env:APP_SERVICE_NAME `
204+ --skip-tests
205+
206+ if ($LASTEXITCODE -eq 0) {
207+ Write-Host "Post-deploy script completed successfully!" -ForegroundColor Green
208+ } else {
209+ Write-Host "Post-deploy script completed with warnings (some steps may have failed)" -ForegroundColor Yellow
210+ }
211+ } else {
212+ Write-Host "Warning: post_deploy.py not found, skipping sample data upload" -ForegroundColor Yellow
213+ }
214+
215+ Write-Host ""
216+ Write-Host "===== Deployment Complete =====" -ForegroundColor Green
163217 Write-Host ""
164- Write-Host "2. Access the web application:"
218+ Write-Host "Access the web application:"
165219 Write-Host " $env:WEB_APP_URL" -ForegroundColor Cyan
166220 shell : pwsh
167221 continueOnError : false
@@ -197,7 +251,7 @@ hooks:
197251 echo "===== Building Container Image ====="
198252 echo "Building and pushing image to ACR: $ACR_NAME"
199253
200- if az acr build --registry "$ACR_NAME" --image content-gen-app:latest ./src; then
254+ if az acr build --registry "$ACR_NAME" --image content-gen-app:latest --file ./src/WebApp.Dockerfile ./src; then
201255 echo "Container image built and pushed successfully!"
202256
203257 # Enable container deployment and re-provision
@@ -223,12 +277,61 @@ hooks:
223277 echo "Container Registry: $ACR_NAME"
224278 fi
225279
280+ # Build and deploy frontend to App Service
281+ echo ""
282+ echo "===== Building Frontend ====="
283+ cd ./src/frontend
284+ if npm install && npm run build; then
285+ echo "Frontend build completed!"
286+
287+ # Copy build to frontend-server
288+ cp -r ../static/* ../frontend-server/static/ 2>/dev/null || true
289+
290+ cd ../frontend-server
291+
292+ # Create deployment package
293+ echo "Creating deployment package..."
294+ rm -f frontend-deploy.zip
295+ zip -r frontend-deploy.zip static/ server.js package.json package-lock.json
296+
297+ echo ""
298+ echo "===== Deploying Frontend to App Service ====="
299+ if az webapp deploy \
300+ --resource-group "$RESOURCE_GROUP_NAME" \
301+ --name "$APP_SERVICE_NAME" \
302+ --src-path frontend-deploy.zip \
303+ --type zip; then
304+ echo "Frontend deployed successfully!"
305+ else
306+ echo "Frontend deployment failed"
307+ fi
308+
309+ cd ../..
310+ else
311+ echo "Frontend build failed"
312+ cd ../..
313+ fi
314+
315+ # Run post-deploy script to upload sample data and create search index
316+ echo ""
317+ echo "===== Running Post-Deploy Script ====="
318+ echo "This will upload sample data and create the search index..."
319+
320+ if [ -f "./scripts/post_deploy.py" ]; then
321+ python3 ./scripts/post_deploy.py \
322+ --resource-group "$RESOURCE_GROUP_NAME" \
323+ --app-name "$APP_SERVICE_NAME" \
324+ --skip-tests \
325+ && echo "Post-deploy script completed successfully!" \
326+ || echo "Post-deploy script completed with warnings (some steps may have failed)"
327+ else
328+ echo "Warning: post_deploy.py not found, skipping sample data upload"
329+ fi
330+
226331 echo ""
227- echo "===== Next Steps ====="
228- echo "1. Upload product data:"
229- echo " python ./scripts/product_ingestion.py --data-path ./sample_data"
332+ echo "===== Deployment Complete ====="
230333 echo ""
231- echo "2. Access the web application:"
334+ echo "Access the web application:"
232335 echo " $WEB_APP_URL"
233336 shell : sh
234337 continueOnError : false
0 commit comments