A minimal FastAPI application designed for deployment to cloud platforms (like AWS ECS, Azure Container Instances, Google Cloud Run, etc.) or any Docker-compatible environment.
- Health check endpoint (
/health) - Info endpoint (
/info) showing application and environment details - Minimal dependencies (FastAPI and Uvicorn)
- Dockerized for easy deployment
- Ready for cloud deployment
- Python 3.12+
- pip
-
Clone the repository:
git clone <repository-url> cd <repository-directory>
-
Install dependencies:
pip install -r requirements.txt
-
Run the application:
python main.py
or
uvicorn main:app --host 0.0.0.0 --port 8000
-
Open your browser to
http://localhost:8000/docsfor the API documentation (Swagger UI) or visit:- Health check:
http://localhost:8000/health - Info:
http://localhost:8000/info
- Health check:
docker build -t simple-fastapi-cloud .docker run -p 8000:8000 --env ENVIRONMENT=development simple-fastapi-cloud- Health check:
http://localhost:8000/health - Info:
http://localhost:8000/info - API docs:
http://localhost:8000/docs
This project is ready for deployment to any cloud platform that supports Docker containers. Here are some examples:
gcloud run deploy --image gcr.io/<project-id>/simple-fastapi-cloud --platform managed- Push image to ECR
- Create task definition and service
az container create --resource-group <group> --name <name> --image <acr-login-server>/simple-fastapi-cloud --dns-name-label <dns-name> --ports 8000Returns a simple health check response.
Response:
{
"status": "healthy",
"timestamp": "2024-06-29T20:05:00.123456"
}Returns application and environment information.
Response:
{
"app_name": "Simple FastAPI Cloud Project",
"app_version": "0.1.0",
"python_version": "3.12.0",
"platform": "Linux-5.15.0-105-generic-x86_64-with-glibc2.35",
"environment": "production",
"timestamp": "2024-06-29T20:05:00.123456"
}.
├── Dockerfile # Dockerfile for containerization
├── main.py # Main FastAPI application
├── requirements.txt # Python dependencies
└── README.md # This file
This project is licensed under the MIT License - see the LICENSE file for details.