dubinc / dub

Open-source link management infrastructure. Loved by modern marketing teams like Vercel, Raycast, and Perplexity.
https://dub.co
GNU Affero General Public License v3.0
18.93k stars 2.05k forks source link

Self host instructions #12

Closed ThatOneCalculator closed 11 months ago

ThatOneCalculator commented 2 years ago

There should be instructions on how to self-host Dub.

ThatOneCalculator commented 2 years ago

@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'
}
steven-tey commented 2 years ago

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 commented 2 years ago

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)

ThatOneCalculator commented 2 years ago

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.

ovizii commented 2 years ago

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

steven-tey commented 2 years ago

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 :)

Snazzah commented 2 years ago

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

steven-tey commented 2 years ago

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 commented 2 years ago

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 😅

Ashutosh-Malve commented 1 year ago

any update on this steven-tey?

steven-tey commented 1 year ago

@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!

FiveMDevv commented 1 year ago

Any update on this?

steven-tey commented 1 year ago

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

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! :)

Snazzah commented 1 year ago

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.

steven-tey commented 1 year ago

@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! 🙏

Snazzah commented 1 year ago

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.

steven-tey commented 1 year ago

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

ThatOneCalculator commented 1 year ago

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

steven-tey commented 1 year ago

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

cameronbensimon commented 1 year ago

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

steven-tey commented 1 year ago

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:

Xenoed commented 1 year ago

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

BirbEXE commented 1 year ago

@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.

ThatOneCalculator commented 1 year ago

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.

BirbEXE commented 1 year ago

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

berkyzl commented 11 months ago

Any updates on self hosting? with local services

steven-tey commented 11 months ago

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!

ThatOneCalculator commented 11 months ago

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

ovizii commented 11 months ago

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 🤦🏻

steven-tey commented 11 months ago

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.

cameronbensimon commented 11 months ago

This is great @steven-tey Thanks a lot, I appreciate it :)

ThatOneCalculator commented 11 months ago

@steven-tey the point of self-hosting for many is NOT the price — it's the autonomy of being able to control our own online services on our own hardware. I self host a lot of services for my personal use on a single mini PC shoved behind a router, knowing that I'm the only person who has physical and administrative control over that infrastructure.

steven-tey commented 11 months ago

@ThatOneCalculator that makes sense! We're planning to implement a simpler version of Dub (à la Stub) in the future that would swap out these services for native databases (mysql, redis) to make it more self-hostable in your own environment. Stay tuned! :)

ThatOneCalculator commented 11 months ago

Awesome! In that case, this issue should be reopened until that version is done.

ThatOneCalculator commented 7 months ago

@steven-tey why is this issue still closed? As it stands, according to https://dub.co/docs/self-hosting , I can't self host without the use of many cloud services.

tomy0000000 commented 7 months ago

@steven-tey why is this issue still closed? As it stands, according to https://dub.co/docs/self-hosting , I can't self host without the use of many cloud services.

I think his definition of done for this issue is that "there exists a document explaining how this thing can be deployed", which is what the title implies.

I personally wish there could be an easier way (hopefully through Docker). That's why I'm keeping an eye on Stub.

Should probably open another issue regarding this, but given that this project is becoming a product of @steven-tey's startup, there are conflicts of interest, and I don't think they'll include this in his roadmap.

ThatOneCalculator commented 7 months ago

In any case, the issue should still be reopened. Whether it's implemented or not, deploying is not always self hosting (certainly not in this case) and therefore the issue should still not be considered closed. For the sake of transparency, even if it's not planned, the issue should be open.