mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-22 09:13:37 +01:00
Add DATABASE_TYPE environment variable
Determines which Prisma schema to use
This commit is contained in:
parent
05dc77ca35
commit
73ea516a7a
@ -1,6 +1,9 @@
|
||||
FROM node:12.18-alpine
|
||||
|
||||
ENV DATABASE_URL "postgresql://umami:umami@db:5432/umami"
|
||||
ARG DATABASE_TYPE
|
||||
|
||||
ENV DATABASE_URL "postgresql://umami:umami@db:5432/umami" \
|
||||
DATABASE_TYPE=$DATABASE_TYPE
|
||||
|
||||
COPY . /app
|
||||
WORKDIR /app
|
||||
|
@ -7,6 +7,7 @@ services:
|
||||
- "3000:3000"
|
||||
environment:
|
||||
DATABASE_URL: postgresql://umami:umami@db:5432/umami
|
||||
DATABASE_TYPE: postgresql
|
||||
HASH_SALT: replace-me-with-a-random-string
|
||||
depends_on:
|
||||
- db
|
||||
|
@ -2,15 +2,15 @@ require('dotenv').config();
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const db = process.env.DATABASE_URL.split(':')[0];
|
||||
const databaseType = process.env.DATABASE_TYPE || process.env.DATABASE_URL.split(':')[0];
|
||||
|
||||
if (!db) {
|
||||
throw new Error('Database not specified');
|
||||
if (!databaseType) {
|
||||
throw new Error('Database schema not specified');
|
||||
}
|
||||
|
||||
console.log(`Database detected: ${db}`);
|
||||
console.log(`Database schema detected: ${databaseType}`);
|
||||
|
||||
const src = path.resolve(__dirname, `../prisma/schema.${db}.prisma`);
|
||||
const src = path.resolve(__dirname, `../prisma/schema.${databaseType}.prisma`);
|
||||
const dest = path.resolve(__dirname, '../prisma/schema.prisma');
|
||||
|
||||
fs.copyFileSync(src, dest);
|
||||
|
Loading…
Reference in New Issue
Block a user