mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-18 15:23:38 +01:00
Merge pull request #46 from hugomd/feat/add-database-schema-variable
Add DATABASE_TYPE environment variable
This commit is contained in:
commit
bd4d2b1108
@ -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