Skip to content

Commit 92234ee

Browse files
committed
add deployment docs
1 parent ef5c2ea commit 92234ee

File tree

12 files changed

+452
-8
lines changed

12 files changed

+452
-8
lines changed

deploy/.dockerignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Version control
2+
.git
3+
.gitignore
4+
5+
# Dependencies
6+
**/node_modules
7+
**/venv
8+
9+
# Build artifacts
10+
**/build
11+
**/dist
12+
**/__pycache__
13+
**/*.pyc
14+
15+
# Development files
16+
**/.env
17+
**/.env.*
18+
**/npm-debug.log
19+
**/.DS_Store

deploy/docker/Dockerfile.backend

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,20 @@ FROM python:3.8-slim
22

33
WORKDIR /app
44

5+
# Install system dependencies
6+
RUN apt-get update && apt-get install -y \
7+
build-essential \
8+
&& rm -rf /var/lib/apt/lists/*
9+
10+
# Install Python dependencies
511
COPY backend/requirements.txt .
612
RUN pip install --no-cache-dir -r requirements.txt
713

14+
# Copy application code
815
COPY backend .
916

10-
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
17+
# Create uploads directory
18+
RUN mkdir -p uploads
19+
20+
# Run with uvicorn
21+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "4"]

deploy/docker/Dockerfile.frontend

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
1-
FROM node:18-alpine
1+
FROM node:18-alpine as builder
22

33
WORKDIR /app
44

5+
# Install dependencies
56
COPY frontend/package*.json ./
6-
RUN npm install
7+
RUN npm ci
78

9+
# Copy source code
810
COPY frontend .
911

10-
CMD ["npm", "start"]
12+
# Build application
13+
RUN npm run build
14+
15+
# Production image
16+
FROM nginx:alpine
17+
18+
# Copy built assets
19+
COPY --from=builder /app/build /usr/share/nginx/html
20+
21+
# Copy nginx configuration
22+
COPY deploy/docker/nginx.conf /etc/nginx/conf.d/default.conf
23+
24+
EXPOSE 80
25+
26+
CMD ["nginx", "-g", "daemon off;"]

deploy/docker/Dockerfile.frontend.dev

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM node:18-alpine
2+
3+
WORKDIR /app
4+
5+
# Install dependencies
6+
COPY frontend/package*.json ./
7+
RUN npm install
8+
9+
# Copy source code
10+
COPY frontend .
11+
12+
# Start development server
13+
CMD ["npm", "start"]

deploy/docker/docker-compose.dev.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
version: '3.8'
2+
3+
services:
4+
backend:
5+
build:
6+
context: ../..
7+
dockerfile: deploy/docker/Dockerfile.backend
8+
ports:
9+
- "8000:8000"
10+
env_file:
11+
- ../../backend/.env
12+
volumes:
13+
- ../../backend:/app
14+
- uploads:/app/uploads
15+
command: ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
16+
depends_on:
17+
- mongodb
18+
19+
frontend:
20+
build:
21+
context: ../..
22+
dockerfile: deploy/docker/Dockerfile.frontend.dev
23+
ports:
24+
- "3000:3000"
25+
volumes:
26+
- ../../frontend:/app
27+
- /app/node_modules
28+
environment:
29+
- REACT_APP_API_URL=http://localhost:8000
30+
command: ["npm", "start"]
31+
32+
mongodb:
33+
image: mongo:latest
34+
ports:
35+
- "27017:27017"
36+
volumes:
37+
- mongodb_data:/data/db
38+
39+
volumes:
40+
mongodb_data:
41+
uploads:

deploy/docker/docker-compose.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,36 @@ services:
99
- "8000:8000"
1010
env_file:
1111
- ../../backend/.env
12+
volumes:
13+
- uploads:/app/uploads
1214
depends_on:
1315
- mongodb
16+
restart: unless-stopped
17+
healthcheck:
18+
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
19+
interval: 30s
20+
timeout: 10s
21+
retries: 3
1422

1523
frontend:
1624
build:
1725
context: ../..
1826
dockerfile: deploy/docker/Dockerfile.frontend
1927
ports:
20-
- "3000:3000"
21-
env_file:
22-
- ../../frontend/.env
28+
- "80:80"
2329
depends_on:
2430
- backend
31+
restart: unless-stopped
2532

2633
mongodb:
2734
image: mongo:latest
2835
ports:
2936
- "27017:27017"
3037
volumes:
3138
- mongodb_data:/data/db
39+
restart: unless-stopped
40+
command: ["--bind_ip", "0.0.0.0"]
3241

3342
volumes:
34-
mongodb_data:
43+
mongodb_data:
44+
uploads:

deploy/docker/nginx.conf

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
server {
2+
listen 80;
3+
server_name localhost;
4+
5+
location / {
6+
root /usr/share/nginx/html;
7+
index index.html;
8+
try_files $uri $uri/ /index.html;
9+
}
10+
11+
# Proxy API requests to backend
12+
location /api {
13+
proxy_pass http://backend:8000;
14+
proxy_http_version 1.1;
15+
proxy_set_header Upgrade $http_upgrade;
16+
proxy_set_header Connection 'upgrade';
17+
proxy_set_header Host $host;
18+
proxy_cache_bypass $http_upgrade;
19+
}
20+
21+
# Proxy WebSocket connections
22+
location /ws {
23+
proxy_pass http://backend:8000;
24+
proxy_http_version 1.1;
25+
proxy_set_header Upgrade $http_upgrade;
26+
proxy_set_header Connection "Upgrade";
27+
proxy_set_header Host $host;
28+
}
29+
}

docs/deployment/aws.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# AWS Deployment Guide
2+
3+
## Prerequisites
4+
- AWS Account with appropriate permissions
5+
- AWS CLI configured locally
6+
- Docker installed
7+
- Domain name (optional)
8+
9+
## Infrastructure Setup
10+
11+
### 1. ECR Repository Setup
12+
# Create ECR repositories for frontend and backend
13+
aws ecr create-repository --repository-name docuchat-frontend
14+
aws ecr create-repository --repository-name docuchat-backend
15+
16+
### 2. ECS Cluster Creation
17+
# Create ECS cluster
18+
aws ecs create-cluster --cluster-name docuchat-cluster
19+
20+
### 3. MongoDB Atlas Setup
21+
1. Create MongoDB Atlas cluster
22+
2. Configure network access
23+
3. Create database user
24+
4. Get connection string
25+
26+
### 4. S3 Bucket for Documents
27+
# Create S3 bucket
28+
aws s3 mb s3://docuchat-documents
29+
30+
# Enable versioning
31+
aws s3api put-bucket-versioning \
32+
--bucket docuchat-documents \
33+
--versioning-configuration Status=Enabled
34+
35+
## Application Deployment
36+
37+
### 1. Build and Push Docker Images
38+
# Login to ECR
39+
aws ecr get-login-password --region region | docker login --username AWS --password-stdin account-id.dkr.ecr.region.amazonaws.com
40+
41+
# Build and push images
42+
docker build -t docuchat-backend -f deploy/docker/Dockerfile.backend .
43+
docker tag docuchat-backend:latest account-id.dkr.ecr.region.amazonaws.com/docuchat-backend:latest
44+
docker push account-id.dkr.ecr.region.amazonaws.com/docuchat-backend:latest
45+
46+
### 2. ECS Service Deployment
47+
1. Create task definitions
48+
2. Configure services
49+
3. Set up load balancers
50+
4. Configure auto-scaling
51+
52+
### 3. CloudFront Setup
53+
1. Create distribution
54+
2. Configure SSL certificate
55+
3. Set up caching rules
56+
57+
### 4. Route53 Configuration
58+
1. Create hosted zone
59+
2. Configure DNS records
60+
3. Set up health checks
61+
62+
## Monitoring and Maintenance
63+
64+
### CloudWatch Setup
65+
# Create log groups
66+
aws logs create-log-group --log-group-name /ecs/docuchat-backend
67+
aws logs create-log-group --log-group-name /ecs/docuchat-frontend
68+
69+
### Backup Configuration
70+
- Configure S3 lifecycle rules
71+
- Set up MongoDB Atlas backups
72+
- Create backup retention policies
73+
74+
## Security Considerations
75+
- Enable AWS WAF
76+
- Configure security groups
77+
- Set up IAM roles and policies
78+
- Enable CloudTrail logging

docs/deployment/azure.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Microsoft Azure Deployment Guide
2+
3+
## Prerequisites
4+
- Azure Account
5+
- Azure CLI installed
6+
- Docker installed
7+
- Domain name (optional)
8+
9+
## Infrastructure Setup
10+
11+
### 1. Azure Container Registry
12+
# Create resource group
13+
az group create --name docuchat-rg --location eastus
14+
15+
# Create container registry
16+
az acr create --resource-group docuchat-rg \
17+
--name docuchatregistry --sku Basic
18+
19+
### 2. AKS Cluster Setup
20+
# Create AKS cluster
21+
az aks create --resource-group docuchat-rg \
22+
--name docuchat-cluster \
23+
--node-count 3 \
24+
--enable-addons monitoring
25+
26+
### 3. Azure Cosmos DB Setup
27+
1. Create Cosmos DB account
28+
2. Configure MongoDB API
29+
3. Set up backup policy
30+
31+
## Application Deployment
32+
33+
### 1. Build and Push Docker Images
34+
# Login to ACR
35+
az acr login --name docuchatregistry
36+
37+
# Build and push images
38+
docker build -t docuchatregistry.azurecr.io/docuchat-backend -f deploy/docker/Dockerfile.backend .
39+
docker push docuchatregistry.azurecr.io/docuchat-backend
40+
41+
### 2. Deploy to AKS
42+
1. Apply Kubernetes configurations
43+
2. Set up ingress controller
44+
3. Configure SSL/TLS
45+
4. Set up monitoring
46+
47+
## Monitoring and Maintenance
48+
49+
### Azure Monitor Setup
50+
- Configure Application Insights
51+
- Set up Log Analytics
52+
- Create alerts and dashboards
53+
54+
### Backup Strategy
55+
- Configure automated backups
56+
- Set up geo-replication
57+
- Create disaster recovery plan

0 commit comments

Comments
 (0)