Compare commits

...

6 Commits

2 changed files with 20 additions and 7 deletions

View File

@@ -23,7 +23,7 @@ COPY backend/src/ ./src/
# Build backend # Build backend
RUN npm run build RUN npm run build
# Copy database files manually (tsc doesn't copy non-TS files) # Copy database files manually
RUN cp -r src/database/ dist/database/ RUN cp -r src/database/ dist/database/
# Verify Python and OR-Tools installation # Verify Python and OR-Tools installation
@@ -49,13 +49,16 @@ COPY frontend/public/ ./public/
RUN npm run build RUN npm run build
# Production stage # Production stage
FROM node:20-alpine FROM node:20-bookworm
WORKDIR /app WORKDIR /app
# Install PM2 for process management # Install PM2 for process management
RUN npm install -g pm2 RUN npm install -g pm2
# Create data directory for SQLite database with proper permissions
RUN mkdir -p /app/data
# Copy backend built files # Copy backend built files
COPY --from=backend-builder /app/backend/package*.json ./ COPY --from=backend-builder /app/backend/package*.json ./
COPY --from=backend-builder /app/backend/dist/ ./dist/ COPY --from=backend-builder /app/backend/dist/ ./dist/
@@ -67,10 +70,12 @@ COPY --from=frontend-builder /app/frontend/build/ ./frontend-build/
# Copy PM2 configuration # Copy PM2 configuration
COPY ecosystem.config.cjs ./ COPY ecosystem.config.cjs ./
# Create a non-root user # Create a non-root user and group - DEBIAN STYLE
RUN addgroup -g 1001 -S nodejs && \ RUN groupadd -g 1001 nodejs && \
adduser -S schichtplan -u 1001 && \ useradd -m -u 1001 -s /bin/bash -g nodejs schichtplan && \
chown -R schichtplan:nodejs /app chown -R schichtplan:nodejs /app && \
chmod 755 /app && \
chmod 775 /app/data
USER schichtplan USER schichtplan

View File

@@ -1,10 +1,18 @@
import sqlite3 from 'sqlite3'; import sqlite3 from 'sqlite3';
import path from 'path'; import path from 'path';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'url';
import fs from 'fs';
const __filename = fileURLToPath(import.meta.url); const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename); const __dirname = path.dirname(__filename);
const dbPath = path.join(__dirname, '../../database/schichtplan.db');
const dbPath = process.env.DB_PATH || '/app/data/schichtplan.db';
// Stelle sicher, dass das Verzeichnis existiert
const dbDir = path.dirname(dbPath);
if (!fs.existsSync(dbDir)) {
fs.mkdirSync(dbDir, { recursive: true });
}
class Database { class Database {
private db: sqlite3.Database; private db: sqlite3.Database;