dub icon indicating copy to clipboard operation
dub copied to clipboard

Self host instructions

Open ThatOneCalculator opened this issue 3 years ago • 11 comments

There should be instructions on how to self-host on a server without Vercel.

ThatOneCalculator avatar Sep 22 '22 19:09 ThatOneCalculator

@steven-tey your lack of instructions leads to a lot of confusion, especially since you didn't even fill out the entire .env.production for self hosting. UPSTASH_REDIS_REST_URL isn't in the example env, nor did you explain that it's needed or even what it's for.

➜  dub git:(main) ✗ yarn run start --port 3839
yarn run v1.22.15
$ next start --port 3839
ready - started server on 0.0.0.0:3839, url: http://localhost:3839
info  - Loaded env from /root/dub/.env.production
Error: Unable to find environment variable: `UPSTASH_REDIS_REST_URL`
    at <unknown> (evalmachine.<anonymous>:4594)
    at Function.fromEnv (evalmachine.<anonymous>:4594:19)
    at Object.397 (evalmachine.<anonymous>:926:40)
    at __webpack_require__ (evalmachine.<anonymous>:25:42)
    at Object.3207 (evalmachine.<anonymous>:365:19)
    at __webpack_require__ (evalmachine.<anonymous>:25:42)
    at __webpack_exec__ (evalmachine.<anonymous>:5494:48)
    at <unknown> (evalmachine.<anonymous>:5495:57)
    at Function.__webpack_require__.O (evalmachine.<anonymous>:63:23)
    at <unknown> (evalmachine.<anonymous>:5496:56)
    at webpackJsonpCallback (evalmachine.<anonymous>:158:39)
[next-auth][error][NO_SECRET] 
https://next-auth.js.org/errors#no_secret Please define a `secret` in production. MissingSecret [MissingSecretError]: Please define a `secret` in production.
    at assertConfig (/root/dub/node_modules/next-auth/core/lib/assert.js:42:12)
    at NextAuthHandler (/root/dub/node_modules/next-auth/core/index.js:70:52)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async NextAuthNextHandler (/root/dub/node_modules/next-auth/next/index.js:23:19)
    at async /root/dub/node_modules/next-auth/next/index.js:59:32
    at async Object.apiResolver (/root/dub/node_modules/next/dist/server/api-utils/node.js:366:9)
    at async NextNodeServer.runApi (/root/dub/node_modules/next/dist/server/next-server.js:481:9)
    at async Object.fn (/root/dub/node_modules/next/dist/server/next-server.js:735:37)
    at async Router.execute (/root/dub/node_modules/next/dist/server/router.js:247:36)
    at async NextNodeServer.run (/root/dub/node_modules/next/dist/server/base-server.js:347:29) {
  code: 'NO_SECRET'
}

ThatOneCalculator avatar Sep 22 '22 19:09 ThatOneCalculator

Sorry about that, I ran out of time to write the self-host instructions – I'm going to tackle that tonight! Thanks for the message! :)

steven-tey avatar Sep 22 '22 20:09 steven-tey

Update: Started working on this in this PR: https://github.com/steven-tey/dub/pull/16

Added some self-hosted setup instructions in the .env.example file + included the required env vars in the Vercel deploy button (it's not perfect yet but it's a start)

steven-tey avatar Sep 23 '22 04:09 steven-tey

It's still a bit confusing though with the redis upstart URL and the Vercel token -- is there (going to be) a way to host this without relying on cloud providers like vercel? I just wanna stick this on my homelab and not worry about another provider.

ThatOneCalculator avatar Sep 23 '22 04:09 ThatOneCalculator

Maybe someone could even package all of that into a docker image?

ovizii avatar Sep 23 '22 15:09 ovizii

Crossposting over from https://github.com/steven-tey/dub/issues/25:

To be completely honest I'm not very familiar with docker – if someone can PR this option into a branch (i.e. docker) I'm more than happy to feature it in the README as one of the self-hosted options :)

steven-tey avatar Sep 26 '22 01:09 steven-tey

I've tried out trying to get this to be self-hostable and ended up making a modified fork of it. Since this is mainly reliant Vercel Edge Functions and Upstash Redis, most of the work was just replacing that stuff and getting the rest to work in Docker.

You can try and see if this works out for you: https://github.com/Snazzah/stub

Snazzah avatar Sep 29 '22 04:09 Snazzah

Stub is really amazing @Snazzah, great work! 😄

I'm planning to add a directory that has a simpler version of Dub (removing all unnecessary modules like Stripe, Plausible, etc.) and include proper self-host instructions on here soon! Reason I'm doing this is for y'all to be able to receive upstream updates easily (since you're forking the repo you can just pull from origin every time I push updates).

If you're worried about using Vercel + Upstash – given that you're using it only for your own links your usage will probably stay within their free plan anyway + their developer experience is really unbeatable so I'd still recommend using them! (disclaimer: I work at Vercel)

Sorry again for the delay y'all! Got swamped with a ton of bug fixes this week 😅

steven-tey avatar Oct 01 '22 19:10 steven-tey

Just wanted to follow up and say that I haven't forgotten about this issue yet – it's top on my TODO list for this week! Sorry again for the delay 😅

steven-tey avatar Oct 10 '22 16:10 steven-tey

any update on this steven-tey?

Ashutosh-Malve avatar May 07 '23 10:05 Ashutosh-Malve

@Ashutosh-Malve not yet, sorry! 😓 there are a few other features at the top of the roadmap (e.g. #38, #73, #191) so won't be able to get to this until after that!

steven-tey avatar May 28 '23 16:05 steven-tey

Any update on this?

FiveMDevv avatar Aug 22 '23 14:08 FiveMDevv

Hey everyone! Took a first stab at improving Dub's self-hosting experience today by:

  • Adding detailed instructions on how to set up env vars in .env.example file
  • Added a PR that publishes all the Tinybird pipes that Dub uses

This is still not perfect, but it's a stop gap – we're planning to add a proper, well-documented self-hosting guide soon! Stay tuned! :)

steven-tey avatar Aug 25 '23 01:08 steven-tey

Nice! Might still need to remove some hardcoded references to Dub's domains for the future (and easily be able to just have the dashboard and not the landing page) but so far it's some progress. I could help out putting it in a Dockerfile when that's dealt with.

Snazzah avatar Aug 25 '23 05:08 Snazzah

@Snazzah – agreed! I'm thinking of maybe splitting the repo into a private one that has all the marketing site, Stripe implementation etc. and the public one only having the dashboard. Would love some ideas on how to do version control though, i.e. not having to manually sync changes every time :thinkies:

Would definitely love helping with the Dockerfile side of things! 🙏

steven-tey avatar Aug 25 '23 05:08 steven-tey

You could split off the main marketing site (or any pages that just reside on dub.co) into a separate repo while leaving things that reside on app.dub.co on this one. You'd also be able to remove some hardcoded stuff since dub.sh would now just be used as a short link generator rather than half-marketing/half-shortlink. As far as removing Stripe implementation, you could have it toggled off if there's no Stripe API keys or have an environment variable that would put the dashboard on "self-host mode" making some things toggled off and allowing for more admin access for some users.

Snazzah avatar Aug 25 '23 05:08 Snazzah

@Snazzah okay, will look into this once #73 is done! 🙏

steven-tey avatar Aug 25 '23 13:08 steven-tey

@steven-tey totally unrelated, but what are you using for the custom emojis in GitHub? 👀

ThatOneCalculator avatar Aug 25 '23 15:08 ThatOneCalculator

@ThatOneCalculator https://single-emoji.vercel.app/ by @Schniz :yayawesome:

steven-tey avatar Aug 26 '23 00:08 steven-tey

Hi, any updates on the guide to deploy to Vercel?

cameronbensimon avatar Oct 07 '23 14:10 cameronbensimon

Recently completed the migration to Turborepo so we're one step closer to a better self-hosting experience for Dub! :cele-cry:

Reason: You no longer need to set up env vars that are only needed for the marketing site in order to get Dub up and running.

Next up: Planning to write up a full self-hosting documentation that walks you through all the steps needed to self-host Dub! :star-struck_cat:

steven-tey avatar Oct 12 '23 03:10 steven-tey

hey, any updates on the self-hosting guide? Also, please tell me why, after forking your Dub repository, I want to create a page with a copied site, but for some reason the Github site opens there? I am attaching a screenshot

Untitled

Xenoed avatar Nov 03 '23 17:11 Xenoed

@steven-tey when the full self-hosting guide comes back, is there any plan to relaunch vercel hosting too?

also, is there an ETA on a self hosting guide? thanks for your work on this amazing project.

BirbEXE avatar Nov 14 '23 08:11 BirbEXE

If I'm going to be honest, it's been over a YEAR now... it's starting to seem like a nothing burger. I'd love to be proven wrong.

ThatOneCalculator avatar Nov 14 '23 16:11 ThatOneCalculator

If I'm going to be honest, it's been over a YEAR now... it's starting to seem like a nothing burger. I'd love to be proven wrong.

yeah, we can only hope.

I understand that dub effectively operates as a business, and so seems hosting probably isn't a priority over adding new features for customers. it would be nice if we at least got the vercel option back soon though

BirbEXE avatar Nov 14 '23 16:11 BirbEXE

Any updates on self hosting? with local services

berkyzl avatar Dec 05 '23 12:12 berkyzl

Good news: We just made Dub's codebase more modular and published a complete guide on how to self-host Dub: https://dub.co/docs/self-hosting/guide 🥳

Feel free to give it a try and let us know if you run into any issues!

steven-tey avatar Dec 12 '23 00:12 steven-tey

This isn't actually self-hostable though, you need subscriptions to a bunch of cloud services.

ThatOneCalculator avatar Dec 12 '23 02:12 ThatOneCalculator

This isn't actually self-hostable though, you need subscriptions to a bunch of cloud services.

You're totally right. I'm not going to create 6 online accounts to self-host something as trivial as a link shortener 🤦🏻

ovizii avatar Dec 12 '23 08:12 ovizii

Thanks for the feedback here! A few things:

  1. You technically only need 4 of those services: Tinybird, Upstash, Planetscale, and Vercel.
  2. Most self-hosting use cases would fit comfortably under the free plan for all of these services.

That being said, we are planning to improve the self-hosting experience by reducing the reliance on these cloud services in the future, but in the meantime, this is an improvement to what was previously a confusing and error-prone self-hosting experience.

steven-tey avatar Dec 12 '23 15:12 steven-tey