https://github.com/thorwebdev/supa-fly-ferretdb
Add MongoDB Compatibility to your Supabase Project with FerretDB and Fly.io!
https://github.com/thorwebdev/supa-fly-ferretdb
Last synced: 6 months ago
JSON representation
Add MongoDB Compatibility to your Supabase Project with FerretDB and Fly.io!
- Host: GitHub
- URL: https://github.com/thorwebdev/supa-fly-ferretdb
- Owner: thorwebdev
- Created: 2024-01-05T08:04:35.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-31T10:19:11.000Z (over 2 years ago)
- Last Synced: 2025-07-12T03:53:56.318Z (11 months ago)
- Language: TypeScript
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# NoSQL Postgres with FerretDB, Fly.io, and Supabase
[FerretDB](https://www.ferretdb.com/) is an awesome open source projects using JSONB to implement MongoDB compatability on top of Postgres!
## Prerequisites
- A hosted Supabase project. Don't have one yet? -> [database.new](https://database.new)
- Docker or [Orbstack](https://orbstack.dev/)
## Run locally with Docker
```bash
# Expose required env vars:
export DB_USER=postgres
export DB_PASSWORD=
export SUPA_PROJECT_REF=
export SUPA_REGION=
export DB_URL=postgres://$DB_USER.$SUPA_PROJECT_REF:$DB_PASSWORD@$SUPA_REGION.pooler.supabase.com:5432/postgres
# Run FerretDB in docker container
docker run -p 27017:27017 -p 8080:8080 -e FERRETDB_POSTGRESQL_URL=$DB_URL ghcr.io/ferretdb/ferretdb
# Consturct mongodb url
export MONGODB_URL=mongodb://$DB_USER.$SUPA_PROJECT_REF:$DB_PASSWORD@127.0.0.1:27017/ferretdb?authMechanism=PLAIN
# Test with mongosh
# If you have mongodb installed locally
mongosh '$MONGODB_URL'
# If you don't have mongodb installed locally, run in docker container
docker run --rm -it --entrypoint=mongosh mongo \
"$MONGODB_URL"
# Test with MongoClient in TypeScript
deno run -A mongo.ts
```
## Deploy to Fly.io
- fly launch --no-deploy
- An existing fly.toml file was found for app supa-ferretdb
- ? Would you like to copy its configuration to the new app? (y/N) > y
- fly secrets set FERRETDB_POSTGRESQL_URL=$DB_URL
- fly deploy
- fly ips allocate-v4
- Note: this is a paid feature! You can test it for free as long as you [release the dedicated IPv4](https://community.fly.io/t/we-are-going-to-start-charging-for-dedicated-ipv4-in-january-1st/15970#how-not-to-be-billed-2) before the end of the billing period!
Now simply replace `127.0.0.1` in the `MONGODB_URL` with your dedicated IPv4 address and you're ready to roll \o/