/fastapi_docker_starter

Fastapi docker app

Primary LanguagePythonMIT LicenseMIT

FastApi Docker Quickstart Application

Docker Compose Actions Workflow

Contributors Forks Stargazers Issues MIT License LinkedIn

About The Project

Product Name Screen Shot

(back to top)

Built With

(back to top)

Getting Started

Below are steps to get the project up and running locally.

Prerequisites

You the following prerequisites to get started with this project.

  1. Install Python 3.9.7 or 3.10
  2. Install Docker
  3. Install Docker Compose
  4. Install PostgreSQL
  5. Install SQLAlchemy
  6. Install FastAPI
  7. Create a GitHub repository

Installation

  1. Clone GitHub repository

    git clone https://github.com/KenMwaura1/fastapi_docker_starter
  2. Change into the folder

    cd fastapi_docker_starter
  3. 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
    
  1. Create a .env file and add your credentials

    touch .env 
    

    OR Copy the included example

    cp .env.example .env 
    
  2. Add your credentials to the .env file

    OR

    export DATABASE_URL=postgres://username:password@localhost:5432/database_name
    
  3. Install the required dependencies

    pip install -r requirements.txt
  4. Make the shell script executable

    chmod a+x ./run.sh
  5. Run the app

    ./run.sh

    OR run with uvicorn:

    uvicorn app.main:app --reload
  6. Open the browser and go tohttp://localhost:8001/home view the app running.

  7. View the docs at http://localhost:8001/docs to view the API docs.

Docker Compose

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

(back to top)

Usage

-- TODO: Add usage examples

Contributing

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!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

@Ken_Mwaura1 - kemwaura@gmail.com

Project Link: https://github.com/KenMwaura1/fastapi_docker_starter

(back to top)

Author

Ken Mwaura