Skip to content

Latest commit

 

History

History
172 lines (134 loc) · 4.09 KB

README.md

File metadata and controls

172 lines (134 loc) · 4.09 KB

Deployment Guide

This directory contains everything needed to deploy the Video Processing Application to AWS.

Prerequisites

  • Docker and Docker Compose installed locally
  • Pulumi CLI installed
  • AWS CLI configured with appropriate credentials
  • Cloudflare account and API token
  • Domain name managed by Cloudflare
  • Python 3.12 or higher
  • Git (for cloning the repository)

Project Structure

deployments/
├── docker-compose.yml    # Container orchestration
├── Dockerfile           # Container build definition
├── deploy.sh           # Deployment automation script
├── Pulumi.yaml        # Pulumi project configuration
├── infra/             # Pulumi infrastructure code
│   ├── __main__.py   # Main infrastructure definition
│   └── requirements.txt  # Infrastructure dependencies
└── README.md         # This documentation

Local Development with Docker

Initial Setup

  1. Create and activate virtual environment:
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
pip install -r requirements.txt
  1. Create necessary directories:
mkdir -p uploads processed

Running the Application

  1. Build and run locally:
# Run from the project root directory
docker-compose -f deployments/docker-compose.yml up --build
  1. Access the application at http://localhost:8000

  2. Stop the application:

# Use Ctrl+C to stop, then:
docker-compose -f deployments/docker-compose.yml down

Production Deployment

Infrastructure Setup

The deployment script will:

  1. Use the project's virtual environment
  2. Install required Pulumi packages
  3. Initialize the Pulumi stack
  4. Deploy the infrastructure

Before deploying:

# Activate the project's virtual environment
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
  1. Make the deployment script executable:
# Run from the project root directory
chmod +x deployments/deploy.sh
  1. Deploy to AWS with Cloudflare integration:
# Run from the project root directory
./deployments/deploy.sh yourdomain.com your-cloudflare-api-token production

Post-Deployment

After deployment:

  1. The application will be available at your specified domain
  2. Cloudflare will automatically handle SSL/TLS
  3. The health check endpoint will monitor application status
  4. Docker will automatically restart the container if it fails

Infrastructure Details

The deployment creates:

  • VPC with proper networking
  • EC2 instance running Docker
  • Security group with necessary ports
  • DNS record in Cloudflare
  • SSL/TLS via Cloudflare's proxy

Security Features

  • Cloudflare proxy protection
  • Automated SSL/TLS certificate management
  • Restricted security group rules
  • Container isolation

Configuration

Adjust the following files for customization:

  • deployments/docker-compose.yml for container configuration
  • deployments/Dockerfile for build process
  • deployments/infra/__main__.py for infrastructure settings
  • .env for application configuration (created during deployment)

Environment Variables

HOST=0.0.0.0
PORT=80  # In production
DEBUG=False
ALLOWED_EXTENSIONS="mp4, avi, mov, mkv"
UPLOAD_DIR=uploads
PROCESSED_DIR=processed

Monitoring

The application includes a health check endpoint at /health Docker will automatically restart the container if it becomes unhealthy.

Health check configuration:

  • Interval: 30s
  • Timeout: 10s
  • Retries: 3

Cleanup

To destroy the infrastructure:

# Run from the project root directory
cd deployments/infra
pulumi destroy --yes

Local Cleanup

# Remove containers and images
docker-compose -f deployments/docker-compose.yml down --rmi all

# Clean up volumes (optional)
rm -rf uploads/* processed/*

Troubleshooting

  1. If deployment fails:

    • Check AWS credentials
    • Verify Cloudflare API token permissions
    • Review Pulumi logs
  2. If container fails to start:

    • Check docker logs
    • Verify port availability
    • Ensure directories exist
  3. For SSL/TLS issues:

    • Verify Cloudflare proxy status
    • Check DNS propagation