Deploy FastAPI on Ubuntu: CRUD with PostgreSQL, Gunicorn, and Caddy

Added:

VM Setup
PostgreSQL Config
Clone & Env
Dependencies Test
Gunicorn Service
Log Rotation
Caddy Reverse Proxy
Custom Domain SSL

VM Setup

0:01
Playing Section
  • 1

    Creates an Ubuntu 18 virtual machine on Azure cloud.

  • 2

    Enables ports 22, 80, and 443 for access and web traffic.

Basic proficiency in Python and the FastAPI framework, including defining routes and building simple CRUD (Create, Read, Update, Delete) APIs.
Fundamental Linux/Ubuntu command-line skills, such as SSHing into a server, managing files, and executing basic administrative commands.
Basic understanding of relational databases (specifically PostgreSQL) and how applications connect to them using environment variables or connection strings.
General awareness of client-server architecture, HTTP protocols, and the role of web servers versus application servers.
Containerizing the FastAPI application and PostgreSQL database using Docker and Docker Compose for consistent local and production environments.
Implementing Continuous Integration and Continuous Deployment (CI/CD) pipelines using platforms like GitHub Actions or GitLab CI to automate testing and deployment.
Application monitoring, logging, and error tracking using tools such as Prometheus, Grafana, Sentry, or ELK Stack to maintain production health.
Advanced server security and hardening techniques, including setting up UFW (Uncomplicated Firewall), fail2ban, and securing SSH access.
11.1K views101likes41:48@TutLinksOriginal Release: 2020-12-30

This tutorial demonstrates how to deploy a FastAPI application on Ubuntu 18 by setting up a PostgreSQL database for CRUD operations, configuring Gunicorn as a systemd service for production-grade execution, and using Caddy 2 as a reverse proxy to expose the application to the public internet with automatic HTTPS support.