Skip to content

Deployment Guide

This guide covers building and deploying the application to AWS (ECR) or Azure (ACR).

Prerequisites

  • Python 3.13+
  • Node.js and npm
  • Docker Desktop (engine must be running)
  • AWS CLI configured with a named profile (for AWS deployment)
  • Azure CLI with az acr login access (for Azure deployment)

Configuration

All deployment settings are Python constants in app/settings.py — not shell environment variables.

AWS Settings

Variable Description Example
AWS_PROFILE AWS CLI named profile "edward_meetgrit"
AWS_ACCOUNT_ID AWS account ID "907965464542"
AWS_REGION AWS region "us-east-1"
IMAGE_NAME Local Docker image name "chatbot"
ECR_REPOSITORY_NAME ECR repository path "django-apprunner-chatbot/chatbot"

Azure Settings

Azure settings are nested inside the CORE_SETTINGS dictionary:

Key Description
CORE_SETTINGS['AZURE_ACR_REGISTRY_NAME'] Azure Container Registry name
CORE_SETTINGS['AZURE_ACR_REPOSITORY_NAME'] ACR repository name

Build Docker Image

Build the Docker image before deploying to either platform:

# For AWS deployment
python scripts.py build_image

# For Azure deployment
python scripts.py build_image_azure

Both commands run the same build steps:

  1. npm install — installs frontend dependencies
  2. npm run build — compiles frontend assets
  3. python manage.py collectstatic — collects static files
  4. docker buildx build --platform=linux/amd64 — builds the Docker image, tagged as latest

Deploy

AWS (ECR)

python scripts.py deploy

Steps performed:

  1. Logs in to ECR using aws ecr get-login-password with the configured AWS_PROFILE
  2. Tags the local image for the ECR registry
  3. Deletes the existing image in ECR (by tag)
  4. Pushes the new image to ECR

Azure (ACR)

python scripts.py deploy_azure

Steps performed:

  1. Logs in to ACR using az acr login
  2. Tags the local image for the ACR registry
  3. Pushes the image to ACR (ACR overwrites existing tags, so no delete step is needed)

Troubleshooting

Docker not running

Command timed out

Open Docker Desktop and ensure the engine is running. The scripts use the desktop-linux Docker context.

npm not installed

An error occurred during the build process
Make sure Node.js and npm are installed on your system.

Install Node.js and npm, then retry the build command.

AWS credentials

If ECR login fails, verify that AWS_PROFILE in app/settings.py matches a configured profile in your AWS CLI (~/.aws/credentials).

Azure credentials

If ACR login fails, ensure you have run az login and have access to the registry specified in CORE_SETTINGS['AZURE_ACR_REGISTRY_NAME'].