Compare commits

..

No commits in common. "4a994c3bf825e29e7e573278a91e203860369659" and "f1a2ca75b1af7660c8fbf08516c2c2f9d485dd2e" have entirely different histories.

2 changed files with 15 additions and 47 deletions

View File

@ -2,8 +2,8 @@ FROM node:20-alpine
WORKDIR /app
# Install system dependencies for SQLite and native modules
RUN apk add --no-cache python3 build-base g++ make sqlite sqlite-dev gcc musl-dev git libffi-dev openssl-dev cmake
# Install system dependencies
RUN apk add --no-cache python3 build-base g++ make sqlite sqlite-dev
# Install pnpm
RUN npm install -g pnpm
@ -11,20 +11,10 @@ RUN npm install -g pnpm
# Copy package files
COPY package.json pnpm-lock.yaml ./
# Install dependencies with native bindings build approval, ensuring to build from source for all platforms
ENV CFLAGS="-fPIC" \
LDFLAGS="-fPIC" \
CXXFLAGS="-fPIC" \
npm_config_build_from_source=true \
npm_config_sqlite=/usr/local \
npm_config_sqlite_libname=sqlite3
# Durchführen der Installation mit umfassenden Flags für native Bindungen
# Install dependencies with native bindings build approval
RUN pnpm install --unsafe-perm --no-optional --frozen-lockfile
# Explizit better-sqlite3 für die aktuelle Plattform neu bauen
RUN cd /app/node_modules/better-sqlite3 && \
npm run build-release
# Rebuild better-sqlite3 with explicit platform options for ARM compatibility
RUN npm_config_build_from_source=true pnpm rebuild better-sqlite3
# Install tsx for running TypeScript files directly
RUN pnpm add -D tsx
@ -46,26 +36,20 @@ RUN echo '#!/bin/sh' > /app/startup.sh && \
echo 'set -e' >> /app/startup.sh && \
echo 'mkdir -p /app/db' >> /app/startup.sh && \
echo 'echo "Starting application..."' >> /app/startup.sh && \
echo 'echo "Konfiguriere DB-Verzeichnis..."' >> /app/startup.sh && \
echo 'echo "Attempting database setup..."' >> /app/startup.sh && \
echo 'DB_FILE="/app/db/sqlite.db"' >> /app/startup.sh && \
echo 'if [ ! -f "$DB_FILE" ]; then' >> /app/startup.sh && \
echo ' echo "Creating empty database file..."' >> /app/startup.sh && \
echo ' touch "$DB_FILE"' >> /app/startup.sh && \
echo ' chmod 666 "$DB_FILE"' >> /app/startup.sh && \
echo 'fi' >> /app/startup.sh && \
echo 'chmod 666 "$DB_FILE"' >> /app/startup.sh && \
echo 'chmod -R 777 /app/db' >> /app/startup.sh && \
echo 'export DB_PATH=$DB_FILE' >> /app/startup.sh && \
echo 'echo "Datenbank wird unter $DB_PATH verwendet"' >> /app/startup.sh && \
echo 'echo "Führe Datenbank-Migration aus..."' >> /app/startup.sh && \
echo 'NODE_ENV=production npx tsx ./src/server/db/migrate.ts' >> /app/startup.sh && \
echo 'echo "Migration abgeschlossen"' >> /app/startup.sh && \
echo 'echo "Starte Next.js Anwendung..."' >> /app/startup.sh && \
echo 'if [ -d ".next" ]; then' >> /app/startup.sh && \
echo ' pnpm start' >> /app/startup.sh && \
echo 'else' >> /app/startup.sh && \
echo ' echo "Build directory nicht gefunden, führe Build aus..."' >> /app/startup.sh && \
echo ' pnpm build && pnpm start' >> /app/startup.sh && \
echo 'fi' >> /app/startup.sh && \
echo 'echo "Rebuilding native bindings..."' >> /app/startup.sh && \
echo 'npm_config_build_from_source=true pnpm rebuild better-sqlite3 || echo "Rebuild failed but continuing..."' >> /app/startup.sh && \
echo 'echo "Attempting database migration..."' >> /app/startup.sh && \
echo 'NODE_ENV=production npx tsx ./src/server/db/migrate.ts || echo "Migration failed but continuing..."' >> /app/startup.sh && \
echo 'echo "Migration completed or skipped"' >> /app/startup.sh && \
echo 'pnpm build || echo "Build failed, but continuing with existing build..."' >> /app/startup.sh && \
echo 'pnpm start || pnpm dev' >> /app/startup.sh && \
chmod +x /app/startup.sh
# Start the application

View File

@ -3,21 +3,5 @@ import Database from "better-sqlite3";
import { drizzle } from "drizzle-orm/better-sqlite3";
import * as schema from "@/server/db/schema";
// Stellen sicher, dass DB_PATH tatsächlich gesetzt ist
const dbPath = env.DB_PATH || "/app/db/sqlite.db";
// Konfiguriere SQLite für zuverlässigeren Betrieb
const sqlite = new Database(dbPath, {
// Setze längeres Timeout für Operationen auf langsamen Geräten (RPi)
timeout: 30000,
// Aktiviere WAL-Modus für höhere Performance
journalMode: 'wal',
// Verbesserte Fehlerbehandlung
verbose: console.error,
});
// Aktiviere Fremdschlüssel-Constraints
sqlite.pragma('foreign_keys = ON');
// Exportiere die Drizzle-Datenbankinstanz
const sqlite = new Database(env.DB_PATH);
export const db = drizzle(sqlite, { schema });