dub icon indicating copy to clipboard operation
dub copied to clipboard

Potential Solution to Replace Planetscale effectively

Open rfrlcode opened this issue 1 year ago • 4 comments

I believe I might have found a way to replace planetscale with a different mysql provider, while keeping the features from planetscale.ts working completely.

First, startup a hosted mysql instance somewhere. Can be anywhere. I chose aiven.io. Get the mysql uri from them. it will look like this: mysql://username:[email protected]:28146/dbname?ssl-mode=REQUIRED

add this to your .env as the DATABASE_URL

We will now work on a way to deploy the docker image for the planetscale http sim. Create a folder anywhere (can be named anything). This folder should contain two files:

  1. docker-compose.yml version: "3" services: planetscale-proxy: build: context: . dockerfile: Dockerfile environment:

    • MYSQL_DBNAME=dbname
    • MYSQL_ADDR=hostname.a.aivencloud.com
    • MYSQL_PORT=28146
  2. Dockerfile FROM ghcr.io/mattrobenolt/ps-http-sim:latest CMD ["-listen-port=3900", "-mysql-dbname=dbname", "-mysql-addr=hostname.a.aivencloud.com", "-mysql-port=28146"]

Deploy this docker image anywhere. I used render.com for free hosting (upload the above folder with two files to github, and then deploy to render using github). render will give you a url like this: https://examples.onrender.com

Use the url, to add the following to your dub .env file (the username and password come from the mysql uri above) PLANETSCALE_DATABASE_URL="https://username:[email protected]"

now pnpm run dev, and everything should work as usual, and we dont have to pay the $$ for Planetscale. Let me know what yall think, and if something can be improved!

rfrlcode avatar Apr 08 '24 17:04 rfrlcode

hey @rfrlcode does this still work? I'm looking for a replacement for planet scale for self hosting, not for local, is this possible?

h4MeMengoding avatar Jul 10 '24 15:07 h4MeMengoding

yup, it definitely does

rfrlcode avatar Jul 10 '24 21:07 rfrlcode

For docker images that need to be deployed, can you use Vercel? it seems possible @rfrlcode

h4MeMengoding avatar Jul 10 '24 23:07 h4MeMengoding