GithubHelp home page GithubHelp logo

jeremyandress / fastapi-docker Goto Github PK

View Code? Open in Web Editor NEW
31.0 4.0 8.0 503 KB

Docker image with FastAPI with users management, ready for production :rocket:

License: MIT License

Shell 1.93% Dockerfile 5.48% Python 91.29% Mako 1.30%
fastapi docker mysql openapi backend python fastapi-docker postgresql swagger-ui postgres

fastapi-docker's Introduction

Test license Profile

Features โœจ

  • FastAPI framework.
  • Interactive API documentation
  • Full Docker integration.
  • Docker Compose integration.
  • Production ready Python web server using Uvicorn.
  • Secure password hashing by default.
  • JWT token authentication.
  • SQLAlchemy models
  • CORS (Cross Origin Resource Sharing).
  • Small utility to paginate SqlAlchemy queries.

Requirements ๐Ÿ“Œ

  • Docker ๐Ÿณ
  • docker-compose ๐Ÿณ
  • Python 3.6+ ๐Ÿ To use without docker

Quick Start ๐ŸŒฑ

Run FastAPI Docker โšก Local Development

  1. git clone https://github.com/JeremyAndress/fastapi-docker.git
  2. Create .env files cp .env.example .env

You should now have a directory structure like:

.
โ”œโ”€โ”€ compose
โ”‚ย ย  โ”œโ”€โ”€ local
โ”‚ย ย  โ”œโ”€โ”€ production
โ”‚ย ย  โ”œโ”€โ”€ scripts
โ”‚ย ย  โ””โ”€โ”€ stage
โ”œโ”€โ”€ nginx
โ”‚ย ย  โ””โ”€โ”€ site.conf
โ”œโ”€โ”€ requirements
โ”‚ย ย  โ”œโ”€โ”€ local.txt
โ”‚ย ย  โ”œโ”€โ”€ migrations.txt
โ”‚ย ย  โ”œโ”€โ”€ mysql.txt
โ”‚ย ย  โ”œโ”€โ”€ postgre.txt
โ”‚ย ย  โ”œโ”€โ”€ production.txt
โ”‚ย ย  โ””โ”€โ”€ test.txt
โ”œโ”€โ”€ screenshots
โ”‚ย ย  โ””โ”€โ”€ ui.png
โ”œโ”€โ”€ src
โ”‚ย ย  โ”œโ”€โ”€ alembic
โ”‚ย ย  โ”œโ”€โ”€ api
โ”‚ย ย  โ”œโ”€โ”€ core
โ”‚ย ย  โ”œโ”€โ”€ db
โ”‚ย ย  โ”œโ”€โ”€ logs
โ”‚ย ย  โ”œโ”€โ”€ models
โ”‚ย ย  โ”œโ”€โ”€ __pycache__
โ”‚ย ย  โ”œโ”€โ”€ schemas
โ”‚ย ย  โ”œโ”€โ”€ tests
โ”‚ย ย  โ”œโ”€โ”€ utils
โ”‚ย ย  โ”œโ”€โ”€ alembic.ini
โ”‚ย ย  โ”œโ”€โ”€ main.py
โ”‚ย ย  โ”œโ”€โ”€ pre_start.py
โ”‚ย ย  โ””โ”€โ”€ prestart.sh
โ”œโ”€โ”€ CHANGELOG.md
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ .env.example
โ”œโ”€โ”€ .flake8
โ”œโ”€โ”€ local.yml
โ”œโ”€โ”€ production.yml
โ”œโ”€โ”€ pytest.ini
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ stage.yml
  1. docker-compose -f local.yml build
  2. docker-compose -f local.yml up -d
  3. That's just all, api server is listen at http://localhost:8030/docs now

You will see the automatic interactive API documentation (provided by Swagger UI): Swagger UI

Testing ๐Ÿšจ

    pytest -vvs src/tests/

fastapi-docker's People

Contributors

dependabot[bot] avatar jeremyandress avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

fastapi-docker's Issues

docker-compose -f local.yml build FAILS

Greetings. I successfully fired up your JeremyAndress/FastApi-simple repo. However, this one fails.

Running on Windows 10.

Thank you for any thoughts/suggestions.

`C:__repos\fastapi\fastapi-docker>docker-compose -f local.yml build
WARNING: The POSTGRES_SERVER variable is not set. Defaulting to a blank string.
Building nginx
Step 1/2 : FROM nginx:1.19.1-alpine
---> ecd67fe340f9
Step 2/2 : ADD /nginx/site.conf /etc/nginx/conf.d/default.conf
---> Using cache
---> f7fcc5aec1c4

Successfully built f7fcc5aec1c4
Successfully tagged fastapi-docker_nginx:latest
Building core
Step 1/15 : FROM python:3.6.11-alpine3.11
---> ad9bc7ab5910
Step 2/15 : ARG MYSQL_SERVER
---> Using cache
---> 36de4221a248
Step 3/15 : ARG POSTGRES_SERVER
---> Using cache
---> 5df22b7683aa
Step 4/15 : ENV ENVTYPE=local
---> Using cache
---> 92fa15be7706
Step 5/15 : ENV PYTHONUNBUFFERED 1
---> Using cache
---> 8228a1dc2c1a
Step 6/15 : ENV APP_HOME=/home/app/web
---> Using cache
---> 2a9d3c040655
Step 7/15 : RUN mkdir -p $APP_HOME
---> Using cache
---> 535b4f2e510f
Step 8/15 : WORKDIR $APP_HOME
---> Using cache
---> f4aa7c807743
Step 9/15 : ADD /compose/scripts.sh $APP_HOME
---> Using cache
---> 0c7aa2627ec4
Step 10/15 : ADD /requirements/$ENVTYPE.txt $APP_HOME
---> Using cache
---> 049bf14f50ed
Step 11/15 : RUN chmod +x scripts.sh
---> Using cache
---> 5b684b5ca32e
Step 12/15 : RUN ./scripts.sh
---> Running in 1c341fe2de08
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
(missing):
] required by: world[tzdata
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
v3.11.7-19-gd6a090b561 [http://dl-cdn.alpinelinux.org/alpine/v3.11/main]
v3.11.7 [http://dl-cdn.alpinelinux.org/alpine/v3.11/community]
OK: 11277 distinct packages available
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
(missing):
] required by: world[
: not foundh: line 5: python3-dev
./scripts.sh: line 11: syntax error: unexpected "elif" (expecting "then")
ERROR: Service 'core' failed to build : The command '/bin/sh -c ./scripts.sh' returned a non-zero code: 2

`

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.