akashkolte commited on
Commit
55a5eba
Β·
1 Parent(s): fa02816

added docker file

Browse files
Files changed (3) hide show
  1. .dockerignore +9 -0
  2. Dockerfile +27 -0
  3. deploy.sh +92 -0
.dockerignore ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ .git
2
+ .venv
3
+ .env
4
+ .claude
5
+ .code-review-graph
6
+ frontend/node_modules
7
+ **/__pycache__
8
+ **/*.pyc
9
+ logs/*.jsonl
Dockerfile ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Stage 1 β€” build React frontend
2
+ FROM node:22-alpine AS frontend-build
3
+ WORKDIR /app/frontend
4
+ RUN npm install -g pnpm
5
+ COPY frontend/package.json frontend/pnpm-lock.yaml ./
6
+ RUN pnpm install --frozen-lockfile
7
+ COPY frontend/ ./
8
+ RUN pnpm build
9
+
10
+ # Stage 2 β€” Python backend + static frontend
11
+ FROM python:3.11-slim
12
+ WORKDIR /app
13
+
14
+ # CPU-only torch first β€” keeps image ~1.5 GB smaller than default GPU wheel
15
+ RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu
16
+
17
+ COPY requirements.txt .
18
+ RUN pip install --no-cache-dir -r requirements.txt
19
+
20
+ COPY backend/ ./backend/
21
+ COPY data/ ./data/
22
+ COPY --from=frontend-build /app/frontend/dist ./frontend/dist
23
+
24
+ RUN mkdir -p logs
25
+
26
+ EXPOSE 8000
27
+ CMD ["uvicorn", "backend.api.main:app", "--host", "0.0.0.0", "--port", "8000"]
deploy.sh ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ # ── Config β€” edit these before running ────────────────────────────────────────
5
+ RESOURCE_GROUP="aac-chatbot"
6
+ LOCATION="eastus"
7
+ REGISTRY_NAME="aacchatbotregistry"
8
+ APP_NAME="aac-chatbot"
9
+ ENV_NAME="aac-env"
10
+ IMAGE="$REGISTRY_NAME.azurecr.io/$APP_NAME:latest"
11
+
12
+ # Load from .env if present, else require them to be set in shell
13
+ if [ -f .env ]; then
14
+ export $(grep -v '^#' .env | xargs)
15
+ fi
16
+
17
+ if [ -z "$PRIMARY_API_KEY" ]; then
18
+ echo "ERROR: PRIMARY_API_KEY not set. Add it to .env or export it."
19
+ exit 1
20
+ fi
21
+
22
+ PRIMARY_MODEL="${PRIMARY_MODEL:-gemini-3-flash-preview}"
23
+ PRIMARY_BASE_URL="${PRIMARY_BASE_URL:-https://generativelanguage.googleapis.com/v1beta/openai/}"
24
+ FALLBACK_MODEL="${FALLBACK_MODEL:-$PRIMARY_MODEL}"
25
+ FALLBACK_BASE_URL="${FALLBACK_BASE_URL:-$PRIMARY_BASE_URL}"
26
+ FALLBACK_API_KEY="${FALLBACK_API_KEY:-$PRIMARY_API_KEY}"
27
+
28
+ echo "==> Logging in to Azure..."
29
+ az login --only-show-errors
30
+
31
+ echo "==> Registering providers (safe to re-run)..."
32
+ az provider register -n Microsoft.ContainerRegistry --wait
33
+ az provider register -n Microsoft.OperationalInsights --wait
34
+ az provider register -n Microsoft.App --wait
35
+
36
+ echo "==> Creating resource group..."
37
+ az group create --name $RESOURCE_GROUP --location $LOCATION --only-show-errors
38
+
39
+ echo "==> Creating container registry..."
40
+ az acr create \
41
+ --name $REGISTRY_NAME \
42
+ --resource-group $RESOURCE_GROUP \
43
+ --sku Basic \
44
+ --admin-enabled true \
45
+ --only-show-errors
46
+
47
+ echo "==> Logging in to container registry..."
48
+ az acr login --name $REGISTRY_NAME
49
+
50
+ echo "==> Building and pushing image (linux/amd64)..."
51
+ docker buildx create --use --name aac-builder 2>/dev/null || docker buildx use aac-builder
52
+ docker buildx build \
53
+ --platform linux/amd64 \
54
+ --push \
55
+ -t $IMAGE .
56
+
57
+ echo "==> Creating Container Apps environment..."
58
+ az containerapp env create \
59
+ --name $ENV_NAME \
60
+ --resource-group $RESOURCE_GROUP \
61
+ --location $LOCATION \
62
+ --only-show-errors
63
+
64
+ echo "==> Deploying container app..."
65
+ az containerapp create \
66
+ --name $APP_NAME \
67
+ --resource-group $RESOURCE_GROUP \
68
+ --environment $ENV_NAME \
69
+ --image $IMAGE \
70
+ --registry-server $REGISTRY_NAME.azurecr.io \
71
+ --target-port 8000 \
72
+ --ingress external \
73
+ --min-replicas 1 \
74
+ --only-show-errors \
75
+ --env-vars \
76
+ PRIMARY_MODEL="$PRIMARY_MODEL" \
77
+ PRIMARY_BASE_URL="$PRIMARY_BASE_URL" \
78
+ PRIMARY_API_KEY="$PRIMARY_API_KEY" \
79
+ FALLBACK_MODEL="$FALLBACK_MODEL" \
80
+ FALLBACK_BASE_URL="$FALLBACK_BASE_URL" \
81
+ FALLBACK_API_KEY="$FALLBACK_API_KEY"
82
+
83
+ echo ""
84
+ echo "==> Done! Your app is live at:"
85
+ az containerapp show \
86
+ --name $APP_NAME \
87
+ --resource-group $RESOURCE_GROUP \
88
+ --query properties.configuration.ingress.fqdn \
89
+ --output tsv | sed 's/^/https:\/\//'
90
+
91
+ # delete everything
92
+ # az group delete --name aac-chatbot --yes