mirror of
https://github.com/donpat1to/Schichtenplaner.git
synced 2025-12-01 06:55:45 +01:00
Compare commits
12 Commits
b6b31659e3
...
v0.0.6
| Author | SHA1 | Date | |
|---|---|---|---|
| 9de501c7eb | |||
| 5c6a50ddcf | |||
| 017f5fb2e0 | |||
| 527954befd | |||
| e7d30151b7 | |||
| 4a006a2e69 | |||
| 4b699b05d3 | |||
| dcac0307a2 | |||
| a0cc859935 | |||
| 49afd75ed3 | |||
| ebb9e3f4fe | |||
| 48f140f930 |
13
.github/workflows/docker.yml
vendored
13
.github/workflows/docker.yml
vendored
@@ -3,9 +3,8 @@ name: CI/CD Pipeline
|
|||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
branches: [ main, master, development ]
|
branches: [ "development", "main", "staging" ]
|
||||||
pull_request:
|
tags: [ "v*.*.*" ]
|
||||||
branches: [ main, master, development ]
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: ghcr.io
|
REGISTRY: ghcr.io
|
||||||
@@ -165,7 +164,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Display pushed images
|
- name: Display pushed images
|
||||||
run: |
|
run: |
|
||||||
echo "✅ Docker images pushed successfully!"
|
echo "Docker images pushed successfully!"
|
||||||
echo "📦 Image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
|
echo "- Image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
|
||||||
echo "🏷️ Tags: ${{ steps.meta.outputs.tags }}"
|
echo "- Tags: ${{ steps.meta.outputs.tags }}"
|
||||||
echo "🚀 New version: ${{ needs.set-tag.outputs.tag_name }}"
|
echo "- New version: ${{ needs.set-tag.outputs.tag_name }}"
|
||||||
|
|||||||
28
Dockerfile
28
Dockerfile
@@ -23,6 +23,8 @@ COPY backend/src/ ./src/
|
|||||||
# Build backend
|
# Build backend
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
|
# Copy database files manually
|
||||||
|
RUN cp -r src/database/ dist/database/
|
||||||
|
|
||||||
# Verify Python and OR-Tools installation
|
# Verify Python and OR-Tools installation
|
||||||
RUN python -c "from ortools.sat.python import cp_model; print('OR-Tools installed successfully')"
|
RUN python -c "from ortools.sat.python import cp_model; print('OR-Tools installed successfully')"
|
||||||
@@ -47,24 +49,20 @@ 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 Python and OR-Tools for production
|
|
||||||
#RUN apk add --no-cache \
|
|
||||||
# python \
|
|
||||||
# py3-pip \
|
|
||||||
# && pip3 install ortools
|
|
||||||
|
|
||||||
# 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/
|
||||||
COPY --from=backend-builder /app/backend/node_modules/ ./node_modules/
|
COPY --from=backend-builder /app/backend/node_modules/ ./node_modules/
|
||||||
# COPY --from=backend-builder /app/backend/python-scripts/ ./python-scripts/
|
|
||||||
|
|
||||||
# Copy frontend built files
|
# Copy frontend built files
|
||||||
COPY --from=frontend-builder /app/frontend/build/ ./frontend-build/
|
COPY --from=frontend-builder /app/frontend/build/ ./frontend-build/
|
||||||
@@ -72,17 +70,15 @@ 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 -r -g 1001 nodejs && \
|
||||||
adduser -S schichtplan -u 1001 && \
|
useradd -r -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
|
||||||
|
|
||||||
# Verify installations
|
|
||||||
#RUN python --version && \
|
|
||||||
# python -c "from ortools.sat.python import cp_model; print('OR-Tools verified')"
|
|
||||||
|
|
||||||
EXPOSE 3000 3002
|
EXPOSE 3000 3002
|
||||||
|
|
||||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user