This repository provides a starter setup for developing a FastAPI application using VS Code Dev Containers or Docker Compose. It enables a smooth development workflow, allowing you to choose between VS Code's built-in Dev Container environment or using Docker Compose with your preferred IDE.
- FastAPI development environment pre-configured.
- Option to use VS Code Dev Containers for a seamless, containerized development experience.
- Docker Compose support for easy environment setup and flexibility with IDE choice.
- Integrated API documentation available at
/docs
.
-
Clone the Repository:
git clone git@github.com:optimisticupdate/fastapi-starter.git cd fastapi-starter touch .env
-
Start VS Code:
Ensure you have the Dev Containers extension installed. -
Open the Project in a Dev Container:
- Click on the "Reopen in Container" prompt in VS Code.
-
Run the Application:
Open the VS Code terminal and execute:fastapi dev app/main.py --host 0.0.0.0
-
Access the application locally at:
- Application: http://127.0.0.1:8000
- API Docs: http://127.0.0.1:8000/docs
-
Start the Bash Session in the API Container:
make bash
-
The
api
container will start and open a bash shell. From there, run:fastapi dev app/main.py --host 0.0.0.0
-
Access the application locally at:
- Application: http://127.0.0.1:8000
- API Docs: http://127.0.0.1:8000/docs
- VS Code with the Dev Containers extension.
- Docker and Docker Compose installed.
- Make (for using the
make
commands).
.
├── app
│ ├── main.py # FastAPI application entry point
│ └── ...
├── .devcontainer # VS Code Dev Container configuration
├── docker-compose.yml # Docker Compose configuration
├── Makefile # Automation of common tasks
└── README.md # Project documentation
-
FastAPI Documentation: https://fastapi.tiangolo.com/
Guide to FastAPI -
VS Code Dev Containers Documentation: https://code.visualstudio.com/docs/devcontainers/containers
Official documentation for developing inside containers using Visual Studio Code.
Contributions, issues, and feature requests are welcome!