Add Migrations
Some checks failed
Deploy Backend to Docker / deploy (push) Failing after 3m2s
Deploy Backend to Docker / deploy-portainer (push) Has been skipped

This commit is contained in:
2025-12-03 21:44:52 -05:00
parent 3f835bfcea
commit 1579f369c2
4 changed files with 28 additions and 2 deletions

View File

@@ -42,8 +42,12 @@ COPY . .
# Build TypeScript # Build TypeScript
RUN npm run build RUN npm run build
# Copy entrypoint script
COPY docker-entrypoint.sh /app/
RUN chmod +x /app/docker-entrypoint.sh
# Expose port # Expose port
EXPOSE 3000 EXPOSE 3000
# Start application (migrations will be run via docker-compose command) # Start application with migrations
CMD ["npm", "start"] ENTRYPOINT ["/app/docker-entrypoint.sh"]

View File

@@ -0,0 +1,8 @@
#!/bin/sh
set -e
echo "Running database migrations..."
npx prisma migrate deploy
echo "Starting application..."
exec npm start

View File

@@ -17,6 +17,7 @@
}, },
"dependencies": { "dependencies": {
"better-sqlite3": "^12.5.0", "better-sqlite3": "^12.5.0",
"dotenv": "^17.2.3",
"electron": "^30.0.0", "electron": "^30.0.0",
"electron-updater": "^6.1.0", "electron-updater": "^6.1.0",
"recharts": "^3.5.1", "recharts": "^3.5.1",

View File

@@ -1,8 +1,21 @@
import { app, BrowserWindow, Tray, Menu, nativeImage } from 'electron'; import { app, BrowserWindow, Tray, Menu, nativeImage } from 'electron';
import * as path from 'path'; import * as path from 'path';
import * as dotenv from 'dotenv';
import { setupIpcHandlers, cleanupIpcHandlers } from './ipc-handlers'; import { setupIpcHandlers, cleanupIpcHandlers } from './ipc-handlers';
import { initDatabase, closeDatabase } from './database'; import { initDatabase, closeDatabase } from './database';
// Load environment variables from .env file
// In dev: __dirname = dist/main, so go up to electron-app root
// In prod: __dirname = resources/app.asar/dist/main, .env should be in resources
const envPath = process.env.NODE_ENV === 'development'
? path.join(__dirname, '../../.env')
: path.join(process.resourcesPath, '.env');
dotenv.config({ path: envPath });
console.log('Loading .env from:', envPath);
console.log('WS_URL:', process.env.WS_URL);
console.log('API_URL:', process.env.API_URL);
let mainWindow: BrowserWindow | null = null; let mainWindow: BrowserWindow | null = null;
let tray: Tray | null = null; let tray: Tray | null = null;