Implement PostgreSQL support and update database configuration: Migrate from SQLite to PostgreSQL by updating the Prisma schema, Docker configuration, and environment variables. Add PostgreSQL dependencies and adjust the database connection logic in the application. Enhance .gitignore to exclude PostgreSQL-related files and directories.
Some checks failed
Deploy with Docker Compose / deploy (push) Has been cancelled

This commit is contained in:
Julien Froidefond
2025-12-17 11:41:32 +01:00
parent 1f59cc7f9d
commit 8ad09ab9c8
45 changed files with 1238 additions and 109 deletions

View File

@@ -1,6 +1,31 @@
version: "3.8"
services:
got-postgres:
image: postgres:15-alpine
container_name: got-mc-postgres
environment:
POSTGRES_USER: ${POSTGRES_USER:-gotgaming}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-change-this-in-production}
POSTGRES_DB: ${POSTGRES_DB:-gotgaming}
POSTGRES_INITDB_ARGS: "-E UTF8 --locale=C"
volumes:
- ${POSTGRES_DATA_PATH:-./data/postgres}:/var/lib/postgresql/data
ports:
- "5433:5432"
restart: unless-stopped
command: postgres -c max_connections=100 -c shared_buffers=256MB -c effective_cache_size=1GB
healthcheck:
test:
[
"CMD-SHELL",
"pg_isready -U ${POSTGRES_USER:-gotgaming} -d ${POSTGRES_DB:-gotgaming}",
]
interval: 5s
timeout: 3s
retries: 10
start_period: 10s
got-app:
build:
context: .
@@ -10,15 +35,18 @@ services:
- "3040:3000"
environment:
- NODE_ENV=production
- DATABASE_URL=file:/app/data/dev.db
- DATABASE_URL=postgresql://${POSTGRES_USER:-gotgaming}:${POSTGRES_PASSWORD:-change-this-in-production}@got-postgres:5432/${POSTGRES_DB:-gotgaming}?schema=public
- NEXTAUTH_URL=${NEXTAUTH_URL:-http://localhost:3000}
- NEXTAUTH_SECRET=${NEXTAUTH_SECRET:-change-this-secret-in-production}
volumes:
# Persist database (override DATA_PATH env var to change location)
- ${PRISMA_DATA_PATH:-/Volumes/EXTERNAL_USB/sites/got-gaming/data}:/app/data
# Persist SQLite database (pour migration)
- ${PRISMA_DATA_PATH:-./data}:/app/data
# Persist uploaded images (avatars and backgrounds)
- ${UPLOADS_PATH:-./public/uploads}:/app/public/uploads
- ./prisma/migrations:/app/prisma/migrations
depends_on:
got-postgres:
condition: service_healthy
restart: unless-stopped
labels:
- "com.centurylinklabs.watchtower.enable=false"