a month ago
I would love to get a comprehensive set of advice around how I can ensure the services in my template deploy in the right order. I have some services building and deploying before the main Postgres DB, they try to run migrations on start but the DB service isn't healthy yet.
I have ran this as a project for months before converting to a template, I know that the networking is correct. Once I wait for the DB to be healthy, and click "redeploy" on the failed services, everything works fine.
Help is much appreciated, thank you!
0 Replies
a month ago
What are the specific services that you need to redeploy after DB is healthy?
I was correct. Supabase Storage, Supabase Realtime, and Supabase Auth have all failed, while Postgres was still building
Im fairly sure that services connected to other services via environment variables wait for the first service to deploy before deploying themselves.
a month ago
I'm genuinely curious as to what is lacking in the pre-existing supabase template that warrants a new supabase template?
This template includes everything other than analytics. Storage, imag transformation, a nextJS frontend app with all the auth features built in, edge functions. Not only that but I've made the repo structure what I call a "local-first" monorepo. every service points to a directory within the repo, such that when you add app logic (email templates, edge functions, DB migrations) it triggers a rebuild.
This is the best local dev experience for Supabase I've ever come across
I invite you to deploy my template and offer some advice ! That's why I started this thread lol
The issue with the previous template, other than not implementing the entire framework, was that many of the services point to docker images. I still use the official images obviously, but I do it by using the "build" context feature in docker composer yml. Every service has a directory, with a Dockerfile inside that uses the Supabase official image as a base.
Please check it out on GitHub. Anyway, yeah I'd really like to solve the deployment order
a month ago
IIRC they did that because not everything was possible to deploy, some stuff required shared volumes.
The storage service and image proxy share a volume when they use the file system mode. I included MinIO in the template and they point to it to read and write objects
a month ago
Sounds good
I also included the ability to edit transactional email templates out of the box, which has been a notorious problem most people pull their hair out over and not even Supabase's hosted platform makes that experience nice
So what's a path forward here? Are you able to check what happened in the infra provisioner that built the project from the template? Inspect my configuration of ENV vars? Why would services be building before the services they depend on?
I've deployed the template again, and having the same issue.
These services reference ${{Postgres.RAILWAY_PRIVATE_DOMAIN}} in their own ENV vars, and yet they build and deploy first. I think I'm out of options without any "insider tips" into how the infra provisioner determines what order to build services in.
This is a blocker for the publishing of my template, would really appreciate a direct look at this or some insider knowledge from an engineer who knows what the system is doing. Thanks for all your hard work!
a month ago
If two services reference each other then they will start to deploy at the same time (but they would also finish at different times), this is the only thing I can think of as to why your deployment order is out of whack.
These services reference Postgres, but it doesn't reference them. Really a curious situation…
a month ago
Yes it does.
${{Kong.JWT_EXPIRY}} & ${{Kong.JWT_SECRET}}
I just moved the 4 remaining variables into Postgres so it no longert references a single other service. Let's see what happens
a month ago
Not sure the relevance of that, you had Postgres referencing Kong
Postgres was only referencing 2 variables from Kong
Oh right, postgres only needs those 2 JWT_ vars. I moved the ANON_KEY and SERVICE KEY over to Postgres because then the only 3 vars a user needs to manually set live on the same service and go together mentally.
a month ago
Curious as to why Postgres needs JWT stuff?
There's a JWT extension used for Supabase auth. signing JWTs for users' access tokens, looking at whether a session has expired
I believe that what was happening before, is that even though Storage/Auth/Realtime all were supposed to wait for Postgres, there was another dependency chain that was given precedence for arbitrary reasons: Postgres waited for Kong which waited for Storage/Auth/Realtime. Just bad luck
In my opinion, the build order for services could be made more configurable and deterministic. But we did it! To really have a service deploy first, try and have it depend on no others if possible
a month ago
🤞
And the new fork has a little hash at the end so I can fork my own repo. Love it 🙂
I intend to build many products of my own on top of this template and it requires ejecting every time
a month ago
Sounds good!
I think we can close this thread, thanks for your time and all your hard work 🙂
a month ago
!s
Status changed to Solved brody • 29 days ago

