Application Deployment - Install Docker, configure environment, and deploy the Relvy application on your EC2 instance.

Overview

This section guides you through deploying the Relvy application on your EC2 instance. We’ll install Docker, configure environment variables, and deploy the application using docker-compose.

Deployment Components

Docker Installation

Install Docker and Docker Compose on EC2

Repository Setup

Clone Relvy repository and configure files

Environment Configuration

Set up environment variables and configuration

Application Launch

Deploy and start the Relvy application

Prerequisites

Before deploying the application, ensure you have:

  • AWS Infrastructure - EC2 instance running and accessible
  • Domain Configuration - SSL certificate and DNS records configured
  • Database Access - RDS endpoint and credentials
  • Slack Integration - App credentials (if using Slack)
  • SSH Access - EC2 key pair and SSH access

Step 1: SSH into EC2 Instance

# SSH into your EC2 instance
ssh -i relvy-app-key.pem ec2-user@<EC2_IP_ADDRESS>

Step 2: Install Docker and Docker Compose

2.1 Install Docker

Run the following script to install Docker and Docker Compose:

#!/bin/bash

# Update system packages
sudo yum update -y

# Install Docker
sudo yum install -y docker

# Start and enable Docker service
sudo systemctl start docker
sudo systemctl enable docker

# Add ec2-user to docker group
sudo usermod -a -G docker ec2-user

# Install Docker Compose
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

# Create symlink to avoid sudo for docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

# Test Docker installation
sudo docker run hello-world

# Display versions
echo "Docker version:"
sudo docker --version
echo "Docker Compose version:"
sudo docker-compose --version

echo "Installation complete! Please log out and back in for group changes to take effect"

Important - You must log out and log back in for the docker group changes to take effect.


### 2.2 Verify Installation

```bash
# Log out and back in for group changes to take effect
exit
ssh -i relvy-app-key.pem ec2-user@<EC2_IP_ADDRESS>

# Verify Docker works without sudo
docker --version
docker-compose --version

# Test Docker functionality
docker run hello-world

Step 3: Clone Relvy Repository

3.1 Clone Repository

# Clone the Relvy repository
git clone https://github.com/Relvy-AI/relvyai.git
cd relvyai

# List contents to verify
ls -la

3.2 Verify Repository Contents

# Check for docker-compose.yml (required for deployment)
ls -la docker-compose.yml

Docker Compose Services - The deployment includes Redis, database migrations, Celery worker, and web application services.

Step 4: Configure Environment Variables

4.1 Create Environment File

# Create an environment file
nano .env

4.2 Configure Required Variables

Set the following environment variables in your .env file:

# Server Configuration
SERVER_HOSTNAME=yourdomain.com

# Database Configuration
POSTGRES_PASSWORD=your_secure_database_password
POSTGRES_ENDPOINT=your-rds-endpoint.region.rds.amazonaws.com
POSTGRES_USER=postgres
POSTGRES_DB=relvydb

# Slack Configuration (if using Slack integration)
SLACK_CLIENT_ID=your_slack_client_id
SLACK_CLIENT_SECRET=your_slack_client_secret

4.3 Environment Variable Reference

VariableDescriptionRequiredExample
SERVER_HOSTNAMEYour domain nameYesrelvy.yourcompany.com
POSTGRES_PASSWORDDatabase passwordYesSecurePassword123!
POSTGRES_ENDPOINTRDS endpointYesrelvy-db.xxxxx.us-west-2.rds.amazonaws.com
POSTGRES_USERDatabase usernameNo (default: postgres)postgres
POSTGRES_DBDatabase nameNo (default: relvydb)relvydb
SLACK_CLIENT_IDSlack app client IDNo123456789.123456789
SLACK_CLIENT_SECRETSlack app client secretNoabc123def456...

Step 5: Docker Login

5.1 Login to Docker Registry

# Login to Docker registry
docker login -u relvyuser

# Enter your access token when prompted for password

Note - Contact us to request an access token for Docker registry access.

Step 6: Deploy Application

6.1 Pull Docker Images

# Pull the required Docker images
docker-compose pull

# Verify images are downloaded
docker images

6.2 Start Application

# Start the application in detached mode
docker-compose up -d

# Check application status
docker-compose ps

6.3 Monitor Application Startup

# View application logs
docker-compose logs -f

# Check individual service logs
docker-compose logs -f app
docker-compose logs -f database

Startup Time - The application may take 2-5 minutes to fully start up. Monitor logs for any errors.

Step 7: Verify Deployment

7.1 Check Application Health

# Test from load balancer
curl -I https://yourdomain.com/health

7.2 Verify Database Connection

# Test database connectivity
docker-compose exec app psql -h $POSTGRES_ENDPOINT -U postgres -d relvydb -c "SELECT version();"

7.3 Check Service Status

# Check all running containers
docker-compose ps

# Check resource usage
docker stats

# Verify network connectivity
docker network ls
docker network inspect relvyai_default

Step 8: Configure Application

8.1 Access Application

  1. Open your browser
  2. Navigate to https://yourdomain.com
  3. You should see the Relvy landing page

8.2 Initial Setup

Follow the on-screen instructions to:

  • Create your first user account
  • Configure basic settings
  • Set up initial integrations

Troubleshooting

Common Issues

IssueSolution
Docker permission deniedLog out and back in, or run newgrp docker
Database connection failedVerify RDS endpoint and security group rules
Application not startingCheck logs with docker-compose logs -f
Domain not accessibleVerify DNS records and load balancer configuration
SSL certificate errorsCheck certificate validation and ALB configuration

Debug Commands

# Check application logs
docker-compose logs -f

# Restart application
docker-compose restart

# Check container status
docker-compose ps

# Test database connectivity
docker-compose exec app nc -zv $POSTGRES_ENDPOINT 5432

# Check environment variables
docker-compose exec app env | grep -E "(POSTGRES|SLACK|SERVER)"

Performance Monitoring

# Monitor resource usage
docker stats

# Check disk usage
df -h

# Monitor memory usage
free -h

# Check network connectivity
netstat -tulpn

Application Management

8.1 Start/Stop Application

# Stop application
docker-compose down

# Start application
docker-compose up -d

# Restart application
docker-compose restart

8.2 Update Application

# Pull latest images
docker-compose pull

# Restart with new images
docker-compose up -d

# Clean up old images
docker image prune -f

Deployment Complete - Your Relvy application is now deployed and running! Keep track of:

Next Steps

Your Relvy application is now deployed! The next steps are:

  1. Complete Initial Setup - Configure users and settings in Initial Setup
  2. Test Integration - Verify Slack integration (if configured)
  3. Monitor Performance - Set up monitoring and alerting

Deployment Successful - Relvy is now running on your infrastructure and ready for incident response workflows.