Compare commits

..

4 Commits

Author SHA1 Message Date
9de501c7eb changed user creation into debian style 2025-10-22 21:28:48 +02:00
5c6a50ddcf changed alpine production build to debian prod build 2025-10-22 21:22:09 +02:00
017f5fb2e0 copy database files manually 2025-10-22 21:01:46 +02:00
527954befd fix database paht 2025-10-22 20:50:36 +02:00
2 changed files with 19 additions and 6 deletions

View File

@@ -49,13 +49,16 @@ COPY frontend/public/ ./public/
RUN npm run build
# Production stage
FROM node:20-alpine
FROM node:20-bookworm
WORKDIR /app
# Install PM2 for process management
RUN npm install -g pm2
# Create data directory for SQLite database with proper permissions
RUN mkdir -p /app/data
# Copy backend built files
COPY --from=backend-builder /app/backend/package*.json ./
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 ecosystem.config.cjs ./
# Create a non-root user
RUN addgroup -g 1001 -S nodejs && \
adduser -S schichtplan -u 1001 && \
chown -R schichtplan:nodejs /app
# Create a non-root user and group - DEBIAN STYLE
RUN groupadd -r -g 1001 nodejs && \
useradd -r -u 1001 -s /bin/bash -g nodejs schichtplan && \
chown -R schichtplan:nodejs /app && \
chmod 755 /app && \
chmod 775 /app/data
USER schichtplan

View File

@@ -1,10 +1,18 @@
import sqlite3 from 'sqlite3';
import path from 'path';
import { fileURLToPath } from 'url';
import fs from 'fs';
const __filename = fileURLToPath(import.meta.url);
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 {
private db: sqlite3.Database;