Giter Site home page Giter Site logo

fastapi-docker-compose's Introduction

Description

Fast api is a modern, fast (high-performance), web framework for building APIs with Python 3.7+ based on standard Python type hints.
This is a quick start with inspired from https://fastapi.tiangolo.com/deployment/docker/#build-a-docker-image-for-fastapi.

Usage

# 1. Edit FAST_API_APP in .env to select which app to use. app_basic is a simple app. See bellow for a description of available applications.
./start.sh init
# 2. Open FastApi OpenApi documentation
google-chrome http://localhost:53187/docs
# 3. Debug spa app
./start.sh npmrunstart
# 4. Open spa app
google-chrome http://localhost:3000

FastAPI : available apps

Frontend

The frontend was initialized with this command :

npx create-react-app frontend
npm run start # See port in .env

In production, the content of frontend/build is mounted as a static app in fastapi. It could also be possible to serve it with nginx.

Postgres migrations with alembic

  1. Update the model in app_sql_alchemy/app/models.py
  2. Run the following commands
./start.sh makemigrations
./start.sh migrate

Debug with Vscode

Debug works with debugpy on the server and remote debug in the IDE.

  • In docker-compose.yml, ensure the command executed for fastapi starts with 'python -m debugpy uvicorn ...'
  • In docker-compose.yml, ensure the debug port matches with the port in .vscode/launch.json
  • Run the server with './start.sh init' and then the debugger

Production

In docker-compose.yml, ensure the command executed for fastapi starts with 'gunicorn ...' with the correct number of workers (Number of recommended workers is 2 x number_of_cores + 1).

Official fastapi docker compose

This project is inspired from the official fast api docker compose project.
See folder called '{{cookiecutter.project_slug}}' in https://github.com/tiangolo/full-stack-fastapi-postgresql

Get openApi schema

See openapi.json.

Fixtures (sqlmodel)

With sqlmodel, run this command :

./start.sh fixturesqlmodel

TODO

  • Create a new app with postgres, full structure and api examples
  • Create a short video to show how to use this project

fastapi-docker-compose's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.