Deployment Guide - usmantahirr/infobip-notification-service GitHub Wiki
This guide provides instructions for deploying the Infobip Notification Service in various environments.
- Node.js 18.x or later
- npm 9.x or later
- Git
- Infobip API credentials
- (Optional) PostgreSQL 14.x or later
- (Optional) Redis 6.x or later
-
Clone the repository:
git clone https://github.com/usmantahirr/infobip-notification-service.git cd infobip-notification-service
-
Install dependencies:
npm install
-
Create environment file:
cp .env.example .env
-
Configure environment variables in
.env
:# Application NODE_ENV=production PORT=3000 # Infobip INFOBIP_API_KEY=your_api_key INFOBIP_BASE_URL=your_base_url INFOBIP_SENDER_EMAIL=your_verified_sender_email INFOBIP_SENDER_NUMBER=your_sender_number # Rate Limiting RATE_LIMIT_WINDOW=60000 RATE_LIMIT_MAX_REQUESTS=100 # (Optional) Database DATABASE_URL=postgresql://user:password@localhost:5432/notification_service # (Optional) Redis REDIS_URL=redis://localhost:6379
-
Start the development server:
npm run dev
-
Access the API documentation:
http://localhost:3000/api-docs
-
Build the Docker image:
docker build -t infobip-notification-service .
-
Run the container:
docker run -d \ -p 3000:3000 \ -e NODE_ENV=production \ -e INFOBIP_API_KEY=your_api_key \ -e INFOBIP_BASE_URL=your_base_url \ -e INFOBIP_SENDER_EMAIL=your_verified_sender_email \ -e INFOBIP_SENDER_NUMBER=your_sender_number \ infobip-notification-service
-
Create a ConfigMap for environment variables:
apiVersion: v1 kind: ConfigMap metadata: name: notification-service-config data: NODE_ENV: "production" PORT: "3000" RATE_LIMIT_WINDOW: "60000" RATE_LIMIT_MAX_REQUESTS: "100"
-
Create a Secret for sensitive data:
apiVersion: v1 kind: Secret metadata: name: notification-service-secrets type: Opaque data: INFOBIP_API_KEY: <base64-encoded-api-key> INFOBIP_BASE_URL: <base64-encoded-base-url> INFOBIP_SENDER_EMAIL: <base64-encoded-sender-email> INFOBIP_SENDER_NUMBER: <base64-encoded-sender-number>
-
Deploy the application:
apiVersion: apps/v1 kind: Deployment metadata: name: notification-service spec: replicas: 3 selector: matchLabels: app: notification-service template: metadata: labels: app: notification-service spec: containers: - name: notification-service image: infobip-notification-service:latest ports: - containerPort: 3000 envFrom: - configMapRef: name: notification-service-config - secretRef: name: notification-service-secrets resources: requests: cpu: "100m" memory: "256Mi" limits: cpu: "500m" memory: "512Mi" readinessProbe: httpGet: path: /health port: 3000 initialDelaySeconds: 5 periodSeconds: 10 livenessProbe: httpGet: path: /health port: 3000 initialDelaySeconds: 15 periodSeconds: 20
-
Create a Service:
apiVersion: v1 kind: Service metadata: name: notification-service spec: selector: app: notification-service ports: - port: 80 targetPort: 3000 type: LoadBalancer
-
Create an ECR repository:
aws ecr create-repository --repository-name infobip-notification-service
-
Push the Docker image:
aws ecr get-login-password --region region | docker login --username AWS --password-stdin aws_account_id.dkr.ecr.region.amazonaws.com docker tag infobip-notification-service:latest aws_account_id.dkr.ecr.region.amazonaws.com/infobip-notification-service:latest docker push aws_account_id.dkr.ecr.region.amazonaws.com/infobip-notification-service:latest
-
Create an ECS task definition:
{ "family": "notification-service", "networkMode": "awsvpc", "requiresCompatibilities": ["FARGATE"], "cpu": "256", "memory": "512", "containerDefinitions": [ { "name": "notification-service", "image": "aws_account_id.dkr.ecr.region.amazonaws.com/infobip-notification-service:latest", "portMappings": [ { "containerPort": 3000, "protocol": "tcp" } ], "environment": [ { "name": "NODE_ENV", "value": "production" } ], "secrets": [ { "name": "INFOBIP_API_KEY", "valueFrom": "arn:aws:ssm:region:account:parameter/notification-service/INFOBIP_API_KEY" } ], "logConfiguration": { "logDriver": "awslogs", "options": { "awslogs-group": "/ecs/notification-service", "awslogs-region": "region", "awslogs-stream-prefix": "ecs" } } } ] }
- Winston logging
- Basic error tracking
- Rate limit monitoring
-
Metrics Collection
- Prometheus metrics
- Custom metrics for:
- Request counts
- Error rates
- Response times
- Queue sizes
-
Logging
- Structured logging
- Log aggregation
- Log retention policies
-
Tracing
- OpenTelemetry integration
- Distributed tracing
- Performance monitoring
- Horizontal scaling via container orchestration
- Rate limiting per instance
- Basic load balancing
-
Database Scaling
- Read replicas
- Connection pooling
- Query optimization
-
Caching Layer
- Redis caching
- Cache invalidation
- Cache warming
-
Queue Management
- Message prioritization
- Dead letter queues
- Retry policies
- API key authentication
- Rate limiting
- Security headers
- CORS configuration
-
Authentication
- JWT support
- OAuth2 integration
- API key rotation
-
Network Security
- WAF integration
- DDoS protection
- VPC configuration
-
Data Security
- Encryption at rest
- TLS 1.3
- Audit logging
- Basic error handling
- Container health checks
- Automatic restarts
-
Data Backup
- Automated backups
- Point-in-time recovery
- Backup verification
-
Disaster Recovery
- Multi-region deployment
- Failover procedures
- Recovery testing
-
High Availability
- Load balancing
- Auto-scaling
- Circuit breakers
-
Updates
- Node.js updates
- Dependency updates
- Security patches
-
Monitoring
- Log analysis
- Performance monitoring
- Error tracking
-
Backup
- Database backups
- Configuration backups
- Recovery testing
-
Service Outage
- Incident response
- Communication plan
- Recovery steps
-
Data Issues
- Data validation
- Recovery procedures
- Integrity checks
-
Security Incidents
- Incident response
- Forensic analysis
- Remediation steps
Last updated: March 5