chore(docker): refactor Docker configuration for environment variables and database initialization
- Updated docker-compose.yml to use environment variable fallbacks for configuration. - Modified Dockerfile to streamline database initialization using Prisma migrations directly. - Removed init-db.js script as its functionality is now integrated into the Docker CMD.
This commit is contained in:
@@ -5,16 +5,22 @@ services:
|
||||
dockerfile: Dockerfile
|
||||
target: runner
|
||||
ports:
|
||||
- '3006:3000'
|
||||
- '${PORT:-3007}:3000'
|
||||
environment:
|
||||
NODE_ENV: production
|
||||
DATABASE_URL: 'file:../data/dev.db' # Prisma
|
||||
BACKUP_DATABASE_PATH: './data/dev.db' # Base de données à sauvegarder
|
||||
BACKUP_STORAGE_PATH: './data/backups' # Dossier des sauvegardes
|
||||
TZ: Europe/Paris
|
||||
NODE_ENV: ${NODE_ENV:-production}
|
||||
DATABASE_URL: ${DATABASE_URL:-file:../data/dev.db}
|
||||
BACKUP_DATABASE_PATH: ${BACKUP_DATABASE_PATH:-./data/dev.db}
|
||||
BACKUP_STORAGE_PATH: ${BACKUP_STORAGE_PATH:-./data/backups}
|
||||
TZ: ${TZ:-Europe/Paris}
|
||||
# NextAuth.js
|
||||
NEXTAUTH_SECRET: 'TbwIWAmQgBcOlg7jRZrhkeEUDTpSr8Cj/Cc7W58fAyw='
|
||||
NEXTAUTH_URL: 'http://localhost:3006'
|
||||
NEXTAUTH_SECRET: ${NEXTAUTH_SECRET:-TbwIWAmQgBcOlg7jRZrhkeEUDTpSr8Cj/Cc7W58fAyw=}
|
||||
NEXTAUTH_URL: ${NEXTAUTH_URL:-http://localhost:3006}
|
||||
# Jira (optionnel)
|
||||
JIRA_BASE_URL: ${JIRA_BASE_URL:-}
|
||||
JIRA_EMAIL: ${JIRA_EMAIL:-}
|
||||
JIRA_API_TOKEN: ${JIRA_API_TOKEN:-}
|
||||
# Debug
|
||||
VERBOSE_LOGGING: ${VERBOSE_LOGGING:-false}
|
||||
volumes:
|
||||
- ./data:/app/data # Dossier local data/ vers /app/data
|
||||
restart: unless-stopped
|
||||
@@ -31,16 +37,22 @@ services:
|
||||
dockerfile: Dockerfile
|
||||
target: base
|
||||
ports:
|
||||
- '3005:3000'
|
||||
- '${PORT_DEV:-3005}:3000'
|
||||
environment:
|
||||
NODE_ENV: development
|
||||
DATABASE_URL: 'file:../data/dev.db' # Prisma
|
||||
BACKUP_DATABASE_PATH: './data/dev.db' # Base de données à sauvegarder
|
||||
BACKUP_STORAGE_PATH: './data/backups' # Dossier des sauvegardes
|
||||
TZ: Europe/Paris
|
||||
NODE_ENV: ${NODE_ENV:-development}
|
||||
DATABASE_URL: ${DATABASE_URL:-file:../data/dev.db}
|
||||
BACKUP_DATABASE_PATH: ${BACKUP_DATABASE_PATH:-./data/dev.db}
|
||||
BACKUP_STORAGE_PATH: ${BACKUP_STORAGE_PATH:-./data/backups}
|
||||
TZ: ${TZ:-Europe/Paris}
|
||||
# NextAuth.js
|
||||
NEXTAUTH_SECRET: 'TbwIWAmQgBcOlg7jRZrhkeEUDTpSr8Cj/Cc7W58fAyw='
|
||||
NEXTAUTH_URL: 'http://localhost:3005'
|
||||
NEXTAUTH_SECRET: ${NEXTAUTH_SECRET:-TbwIWAmQgBcOlg7jRZrhkeEUDTpSr8Cj/Cc7W58fAyw=}
|
||||
NEXTAUTH_URL: ${NEXTAUTH_URL:-http://localhost:3005}
|
||||
# Jira (optionnel)
|
||||
JIRA_BASE_URL: ${JIRA_BASE_URL:-}
|
||||
JIRA_EMAIL: ${JIRA_EMAIL:-}
|
||||
JIRA_API_TOKEN: ${JIRA_API_TOKEN:-}
|
||||
# Debug
|
||||
VERBOSE_LOGGING: ${VERBOSE_LOGGING:-false}
|
||||
volumes:
|
||||
- .:/app # code en live
|
||||
- /app/node_modules # vol anonyme pour ne pas écraser ceux du conteneur
|
||||
@@ -49,7 +61,7 @@ services:
|
||||
command: >
|
||||
sh -c "pnpm install &&
|
||||
pnpm prisma generate &&
|
||||
node scripts/init-db.js &&
|
||||
(pnpm prisma migrate deploy || (echo 'Migration failed, using db push for fresh database...' && pnpm prisma db push --accept-data-loss --skip-generate && for migration in prisma/migrations/*/; do if [ -d \"\$migration\" ] && [ -f \"\$migration/migration.sql\" ]; then migration_name=\$(basename \"\$migration\"); pnpm prisma migrate resolve --applied \"\$migration_name\" 2>/dev/null || true; fi; done)) &&
|
||||
pnpm run dev"
|
||||
profiles:
|
||||
- dev
|
||||
@@ -59,5 +71,6 @@ services:
|
||||
# ├── dev.db -> Base de données développement
|
||||
# └── backups/ -> Sauvegardes automatiques
|
||||
#
|
||||
# 🔧 Configuration via .env.docker
|
||||
# 📚 Documentation : ./data/README.md
|
||||
# 🔧 Configuration via variables d'environnement (.env ou .env.local)
|
||||
# Les variables utilisent la syntaxe ${VAR:-default} pour les fallbacks
|
||||
# 📚 Documentation : ./data/README.md et env.example
|
||||
|
||||
Reference in New Issue
Block a user