Skip to content
This repository has been archived by the owner on Nov 14, 2022. It is now read-only.

Frontend / Backend separate deployment #6

Closed
valentierra opened this issue Mar 6, 2019 · 4 comments
Closed

Frontend / Backend separate deployment #6

valentierra opened this issue Mar 6, 2019 · 4 comments

Comments

@valentierra
Copy link

valentierra commented Mar 6, 2019

Hi Tiangolo

Hope everything is going great from your side!

Just a "tactical" question about how would be the best approach to accommodate this full-stack to be deployed separately:

Frontend
Netlify recently incorporated Vue to the frameworks available for deployments. To take advantage of this new feature, once you built full-stack-fastapi-couchbase's frontend, what would have to take into account to allow the exchange of information with the backend?

Backend
AWS/GCP/Heroku support the containerisation of several services. I read the dockerswarm.rocks info but when you don't have root access and not explicit IPs, how could I securely expose each service/container of the swarm to be connected by the frontend running on Netlify?

Cheers and thanks in advance for your attention!

@valentierra
Copy link
Author

Recently I came across Zeit and was impressed by its integration of services towards the serverless. I am trying to develop the Zeit builders for this full-stack. I think this is the best approach for those who just want to devote themselves to developing their own application.

@tiangolo
Copy link
Owner

Hi @valentierra ! Sorry for the delay.

I guess that using those tools/services you probably wouldn't use/need containers. The drawback might be the vendor locking I guess.

Frontend on Netlify

You can have your frontend built on Netlify building servers directly. Or if you want to do it in Docker, you can push the built code as part of the build process.

In Netlify you would get a somecustomdomain.netlify.com. You can set a DNS record (a CNAME) to point somecustomdomain.com to somecustomdomain.netlify.com. That way, whenever someone goes to somecustomdomain.com, they will see your content served from Netlify.

Frontend CORS

Then you just have to add that domain to your CORS in your backend (in the backend.env file if you use a recent version of this stack).

And that's it, it doesn't matter that your frontend is actually served by Netlify, as long as your backend has the host (https://somecustomdomain.com) in its configuration of CORS.

Backend in AWS/GCP

AWS and GCP can provide you virtual machine instances. Those are just standard Linux instances. You normally have sudo in those machines. And normally, each instance gets a fixed public IP for as long as it exists.

If you plan on removing them and changing them and you want to keep a fixed IP, you can add "floating IPs" (each one has its name for them) and then redirect them to your VM.

Backend in PaaS, Heroku, Google App Engine, etc

If you use one of the "platform as a service" systems, where you don't have control of an actual Linux instance behind, but you just provide your code to some system and it runs it, you are, more or less, in their hands. Some people like it some don't. Setting up IPs, ports, domains, HTTPS, all that is done through their custom private systems.

In that case, you would probably also use one of their "database as a service", like Heroku's Postgres, AWS and Google Cloud have their own versions and also several custom "NoSQL" versions. You would probably not use Couchbase in that scenario. But you would have to adapt your code to use those databases.

Less things to worry yourself (they handle the DB) in exchange of more vendor locking and price fee.

Backend in Function as a service

If you want to use one of the Function as a service (also called "serverless") systems, you might want to try https://github.com/erm/mangum, with it, you can put FastAPI in one of these services.

This gives even more responsibility to the service provider.

@valentierra
Copy link
Author

Thank you @tiangolo!

Impeccable answer! Your feedback is much appreciated!

I am closing the issue but keep posting if I find something with the merit to add/comment.

Cheers!

@tiangolo
Copy link
Owner

Awesome, thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants