tiangolo / full-stack

Full stack, modern web application generator. Using Flask, PostgreSQL DB, Docker, Swagger, automatic HTTPS and more.
MIT License
523 stars 81 forks source link

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

Closed bryanray67 closed 4 years ago

bryanray67 commented 5 years ago

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

tiangolo commented 5 years ago

I'm glad it's been useful!

Yes, that's the next thing I'll do, an equivalent to this project but based on FastAPI. I hope to release it in the next days / week.

As everything is very modular, you can add your Angular code to replace the Vue.js frontend but keeping the Docker multi-stage build (if you want more details on Docker multi-stage build for Angular, check: https://medium.com/@tiangolo/angular-in-docker-with-nginx-supporting-environments-built-with-multi-stage-docker-builds-bb9f1724e984).

As the backend uses SQLAlchemy, you will be able to replace the PostgreSQL with MariaDB (or MySQL) very easily, mainly changing the Docker DB image.

About Nginx, as FastAPI is asynchronous, using Uvicorn with ASGI (instead of WSGI), is production ready, you don't need Nginx. Actually, it has some of the best achievable performances: https://fastapi.tiangolo.com/#performance

And if you use FastAPI you can use the official image: https://github.com/tiangolo/uvicorn-gunicorn-fastapi-docker

bryanray67 commented 5 years ago

Hello Sebastián. Thank you for your reply. I see your comment about Nginx is not needed if I'm using FastAPI and Uvicorn. This is my misunderstanding. I thought Nginx would be needed to serve static files (html/css etc...) and FastAPI was only for the api. I will read up on how to serve my Angular static files with Uvicorn. Regards, Bryan

tiangolo commented 5 years ago

Ah, get it. Actually, Nginx makes sense for your static files (and frontend). This stack (and the next one) have Nginx serving the frontend. But only that service. The backend is served by Uvicorn managed by Gunicorn.

tiangolo commented 5 years ago

Here it is! :tada: :cake: :rocket:

FastAPI with PostgreSQL using SQLAlchemy: https://github.com/tiangolo/full-stack-fastapi-postgresql

You can change it to MariaDB or MySQL by modifying a couple of lines in the docker-compose files and a couple of lines in the code and the Alembic configs. But as it uses SQLAlchemy, most of the code should be quite standard for any of these relational DBs.

tiangolo commented 4 years ago

Hi @bryanray67 , I'll assume you were able to solve your problem and I'll close this issue now.


If you are still using this project, I suggest you check the equivalent project generator for FastAPI that solves the same use cases in a much better way.

Because of that, this Flask-based project generator is now going to be deprecated. You are still free to use it, but it won't receive any new features, changes, or bug fixes.

Nsandomeno commented 3 years ago

@bryanray67 @tiangolo https://github.com/tiangolo/full-stack/issues/23#issuecomment-468948276

I'm having a lot of trouble fixing the Alembic config for this, any chance you can give me an idea for that?

I've done the docker-compose(image), alembic/env.py (env variables), app/core/config.py (PostgresDsn --> AnyUrl, and env variables), as well as added the drivers as dependencies in pyproject.toml (have tried all drivers because of a consistent ACCESS DENIED error from the backend with credentials that work from within the docker container itself) prior to building the image (from a clean spot as well). Here is a bit more info if anyone has a few minutes: https://github.com/PyMySQL/PyMySQL/discussions/909#discussion-77035