tiangolo / full-stack-fastapi-template

Full stack, modern web application template. Using FastAPI, React, SQLModel, PostgreSQL, Docker, GitHub Actions, automatic HTTPS and more.
MIT License
24.44k stars 4.12k forks source link

VITE_API_URL at runtime & optional traefik #1209

Open elsampsa opened 1 month ago

elsampsa commented 1 month ago

Synopsis

This version makes it easier to deploy the fullstack example into cloud services (gcp, aws, azure, etc.).

API endpoint for frontend

Earlier, the argument VITE_API_URL was used at image build time and "hardcoded" into the docker image.

Now it is updated dynamically at container run time, so that deployment (as defined by .env) becomes decoupled from the build.

One defines the API endpoint for the frontend in the .env file with FRONTEND_API_TARGET.

Optional traefik

In the cloud, one might prefer to let the cloud provider to handle ssh, load-balancing, etc. (and also use cloud provider's "native" postgresql). Using traefik or not, can now be defined in the .env file with parameter TRAEFIK:

TRAEFIK=some-value # use traefik
TRAEFIK= # do not use traefik

Thanks for the awesome repo & considering this pull request. :)

P. S. I will add this repo as a subrepo into here:

https://github.com/elsampsa/fastapi-fullstack-cloud-deploy/tree/main