Skip to main content

Requirements

Set up your project

  1. Create a project dir and grab the latest .env template
  1. Generate secrets with openssl rand -hex 16 for the following variables:
Do NOT just copy and paste this. Generate your own secrets instead!
.env (excerpt)
  1. Set NODE_ENV to production:
.env (excerpt)

Create a Supabase DB

Alternative: Self-host Supabase
  1. No account yet? Click here to complete onboarding
  2. Create a new project
Supabase - New Project
  1. Make a note of your password, we’ll need it in a moment
Supabase - Project Password
  1. Wait until your project has finished setting up
Supabase - Project Setup
  1. Navigate to Project Settings -> Database and copy your database connection string
Supabase - Database URL
  1. Paste it into your .env file, and append ?schema=triggerdotdev
Don’t forget to replace <PASSWORD> with the project password you set in Step 3.
.env (excerpt)
  1. The complete file should look something like this now:
.env

Self-host Trigger.dev with docker compose

  1. Create a docker compose file in your project dir
docker-compose.yml
  1. Start your docker container
  1. Wait for the database setup to finish - this might take a while
  2. You should now be able to visit http://localhost:3030 and see this screen:
Trigger.dev - Login
  1. Click “Continue with Email”, enter your email address and hit submit
  2. Grab the magic link from your terminal and proceed with account creation
Trigger.dev - CLI Magic Link
  1. If everything went well, the triggerdotdev and graphile_worker schemas should now be populated. Check your Supabase DB dashboard to be sure:
Supabase - Database Seed
  1. Congratulations, you’re all set up and ready to go with Supabase and Docker! 🚀

Bonus: Connection pooling

What is connection pooling?

Supabase - Connection Pool

Connection Pool - © 2023 Supabase, Apache License 2.0

When running on a single server, our app can be trusted to manage its own connections - it knows how many are open and can process its internal queue as needed. changes things. Here, many concurrent app instances are started, each unaware of the others’ connections. This can lead to a huge - potentially fatal - increase in connections straight to your DB.
PostgreSQL has a default connection limit of 100.
External connection pools solve this by putting an additional layer between client and server, which essentially works like a message queue that gets processed as limits allow. The clients are blind to this and can keep sending their requests as before.

Enable connection pooling

  1. Copy and paste the connection string from earlier to DIRECT_URL
.env (excerpt)
  1. Navigate to Project Settings -> Database and copy your connection pool URL
Supabase - Connection Pool URL
  1. Paste it into your .env file next to DATABASE_URL
  2. Append ?schema=triggerdotdev&pgbouncer=true and insert your password
.env (excerpt)
  1. All done! You can now enjoy the benefits of connection pooling ⚡️

Next steps

Bootstrap your Next.js project

Get started in 5 minutes.

Tunnel local traffic

Start digging with ngrok.