chore: migrate from PostgreSQL to MongoDB and update environment configuration
This commit is contained in:
+2
-2
@@ -1,3 +1,3 @@
|
||||
API_PORT=3671
|
||||
POSTGRES_PASSWORD=pass
|
||||
|
||||
MONGO_INITDB_ROOT_PASSWORD=pass
|
||||
MONGODB_URL=mongodb://theplug:pass@mongodb:27017/theplug?authSource=admin
|
||||
|
||||
@@ -5,6 +5,25 @@ icona di una presa della spina idk
|
||||
## Architettura
|
||||
|
||||
```
|
||||
FastAPI + PostgreSQL + Redis
|
||||
FastAPI + MongoDB + Redis
|
||||
```
|
||||
|
||||
### Setup Dev
|
||||
|
||||
imposta le variabili d'ambiente
|
||||
|
||||
```bash
|
||||
cp .env.example .env
|
||||
# modifica le variabili
|
||||
nano .env
|
||||
```
|
||||
|
||||
avvia i servizi e il server locale
|
||||
```bash
|
||||
docker compose up -d mongodb redis
|
||||
```
|
||||
```bash
|
||||
fastapi dev src/main.py
|
||||
```
|
||||
|
||||
FastAPI docs: `http://localhost:3671/docs`
|
||||
|
||||
+12
-12
@@ -8,10 +8,10 @@ services:
|
||||
ports:
|
||||
- "${API_PORT:-3671}:3671"
|
||||
environment:
|
||||
DATABASE_URL: postgresql://${POSTGRES_USER:-theplug}:${POSTGRES_PASSWORD:-theplug_dev_password}@postgres:5432/${POSTGRES_DB:-theplug}
|
||||
MONGODB_URL: mongodb://${MONGO_USER:-theplug}:${MONGO_PASSWORD:-theplug_dev_password}@mongodb:27017/${MONGO_DB:-theplug}?authSource=admin
|
||||
REDIS_URL: redis://redis:6379/0
|
||||
depends_on:
|
||||
postgres:
|
||||
mongodb:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
@@ -22,20 +22,20 @@ services:
|
||||
retries: 5
|
||||
start_period: 10s
|
||||
|
||||
postgres:
|
||||
image: postgres:17-alpine
|
||||
container_name: theplug-postgres
|
||||
mongodb:
|
||||
image: mongo:8
|
||||
container_name: theplug-mongodb
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
POSTGRES_DB: ${POSTGRES_DB:-theplug}
|
||||
POSTGRES_USER: ${POSTGRES_USER:-theplug}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-theplug_dev_password}
|
||||
MONGO_INITDB_ROOT_USERNAME: ${MONGO_USER:-theplug}
|
||||
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_PASSWORD:-pass}
|
||||
MONGO_INITDB_DATABASE: ${MONGO_DB:-theplug}
|
||||
ports:
|
||||
- "5432:5432"
|
||||
- "27017:27017"
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
- mongodb_data:/data/db
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-theplug} -d ${POSTGRES_DB:-theplug}"]
|
||||
test: ["CMD-SHELL", "mongosh --quiet --username ${MONGO_USER:-theplug} --password ${MONGO_PASSWORD:-theplug_dev_password} --authenticationDatabase admin --eval \"db.adminCommand({ ping: 1 }).ok\" | grep 1"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
@@ -58,5 +58,5 @@ services:
|
||||
start_period: 5s
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
mongodb_data:
|
||||
redis_data:
|
||||
|
||||
+1
-4
@@ -2,10 +2,7 @@ from fastapi import FastAPI
|
||||
from src.proxy.router import router as proxy_router
|
||||
|
||||
app = FastAPI(
|
||||
title="thePlugAPI",
|
||||
contact={
|
||||
"creator": "big_cock_man"
|
||||
}
|
||||
title="thePlugAPI"
|
||||
)
|
||||
|
||||
app.include_router(proxy_router)
|
||||
|
||||
Reference in New Issue
Block a user