A simple REST API built with FastAPI for deployment on Hetzner using Coolify.
- RESTful API with CRUD operations
- Interactive API documentation via Swagger UI
- PostgreSQL database with Tortoise ORM
- Docker and Docker Compose support with automatic port detection
- Easy deployment to Coolify
# Setup and activate virtual environment on Windows
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt
# Run the application
python start.py# Using Docker Compose (recommended)
docker-compose up -d
# Using Docker directly
docker build -t fastapi-app .
docker run -p 8080:8000 -e PORT=8000 fastapi-appGET /: Welcome messageGET /items: List all itemsPOST /items: Create a new itemGET /items/{item_id}: Get an item by IDPUT /items/{item_id}: Update an itemDELETE /items/{item_id}: Delete an itemGET /health: Health check endpoint
API documentation available at: /docs
The application uses the following environment variables:
# API configuration
API_PORT=8080
PORT=8000
# Database configuration
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=mydb
POSTGRES_PORT=5432
POSTGRES_HOST=postgres
# App configuration
APP_NAME=FastAPI REST API with Tortoise ORM
APP_VERSION=1.0.0
APP_DESCRIPTION=A RESTful API built with FastAPI and Tortoise ORM for deployment on Hetzner with Coolify- Push code to a Git repository
- Set up Coolify on your Hetzner server
- Add a new service in Coolify linked to your repository
- Configure environment variables in Coolify
- Deploy the application
For detailed deployment instructions, see DEPLOY_COOLIFY.md.