chore: migrate from PostgreSQL to MongoDB and update environment configuration
This commit is contained in:
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
API_PORT=3671
|
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
|
## 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`
|
FastAPI docs: `http://localhost:3671/docs`
|
||||||
|
|||||||
+12
-12
@@ -8,10 +8,10 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- "${API_PORT:-3671}:3671"
|
- "${API_PORT:-3671}:3671"
|
||||||
environment:
|
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
|
REDIS_URL: redis://redis:6379/0
|
||||||
depends_on:
|
depends_on:
|
||||||
postgres:
|
mongodb:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
redis:
|
redis:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
@@ -22,20 +22,20 @@ services:
|
|||||||
retries: 5
|
retries: 5
|
||||||
start_period: 10s
|
start_period: 10s
|
||||||
|
|
||||||
postgres:
|
mongodb:
|
||||||
image: postgres:17-alpine
|
image: mongo:8
|
||||||
container_name: theplug-postgres
|
container_name: theplug-mongodb
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_DB: ${POSTGRES_DB:-theplug}
|
MONGO_INITDB_ROOT_USERNAME: ${MONGO_USER:-theplug}
|
||||||
POSTGRES_USER: ${POSTGRES_USER:-theplug}
|
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_PASSWORD:-pass}
|
||||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-theplug_dev_password}
|
MONGO_INITDB_DATABASE: ${MONGO_DB:-theplug}
|
||||||
ports:
|
ports:
|
||||||
- "5432:5432"
|
- "27017:27017"
|
||||||
volumes:
|
volumes:
|
||||||
- postgres_data:/var/lib/postgresql/data
|
- mongodb_data:/data/db
|
||||||
healthcheck:
|
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
|
interval: 10s
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 5
|
retries: 5
|
||||||
@@ -58,5 +58,5 @@ services:
|
|||||||
start_period: 5s
|
start_period: 5s
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
postgres_data:
|
mongodb_data:
|
||||||
redis_data:
|
redis_data:
|
||||||
|
|||||||
+1
-4
@@ -2,10 +2,7 @@ from fastapi import FastAPI
|
|||||||
from src.proxy.router import router as proxy_router
|
from src.proxy.router import router as proxy_router
|
||||||
|
|
||||||
app = FastAPI(
|
app = FastAPI(
|
||||||
title="thePlugAPI",
|
title="thePlugAPI"
|
||||||
contact={
|
|
||||||
"creator": "big_cock_man"
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
app.include_router(proxy_router)
|
app.include_router(proxy_router)
|
||||||
|
|||||||
Reference in New Issue
Block a user