Below are steps to get the project up and running locally.
You the following prerequisites to get started with this project.
- Install Python 3.9.7 or 3.10
- Install Docker
- Install Docker Compose
- Install PostgreSQL
- Install SQLAlchemy
- Install FastAPI
- Create a GitHub repository
-
Clone GitHub repository
git clone https://github.com/KenMwaura1/fastapi_docker_starter
-
Change into the folder
cd fastapi_docker_starter
-
Create a virtual environment
python3 -m venv venv
- Activate the virtual environment
source ./venv/bin/activate
- For Fish shell
. venv/bin/activate.fish
-
If you are using pyenv:
3a. Create a virtualenv
pyenv virtualenv fastapi
3b. Activate the virtualenv
pyenv activate fastapi
-
Create a
.env
file and add your credentialstouch .env
OR Copy the included example
cp .env.example .env
-
Add your credentials to the
.env
fileOR
export DATABASE_URL=postgres://username:password@localhost:5432/database_name
-
Install the required dependencies
pip install -r requirements.txt
-
Make the shell script executable
chmod a+x ./run.sh
-
Run the app
./run.sh
OR run with uvicorn:
uvicorn app.main:app --reload
-
Open the browser and go tohttp://localhost:8001/home view the app running.
-
View the docs at http://localhost:8001/docs to view the API docs.
To run the app and the database in a Docker Compose file follow these steps.
Open a terminal and run the following commands.
docker-compose up
To stop the app and the database run the following commands.
docker-compose down
-- TODO: Add usage examples
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE.txt
for more information.
@Ken_Mwaura1 - kemwaura@gmail.com
Project Link: https://github.com/KenMwaura1/fastapi_docker_starter