LibreChat is a chat application that can be deployed on AWS using ECS (Elastic Container Service). This guide provides an overview of the architecture and steps to deploy LibreChat on AWS.
-
Local Development Environment
- Node.js (v14.x or later)
- AWS CDK CLI (
npm install -g aws-cdk
) - Docker Desktop installed and running
- AWS CLI installed and configured
- Git
-
AWS Account Requirements
- AWS Account with administrative privileges
- AWS CLI configured with appropriate credentials
- A registered domain in Route53 (if using HTTPS and Route53)
- SSL certificate in AWS Certificate Manager (if using HTTPS)
-
Clone the Repository
git clone <repository-url> cd librechat-cdk
-
Install Dependencies
npm install
-
Configure the Application
Update the following configuration files based on your requirements:
a. config/config.json
- VPC Configuration
- Region settings
- Container images
- Database configurations
- Domain settings (if using HTTPS)
{ "vpc": { "useExisting": false, "newVpc": { "maxAzs": 2, "natGateways": 1, "cidr": "10.0.0.0/16" } }, "domain": { "name": "your-domain.com", "certificateArn": "arn:aws:acm:region:account:certificate/certificate-id" } }
b. config/Libre_config/librechat.env
- Environment-specific configurations
- API keys and authentication settings
- Feature toggles and limits
c. config/Libre_config/librechat.yaml
- Application configuration
- Endpoints and API settings
- File upload limits
- Regional settings
-
Bootstrap AWS Environment (First time only)
cdk bootstrap aws://ACCOUNT-NUMBER/REGION
-
Review Infrastructure Changes
cdk diff
-
Deploy the Stack
cdk deploy --all
-
HTTP vs HTTPS
- If domain and certificate ARN are configured, the application will be deployed with HTTPS (port 443)
- Without domain configuration, the application will use HTTP (port 80)
-
Docker Requirements
- Ensure Docker Desktop is running before deployment
- The CDK stack uses Docker for lambda layer configuration.
-
Cost Considerations
- The deployment includes:
- DocumentDB cluster
- Aurora PostgreSQL serverless cluster
- NAT Gateway
- Application Load Balancer
- ECS Fargate containers
- Secrets Manager
- Review the AWS pricing calculator for estimated costs
- The deployment includes:
-
Security
- Follow AWS security best practices
- Regularly update container images and dependencies
-
Common Issues
- Docker not running: Ensure Docker Desktop is started
- CDK bootstrap errors: Verify AWS credentials and permissions
- Domain/SSL issues: Verify certificate ARN and domain configuration
- expired credentials - make sure terminal has valid aws credentials and run cdk deploy again.
-
Logs and Monitoring
- CloudWatch Logs for container logs
- CloudWatch Metrics for performance monitoring
To remove all deployed resources:
cdk destroy --all
Note: This will delete all resources including databases. Ensure you have backups if needed.