Deployment on Heroku, AWS, and DigitalOcean

Deployment on Heroku

Initial Setup

  1. Create a new project on Heroku:
  2. Create an application on Heroku and select the database (PostgreSQL recommended).

  3. Install Heroku CLI:

  4. Ensure you have heroku-cli installed and authenticated on your local machine.

Environment Preparation

  1. Create a Procfile:
  2. This file tells Heroku how to run your application:
web: gunicorn nombre_del_proyecto.wsgi
  1. Install dependencies:
  2. Include Gunicorn and any other dependencies in your requirements.txt.

Deployment

  • Use the following command to deploy your application:
git push heroku main
  • After deployment, run the database migrations:
heroku run python manage.py migrate

Deployment on AWS

Elastic Beanstalk Setup

  1. Create a new application:
  2. Log in to the AWS Management Console and create a new application in Elastic Beanstalk.

  3. Choose the platform:

  4. Select the Python platform and configure the instances according to your needs.

Database Configuration

  • Use Amazon RDS to manage the database. Ensure you select PostgreSQL or MySQL and configure it correctly.

Deployment

  • Use the AWS CLI to package and deploy your application:
eb create nombre_de_tu_entorno
  • Once the environment is created, run migrations if necessary:
eb ssh
python manage.py migrate

Deployment on DigitalOcean

Droplet Setup

  1. Create a new Droplet:
  2. Select an Ubuntu image and ensure it has internet access.

Dependency Installation

  • Connect to the server and run the following commands to install Gunicorn and Nginx:
sudo apt update
sudo apt install nginx
sudo apt install python3-gunicorn

Deployment

  • Upload your code to the server using Git or SCP and configure Gunicorn and Nginx to serve your application.