This repository provides a template for creating FastAPI applications using Uvicorn and Docker. It is designed to work seamlessly with the DigitalOcean App Platform.
- FastAPI: A modern, fast (high-performance), web framework for building APIs with Python.
- Uvicorn: An ASGI server implementation that powers FastAPI for handling web requests.
- Docker: Containerization technology to package and deploy your FastAPI application.
- DigitalOcean App Platform: Deploy your application to the DigitalOcean App Platform with ease.
Follow the steps below to get started with this FastAPI template:
-
Clone the repository
git clone https://github.com/nightzeroeth/fastapi-digitalocean-app-template.git
-
Navigate to the project directory
cd fastapi-digitalocean-app-template
-
Customize your FastAPI application
- Modify the
app.py
file to define your API routes, models, and business logic. - Install any additional Python packages your application requires by adding them to
requirements.txt
.
- Modify the
-
Build and run your Docker container
-
Ensure you have Docker installed and running on your machine.
-
Build the Docker image using the provided Dockerfile:
docker build -t my-fastapi-app .
-
Run the Docker container:
docker run -d -p 8000:8000 my-fastapi-app
-
-
Access your FastAPI application
- Open your web browser and visit
http://localhost:8000
to access your FastAPI application running inside the Docker container.
- Open your web browser and visit
Follow these steps to deploy your FastAPI application to the DigitalOcean App Platform:
-
Create a new app on the DigitalOcean App Platform
- Connect your GitHub repository to the App Platform.
- Specify the branch you want to deploy.
- Configure the deployment settings, including the Dockerfile path and any necessary environment variables.
-
Trigger the deployment
- Push your changes to the connected branch in your GitHub repository.
- The DigitalOcean App Platform will automatically detect the changes, build the Docker image, and deploy your FastAPI application.
Contributions are welcome! If you have any suggestions, feature requests, or bug reports, please open an issue or submit a pull request.
This project is licensed under the MIT License.