Skip to main content

Overview

Relaciona supports multiple deployment platforms. This guide covers AWS Elastic Beanstalk, Vercel, Render, and Docker-based deployments.

AWS Elastic Beanstalk

Elastic Beanstalk provides easy deployment with Docker support. The free tier is available for eligible accounts.

Prerequisites

  • AWS account (aws.amazon.com)
  • EB CLI installed (optional but recommended)
pip install awsebcli

Deployment Files

Relaciona includes the following EB configuration: Dockerfile:
FROM python:3.11-slim
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    gcc libpq-dev python3-dev \
    && apt-get clean && rm -rf /var/lib/apt/lists/*

COPY requirements.txt /app/
RUN pip install --no-cache-dir -r requirements.txt

COPY . /app/
RUN python manage.py collectstatic --no-input

EXPOSE 8000
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "relaciona.wsgi:application"]
Dockerrun.aws.json:
{
    "AWSEBDockerrunVersion": "1",
    "Ports": [
        {
            "ContainerPort": 8000,
            "HostPort": 80
        }
    ]
}

Option 1: Web Console Deployment

1

Prepare Application

Create a ZIP file containing all project files:
zip -r relaciona.zip . -x "*.git*" -x "*__pycache__*" -x "*.pyc" -x "venv/*" -x ".env"
2

Create Application

  1. Navigate to Elastic Beanstalk in AWS Console
  2. Click Create Application
  3. Application name: relaciona-app
  4. Platform: Docker
  5. Platform branch: Docker running on 64bit Amazon Linux 2023
  6. Application code: Upload relaciona.zip
3

Configure Environment

  1. Choose Configuration presets: Single instance (free tier eligible)
  2. Click Next
4

Set Environment Variables

In Configure service accessEnvironment properties, add:
SECRET_KEY=your-generated-secret-key
DEBUG=False

# Database (RDS or external)
DB_NAME=postgres
DB_USER=your_db_user
DB_PASSWORD=your_db_password
DB_HOST=your-rds-endpoint.rds.amazonaws.com
DB_PORT=5432

# Cloudinary
CLOUDINARY_CLOUD_NAME=your-cloud-name
CLOUDINARY_API_KEY=your-api-key
CLOUDINARY_API_SECRET=your-api-secret
5

Launch

Click Create application and wait 5-10 minutes for deployment.Your app will be available at:
http://relaciona-env.eba-xxxxxxx.region.elasticbeanstalk.com

Option 2: EB CLI Deployment

1

Initialize EB

eb init -p docker relaciona-app --region eu-west-3
Follow prompts to:
  • Select region
  • Set up AWS credentials (if not configured)
2

Create Environment

eb create relaciona-env --single --instance-type t3.micro
This creates a single-instance environment (free tier eligible).
3

Set Environment Variables

eb setenv \
  SECRET_KEY="your-secret-key" \
  DEBUG="False" \
  DB_NAME="postgres" \
  DB_USER="your_user" \
  DB_PASSWORD="your_password" \
  DB_HOST="your-rds-endpoint.rds.amazonaws.com" \
  DB_PORT="5432" \
  CLOUDINARY_CLOUD_NAME="your-cloud" \
  CLOUDINARY_API_KEY="your-key" \
  CLOUDINARY_API_SECRET="your-secret"
4

Open Application

eb open

Database Setup with RDS

EB instances have ephemeral storage. Use AWS RDS for persistent database storage.
See the Database Setup guide for creating an RDS PostgreSQL instance. Key points:
  • Use db.t3.micro for free tier
  • Enable public access if connecting from outside AWS
  • Configure security groups to allow EB → RDS connections
  • Set RDS endpoint as DB_HOST environment variable

Running Migrations on EB

After deployment, SSH into your instance to run migrations:
eb ssh

# Inside the instance
docker exec -it $(docker ps -q) python manage.py migrate
docker exec -it $(docker ps -q) python manage.py createsuperuser
Or add migrations to your Dockerfile:
CMD python manage.py migrate && gunicorn --bind 0.0.0.0:8000 relaciona.wsgi:application

Updates and Redeployment

# Deploy updates
eb deploy

# View logs
eb logs

# Check status
eb status

# Terminate environment (when done)
eb terminate relaciona-env

Vercel Deployment

Vercel provides serverless deployment for Python applications.

Configuration

vercel.json:
{
    "builds": [
        {
            "src": "relaciona/wsgi.py",
            "use": "@vercel/python",
            "config": {
                "maxLambdaSize": "15mb",
                "runtime": "python3.12"
            }
        }
    ],
    "routes": [
        {
            "src": "/(.*)",
            "dest": "relaciona/wsgi.py"
        }
    ]
}

Deployment Steps

1

Install Vercel CLI

npm install -g vercel
2

Login to Vercel

vercel login
3

Deploy

vercel
Follow prompts:
  • Link to existing project or create new
  • Confirm settings
4

Set Environment Variables

In Vercel dashboard:
  1. Go to Project SettingsEnvironment Variables
  2. Add all required variables:
    • SECRET_KEY
    • DEBUG=False
    • Database credentials
    • Cloudinary credentials
  3. Set scope: Production, Preview, Development
5

Add CSRF Origins

Update settings.py to include your Vercel domain:
CSRF_TRUSTED_ORIGINS = [
    'https://*.vercel.app',
    'https://your-project.vercel.app',
]

Vercel Limitations

Important Vercel constraints:
  • Serverless functions have 10-60s timeout
  • Database connections should use connection pooling
  • No built-in database (use external PostgreSQL)
  • Static files must be served from Cloudinary/CDN
  • Limited to stateless operations

Production Deployment

vercel --prod

Render Deployment

Render provides simple deployment with managed databases.

Configuration

render.yaml:
services:
  - type: web
    name: relaciona-app
    env: python
    buildCommand: ./build.sh
    startCommand: gunicorn relaciona.wsgi:application
    envVars:
      - key: DJANGO_SETTINGS_MODULE
        value: relaciona.settings
      - key: PYTHON_VERSION
        value: 3.11
build.sh:
#!/usr/bin/env bash
set -o errexit

pip install -r requirements.txt
python manage.py collectstatic --no-input
python manage.py migrate
Render automatically runs build.sh on each deployment, making it ideal for running migrations. This ensures your database schema is always up-to-date.

Deployment Steps

1

Create Render Account

Sign up at render.com
2

Create PostgreSQL Database

  1. Click New +PostgreSQL
  2. Name: relaciona-db
  3. Plan: Free
  4. Click Create Database
  5. Note the Internal Database URL
3

Create Web Service

  1. Click New +Web Service
  2. Connect your Git repository
  3. Name: relaciona-app
  4. Environment: Python 3
  5. Build Command: ./build.sh
  6. Start Command: gunicorn relaciona.wsgi:application
4

Set Environment Variables

Add in Environment tab:
SECRET_KEY=your-secret-key
DEBUG=False

# Use Internal Database URL from your Render PostgreSQL
DB_NAME=relaciona_db_xxxx
DB_USER=relaciona_db_xxxx_user
DB_PASSWORD=generated_password
DB_HOST=dpg-xxxx.oregon-postgres.render.com
DB_PORT=5432

# Cloudinary
CLOUDINARY_CLOUD_NAME=your-cloud
CLOUDINARY_API_KEY=your-key
CLOUDINARY_API_SECRET=your-secret

# Python version
PYTHON_VERSION=3.11
5

Deploy

Click Create Web Service. Render automatically:
  • Builds your application
  • Runs migrations (via build.sh)
  • Starts the server

Render Features

  • Auto-deploy: Pushes to GitHub automatically trigger deployments
  • Free SSL: HTTPS enabled by default
  • Managed PostgreSQL: Automatic backups on paid plans
  • Zero-downtime deploys: On paid plans

Docker Deployment

Deploy using Docker on any platform that supports containers.

Build Image

docker build -t relaciona:latest .

Run Container

docker run -d \
  -p 8000:8000 \
  -e SECRET_KEY="your-secret-key" \
  -e DEBUG="False" \
  -e DB_NAME="postgres" \
  -e DB_USER="your_user" \
  -e DB_PASSWORD="your_password" \
  -e DB_HOST="your-db-host" \
  -e DB_PORT="5432" \
  -e CLOUDINARY_CLOUD_NAME="your-cloud" \
  -e CLOUDINARY_API_KEY="your-key" \
  -e CLOUDINARY_API_SECRET="your-secret" \
  --name relaciona \
  relaciona:latest

Using docker-compose

Create docker-compose.yml:
version: '3.8'

services:
  web:
    build: .
    ports:
      - "8000:8000"
    environment:
      - SECRET_KEY=${SECRET_KEY}
      - DEBUG=False
      - DB_NAME=postgres
      - DB_USER=postgres
      - DB_PASSWORD=postgres
      - DB_HOST=db
      - DB_PORT=5432
    depends_on:
      - db
    command: >
      sh -c "python manage.py migrate &&
             python manage.py collectstatic --no-input &&
             gunicorn --bind 0.0.0.0:8000 relaciona.wsgi:application"
  
  db:
    image: postgres:15
    environment:
      - POSTGRES_DB=postgres
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
    volumes:
      - postgres_data:/var/lib/postgresql/data

volumes:
  postgres_data:
Run with:
docker-compose up -d

Docker Hub Deployment

# Tag image
docker tag relaciona:latest yourusername/relaciona:latest

# Login to Docker Hub
docker login

# Push image
docker push yourusername/relaciona:latest
Deploy on any platform:
docker pull yourusername/relaciona:latest
docker run -d -p 8000:8000 --env-file .env yourusername/relaciona:latest

Static Files Serving

Relaciona uses WhiteNoise for static files, which works out-of-the-box on all platforms:
settings.py
MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'whitenoise.middleware.WhiteNoiseMiddleware',  # Serves static files
    # ...
]

STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
Static files are collected during build:
python manage.py collectstatic --no-input

Media Files with Cloudinary

All user uploads are stored on Cloudinary, ensuring files persist across deployments:
1

Create Cloudinary Account

Sign up at cloudinary.com
2

Get Credentials

Dashboard → Account Details:
  • Cloud Name
  • API Key
  • API Secret
3

Set Environment Variables

On your deployment platform:
CLOUDINARY_CLOUD_NAME=your-cloud-name
CLOUDINARY_API_KEY=123456789012345
CLOUDINARY_API_SECRET=your-secret

SSL/HTTPS Configuration

AWS Elastic Beanstalk

Use AWS Certificate Manager (ACM) and Application Load Balancer:
  1. Request SSL certificate in ACM
  2. Configure Load Balancer with HTTPS listener
  3. Update settings.py:
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
SECURE_SSL_REDIRECT = True

Vercel & Render

Automatic HTTPS - no configuration needed!

Post-Deployment Checklist

1

Verify Environment Variables

Ensure all required variables are set correctly.
2

Run Migrations

python manage.py migrate
3

Create Superuser

python manage.py createsuperuser
4

Test Application

  • Access homepage
  • Test login/registration
  • Upload media file (test Cloudinary)
  • Access admin panel
5

Update CSRF Origins

Add your production domain to CSRF_TRUSTED_ORIGINS in settings.py
6

Monitor Logs

Check application logs for errors:
  • AWS EB: eb logs
  • Vercel: Dashboard → Deployments → View logs
  • Render: Dashboard → Logs tab
  • Docker: docker logs relaciona

Troubleshooting

Solution:
  1. Run python manage.py collectstatic --no-input
  2. Verify WhiteNoise is in MIDDLEWARE (after SecurityMiddleware)
  3. Check STATIC_ROOT and STATICFILES_STORAGE settings
  4. Ensure build process includes collectstatic
Solution:
  1. Verify all DB_* environment variables are set correctly
  2. Check database host is accessible (security groups, firewall)
  3. Confirm PostgreSQL is running
  4. Test connection: python manage.py dbshell
  5. For cloud databases, ensure IP whitelist includes your platform
Solution:
  1. Set DEBUG=True temporarily to see detailed error
  2. Check application logs
  3. Verify SECRET_KEY is set
  4. Ensure migrations are up to date
  5. Check ALLOWED_HOSTS includes your domain
Solution:
  1. Verify Cloudinary credentials are correct
  2. Check CLOUDINARY_* environment variables
  3. Test Cloudinary connection in Django shell:
    from django.core.files.storage import default_storage
    print(default_storage.__class__)
    
  4. Ensure Cloudinary is in INSTALLED_APPS
Solution:
  1. Add your domain to CSRF_TRUSTED_ORIGINS:
    CSRF_TRUSTED_ORIGINS = [
        'https://yourdomain.com',
        'https://*.vercel.app',
    ]
    
  2. For localhost development, ensure domain includes port:
    CSRF_TRUSTED_ORIGINS = ['http://localhost:8000']
    

Next Steps

Environment Variables

Reference for all environment variables

Database Setup

PostgreSQL configuration and management

Configuration

Django settings reference

Build docs developers (and LLMs) love