Coder Social home page Coder Social logo

tiangolo / full-stack Goto Github PK

View Code? Open in Web Editor NEW
523.0 24.0 81.0 540 KB

Full stack, modern web application generator. Using Flask, PostgreSQL DB, Docker, Swagger, automatic HTTPS and more.

License: MIT License

Shell 6.74% Python 59.53% Mako 0.78% TypeScript 14.38% JavaScript 0.80% HTML 1.53% Dockerfile 3.92% Vue 12.31%
python flask docker traefik letsencrypt swagger celery sqlalchemy api jwt

full-stack's Introduction

Hey! I'm @tiangolo (Sebastián Ramírez) 👋

I'm a software developer from Colombia. 🇨🇴

I currently live in Berlin, Germany. 🇩🇪

I have been building APIs and tools for Machine Learning and data systems, in Latin America, the Middle East, and now Europe, with different teams and organizations. 🌎

I created FastAPI, Typer and a bunch of other open source tools. 🚀

I like to build things with Deep Learning/Machine Learning, distributed systems, SQL and NoSQL databases, Docker, Python, TypeScript (and JavaScript), modern backend APIs, and modern frontend frameworks. 🤖

I'm currently dedicating a high percentage of my time to FastAPI, Typer, and my other open source projects. At the same time, I'm also helping a limited number of teams and organizations as an external consultant. If you would like to have my help with your team and product, feel free to contact me. 🤓

If my open source projects are useful for your product/company you can also sponsor my work on them. ☕

You can find me on:

full-stack's People

Contributors

abnerjacobsen avatar mariacamilagl avatar mcelisr1 avatar nicobytes avatar ohld avatar tiangolo 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

full-stack's Issues

Traefik on Swarm deploy

I've successfully done a swarm deploy and found it curious that while traefik gets pushed out as a proxy image in the deploy, I couldn't reach the app until i added another Traefik stack following the dockerrocks process. (which is great btw). Is that redundant, or does the app use the proxy to internally route to the public Traefik stack?

Compose file invalid when running `docker-compose up -d`

The README says to run docker-compose up -d, but the default combination of Compose files is lacking a few images:

  • proxy
  • swagger-ui
  • pgadmin
  • flower

They are found in docker-compose.admin.yml, but not sure if that's what's intended to be run locally.

Request: more documentation for configuring/setting up tasks

Specifically in development.

For example, I have added a simple task to worker.py. If I call the test_celery task I can see the response in the celeryworker logs; however, my new task does not run.

I have re-built the celery worker and read the worker.py code from within the running container so I know my new task is there, yet the task does not run when called.

I have added the task to celery_app.py where the task_routes are defined and added my new task to the main-queue like the original test task but still my test task does not run.

I am missing something somewhere?

Localhost login error after running Pytest

Once the command:

DOMAIN=backend sh ./script-test.sh

is executed, the containers are stopped and removed. To start the containers again I have used the command:

docker-compose up -d

Through localhost, Traefik, Celery, pgAdmin and Swagger services seem to work without problem, but Vue doesn't allow the login, reporting the error: "Incorrect email or password". I have followed this procedure a couple of times with identical result.

Is it because of a superuser restriction, like having to create another user to keep using the service? How could I recover the access to Vue service without reinstalling the full-stack?

backend app won't start

Following the instructions in the generated readme, when I docker-compose up -d, the backend fails to start with this error:

backend_1        | Traceback (most recent call last):
backend_1        |   File "./app/main.py", line 8, in <module>
backend_1        |     from .core import app_setup  # noqa
backend_1        |   File "./app/core/app_setup.py", line 18, in <module>
backend_1        |     from ..api.api_v1 import api as api_v1  # noqa
backend_1        |   File "./app/api/api_v1/api.py", line 8, in <module>
backend_1        |     from .api_docs import docs
backend_1        |   File "./app/api/api_v1/api_docs.py", line 3, in <module>
backend_1        |     from flask_apispec import FlaskApiSpec
backend_1        |   File "/usr/local/lib/python3.6/site-packages/flask_apispec/__init__.py", line 2, in <module>
backend_1        |     from flask_apispec.views import ResourceMeta, MethodResource
backend_1        |   File "/usr/local/lib/python3.6/site-packages/flask_apispec/views.py", line 6, in <module>
backend_1        |     from flask_apispec.annotations import activate
backend_1        |   File "/usr/local/lib/python3.6/site-packages/flask_apispec/annotations.py", line 6, in <module>
backend_1        |     from flask_apispec.wrapper import Wrapper
backend_1        |   File "/usr/local/lib/python3.6/site-packages/flask_apispec/wrapper.py", line 8, in <module>
backend_1        |     from webargs import flaskparser
backend_1        |   File "/usr/local/lib/python3.6/site-packages/webargs/__init__.py", line 7, in <module>
backend_1        |     from webargs.core import ValidationError
backend_1        |   File "/usr/local/lib/python3.6/site-packages/webargs/core.py", line 11, in <module>
backend_1        |     from webargs.fields import DelimitedList
backend_1        |   File "/usr/local/lib/python3.6/site-packages/webargs/fields.py", line 97, in <module>
backend_1        |     class DelimitedTuple(DelimitedFieldMixin, ma.fields.Tuple):
backend_1        | AttributeError: module 'marshmallow.fields' has no attribute 'Tuple'
backend_1        | unable to load app 0 (mountpoint='') (callable not found or import error)
backend_1        | *** no app loaded. GAME OVER ***
backend_1        | 2020-12-27 22:28:17,753 INFO exited: uwsgi (exit status 22; not expected)

Maybe it's the wrong version of a related package?

How to troubleshoot a service when it fails to run [workflow for docker swarm deploy]

Hi!

I'm trying to deploy a cluster using these instructions .
https://github.com/tiangolo/full-stack/blob/master/docker-swarm-cluster-deploy.md

It seem like the DB is not coming online and causing the backend to also fail after many attempts from tenacity.

$ docker service logs db tells me "no such task or service: db", but I can see it is listed with
$ docker service ls, with replicas 0/1

I don't have previous experience with swarm, is there a way to access failed service logs?
I tried following advice like print journalctl, but that doesnt seem very useful in this case. Should I include something extra to output logs?

backports.functools_lru_cache

First -- great stack. Thanks for sharing. The best swarm stack template I've come across pre-rolled.

On ubuntu 14.04 // python 2.7, I encountered this:

$ cookiecutter https://github.com/tiangolo/full-stack
Unable to load extension: No module named functools_lru_cache

This fixed it.

$ pip install backports.functools_lru_cache

Just wanted to share in case others encounter.

Modify the existing nginx configuration, including an additional nginx module

Hi!
I'm looking to try out a different configuration for nginx to see if it can resolve a rpc connection problem and came across this section on custom nginx configurations
https://github.com/tiangolo/uwsgi-nginx-flask-docker#customizing-nginx-configurations

According to the nginx docs I would need to use ngx_http_v2_module for this directive.

How can include that module in the nginx? Is there a way to include that at a later stage or should I actually rebuild the base image and import that into the backend.dockerfile.

I'm using the appropriate traefik grpc labels and traefik v1.7 with the latest grpc dependencies. I'm not sure if what I'm trying makes sense, background:

I'm trying to communicate to a Dgraph database from the backend container and after a period of inactivity the query from the client returns:
"<_Rendezvous of RPC that terminated with:
status = StatusCode.UNAVAILABLE
details = "OS Error"
debug_error_string = "{"created":"@1546772849.163482552","description":"Error received from peer","file":"src/core/lib/surface/call.cc","file_line":1036,"grpc_message":"OS Error","grpc_status":14}"

"
After retrying the same query immediately it does work like it should, if possible, I'd like to prevent this connection error from happening all together. (Also tried changing host tcp settings to recommended values with no effect)

FastAPI - Python 3.7 - Nginx - Angular - MariaDB - Docker

Hello, I recently stumbled upon your repositories and looked over the awesome work you have done. It is truly amazing what you can accomplish so quickly with Docker.

I was originally looking to set up a Docker environment with Flask-Nginx-Angular, but after looking at your amazing FastAPI project, I'm leaning in that direction.
Do you plan on creating a Docker setup with FastAPI-Python 3.7-Nginx-MariaDB-Angular?

Thanks for your amazing work!
Bryan

Expected username password for pgAdmin4 on startup after first docker-compose up

Hello,
Should I expect the pgAdmin4 username and password to be based upon the given cookiecutter variables?

i.e.
pgadmin_default_user_password
pgadmin_default_user

It seems to be the default([email protected], admin) every time I rebuild the container with new volume. I looked into docker logs for clues if something in the configuration is not right, but the only thing I noticed was that when I manually try to change the password in the UI it fails showing a

SMTP socketerror: [Errno 99]

There is no error messaging when adding a new user via user management

Error after running docker-compose up -d

I would like to get a Cluster setup with Docker Swarm Mode and Traefik, do you have more detailed docs for that? (I've just started teaching myself the cmd-line and python in the last 30 days so its hard to understand.)

How to setup Flask-Admin

I would like to add Flask-Admin to my backend. When trying to access the /admin endpoint I get a blank page but with the frontend stopped I get a 404.

To test I've added to app_setup.py the following below where sentry is initialized.

from flask_admin import Admin
admin = Admin(app, name=f"{config.PROJECT_NAME}", template_mode="bootstrap3")

I'm just kinda lost as to what needs to be changed. Any help is much appreciated.

How to add Websockets

Hi Sebastian, thank you for all your work on full-stack! Curious if you have any pointers around adding flask-socketio to add websockets alongside the API on the backend?
Hit numerous issues in trying this myself, particularly as i don't think it will work in dev with the werkzerg server (tried adding --no-reload and no debug as socketio has to run in the main thread. And i'm trying to stack deploy to staging to observe if it's just a case of not being able to run in dev but would work in other environments. Any guidance you could offer would be greatly appreciated as I'm looking to blend my Vue.js app to work both with the backend API but also leverage websockets instead of aweful chatty API polling. THANKS!

apispec marshmellow error when attempting to run app via manage.py

Hi!
I'm attempting to run the flask app with flask manager. I've simplified it abit from my last project, and it seems to be working.

Using it like this: run command $ python test-app/backend/app/manage.py runserver
manage.py:

from flask_script import Manager
manager = Manager(app)
if __name__ == '__main__':
    manager.run() 

It's been helpful already in quickly correcting a few mistakes I made instead of rebuilding the docker images. The problem I can't seem to resolve right now is, I'm running into this strange apispec error:

File "/Users/ayeg/miniconda3/envs/test-project/test-app/backend/app/app/api/api_v1/endpoints/user.py", line 75, in <module>
  def route_users_post(email=None, password=None, first_name=None, last_name=None): 
File "/Users/ayeg/miniconda3/envs/test-project/lib/python3.6/site-packages/flask_apispec/extension.py", line 119, in register
  resource_class_args, resource_class_kwargs)
File "/Users/ayeg/miniconda3/envs/test-project/lib/python3.6/site-packages/flask_apispec/extension.py", line 66, in _defer
  bound()
File "/Users/ayeg/miniconda3/envs/test-project/lib/python3.6/site-packages/flask_apispec/extension.py", line 134, in _register
  paths = self.view_converter.convert(target, endpoint, blueprint)
File "/Users/ayeg/miniconda3/envs/test-project/lib/python3.6/site-packages/flask_apispec/apidoc.py", line 37, in convert
  return [self.get_path(rule, target, **kwargs) for rule in rules]
File "/Users/ayeg/miniconda3/envs/test-project/lib/python3.6/site-packages/flask_apispec/apidoc.py", line 37, in <listcomp>
  return [self.get_path(rule, target, **kwargs) for rule in rules]
File "/Users/ayeg/miniconda3/envs/test-project/lib/python3.6/site-packages/flask_apispec/apidoc.py", line 47, in get_path
  for method, view in six.iteritems(operations)
File "/Users/ayeg/miniconda3/envs/test-project/lib/python3.6/site-packages/flask_apispec/apidoc.py", line 48, in <dictcomp>
  if method.lower() in (set(VALID_METHODS) - {'head'})
File "/Users/ayeg/miniconda3/envs/test-project/lib/python3.6/site-packages/flask_apispec/apidoc.py", line 60, in get_operation
  'parameters': self.get_parameters(rule, view, docs, parent),
File "/Users/ayeg/miniconda3/envs/test-project/lib/python3.6/site-packages/flask_apispec/apidoc.py", line 90, in get_parameters
  extra_params = converter(schema, **options) if args else []
File "/Users/ayeg/miniconda3/envs/test-project/lib/python3.6/site-packages/apispec/ext/marshmallow/openapi.py", line 441,in fields2parameters
  prop = self.fields2jsonschema(fields, use_refs=use_refs, dump=False)
File "/Users/ayeg/miniconda3/envs/test-project/lib/python3.6/site-packages/apispec/ext/marshmallow/openapi.py", line 624,in fields2jsonschema
  if field_name in exclude or (field_obj.dump_only and not dump):
AttributeError: 'str' object has no attribute 'dump_only'
(test-project) Bleep-2:test-project ayeg$ python -c "import marshmallow; print(marshmallow.__version__)"
2.16.3
(test-project) Bleep-2:test-project ayeg$ python test-app/backend/app/manage.py runserver
/Users/ayeg/miniconda3/envs/test-project/lib/python3.6/site-packages/flask_sqlalchemy/__init__.py:794: FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future.  Set it toTrue or False to suppress this warning.
'SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and '
None
Traceback (most recent call last):
File "test-app/backend/app/manage.py", line 6, in <module>
  from app.main import app
File "/Users/ayeg/miniconda3/envs/test-project/test-app/backend/app/app/main.py", line 8, in <module>
  from .core import app_setup  # noqa
File "/Users/ayeg/miniconda3/envs/test-project/test-app/backend/app/app/core/app_setup.py", line 21, in <module>
  from ..api.api_v1 import api as api_v1  # noqa
File "/Users/ayeg/miniconda3/envs/test-project/test-app/backend/app/app/api/api_v1/api.py", line 12, in <module>
  from .endpoints import user
File "/Users/ayeg/miniconda3/envs/test-project/test-app/backend/app/app/api/api_v1/endpoints/user.py", line 75, in <module>
  def route_users_post(email=None, password=None, first_name=None, last_name=None, avatar_colors=None): # noqa
File "/Users/ayeg/miniconda3/envs/test-project/lib/python3.6/site-packages/flask_apispec/extension.py", line 119, in register
  resource_class_args, resource_class_kwargs)
File "/Users/ayeg/miniconda3/envs/test-project/lib/python3.6/site-packages/flask_apispec/extension.py", line 66, in _defer
  bound()
File "/Users/ayeg/miniconda3/envs/test-project/lib/python3.6/site-packages/flask_apispec/extension.py", line 134, in _register
  paths = self.view_converter.convert(target, endpoint, blueprint)
File "/Users/ayeg/miniconda3/envs/test-project/lib/python3.6/site-packages/flask_apispec/apidoc.py", line 37, in convert
  return [self.get_path(rule, target, **kwargs) for rule in rules]
File "/Users/ayeg/miniconda3/envs/test-project/lib/python3.6/site-packages/flask_apispec/apidoc.py", line 37, in <listcomp>
  return [self.get_path(rule, target, **kwargs) for rule in rules]
File "/Users/ayeg/miniconda3/envs/test-project/lib/python3.6/site-packages/flask_apispec/apidoc.py", line 47, in get_path
  for method, view in six.iteritems(operations)
File "/Users/ayeg/miniconda3/envs/test-project/lib/python3.6/site-packages/flask_apispec/apidoc.py", line 48, in <dictcomp>
  if method.lower() in (set(VALID_METHODS) - {'head'})
File "/Users/ayeg/miniconda3/envs/test-project/lib/python3.6/site-packages/flask_apispec/apidoc.py", line 60, in get_operation
  'parameters': self.get_parameters(rule, view, docs, parent),
File "/Users/ayeg/miniconda3/envs/test-project/lib/python3.6/site-packages/flask_apispec/apidoc.py", line 90, in get_parameters
  extra_params = converter(schema, **options) if args else []
File "/Users/ayeg/miniconda3/envs/test-project/lib/python3.6/site-packages/apispec/ext/marshmallow/openapi.py", line 441,in fields2parameters
  prop = self.fields2jsonschema(fields, use_refs=use_refs, dump=False)
File "/Users/ayeg/miniconda3/envs/test-project/lib/python3.6/site-packages/apispec/ext/marshmallow/openapi.py", line 624,in fields2jsonschema
  if field_name in exclude or (field_obj.dump_only and not dump):
AttributeError: 'str' object has no attribute 'dump_only'

I haven't specified a specified an apispec version during install, should I be using an older version?
Or could this be related to python 2x vs python 3x?

There are also pylint errors throughout the endpoint files on fields.Str() objects which shows:

"module "webargs.fields" has no 'Str' member [E1101]" .

Update: When importing import marshmallow.fields as fields instead of from webargs import fields the pylint error is not shown anymore, but the marshmallow openapi.py error remains. AttributeError: 'str' object has no attribute 'dump_only'.

Br

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.