Skip to content

Self Hosting

fengkx edited this page May 3, 2021 · 5 revisions

KeepLink is build with Supabase stack and Next.js, But It cannot depoly directly on vercel.com and supabase.io (at least for now) for two reason.

  1. KeepLink use rum index and zhparser for better search support which is not currently exist in Supabase's extensions list.
  2. Vercel's API route has 10 seconds runtime limit for its hobby plain. Archiving page with headless chrome might reach this limit. Maybe it can be solved by Supabase Workflows.

If you really want to deploy on vercel.com and https://supabase.io, which need some code change and database knowledge. Changing the SQL structure in prisma/migrations as follw:

  1. Replace all rum index to gin index
  2. Replace all zhparser text search config to one PostgreSQL builtin.

Self Hosting

docker # Supabase directory
├── docker-compose.yml
├── kong
│   ├── Dockerfile
│   └── kong.yml
└── postgres
|   ├── 00-initial-schema.sql
│   ├── 200-init-zhparser.sql
│   ├── 201-init-rum.sql
│   ├── auth-schema.sql
│   └── Dockerfile
└── docker-compose.yml

The repository contain a docker directory with a docker-compose.yml in it. There is also a docker-compose.yml in the root directory. dockerdirectory is the directory of Supabase. Supabase has a great self host document for you. And the docker-compose.yml in root directory open the KeepLink service and connenct to Supabase docker services by docker network.

Requirements

  1. Install docker and docker-compose
  2. Run git clone https://github.com/fengkx/keeplink

Guide

  1. First of all, CHANGE THE DEFAULT PASSWORD AND SECRET listed in Supabase Docs
  2. Run docker-compose up -d in docker directory to start Supabase
  3. Create .env file According to your environment and password and sercet. For example
NEXT_PUBLIC_SUPABASE_URL=https://supabase.keeplink.cc
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJzdXBhYmFzZSIsImlhdCI6MTYwMzk2ODgzNCwiZXhwIjoyNTUwNjUzNjM0LCJyb2xlIjoiYW5vbiJ9.gCm8Egtn7aeHyz-Pq8QbqxpzSnMK3DffadQsBK9ainY
SUPABASE_PRIVATEKEY=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJzdXBhYmFzZSIsImlhdCI6MTYwMzk2ODgzNCwiZXhwIjoyNTUwNjUzNjM0LCJyb2xlIjoic2VydmljZV9yb2xlIn0.WiEF94VgCZWE_IvPZinXSfpTj4mrVVRktGDQwWaEpl4
DATABASE_URL=postgres://postgres:postgres@db:5432/postgres?schema=public
CHROME_WS_URL=ws://chrome:3000
BASE_URL=https://app.keeplink.cc

Notice that in docker-compose network, You can use key in services field to access that service.

  1. Run docker-compose up -d in root directory to start KeepLink (It might take some time to run next build)

Then KeepLink is running on port 3000 and Supabase is runing on port 8000

Step to change the default secret and password

  1. Generate a long enough super secret string such as a uuid
  2. Paste the default jwt to https://jwt.io/#debugger-io and replace the sercet with the one you generated last step. It will generate a new one for you
  3. Replace all secret and jwt with your newly generated one

Notice: There are two jwt. One is NEXT_PUBLIC_SUPABASE_ANON_KEY which is public and it is the one in kong/kong.yml, the other one is SUPABASE_PRIVATEKEY which is private and should be super sercet

  1. Replace the PostgreSQL password and other password as well

More useful configuration on https://github.com/fengkx/keeplink/wiki/Useful-Configuration