Compare commits

..

11 Commits

23 changed files with 220 additions and 24217 deletions

View File

@@ -16,12 +16,22 @@ jobs:
runs-on: ubuntu-latest
outputs:
tag_name: ${{ steps.set_tag.outputs.tag_name }}
is_main_branch: ${{ steps.branch_check.outputs.is_main }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for tags
- name: Check if main branch
id: branch_check
run: |
if [[ "${GITHUB_REF}" == "refs/heads/main" || "${GITHUB_REF}" == "refs/heads/master" ]]; then
echo "is_main_branch=true" >> $GITHUB_OUTPUT
else
echo "is_main_branch=false" >> $GITHUB_OUTPUT
fi
- name: Determine next semantic version tag
id: set_tag
run: |
@@ -65,14 +75,10 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: backend/package-lock.json
- name: Install backend dependencies
working-directory: ./backend
run: |
# Try npm ci first, if it fails use npm install
npm ci || (echo "package-lock.json out of sync, using npm install..." && npm install)
run: npm install
- name: Run TypeScript check
working-directory: ./backend
@@ -139,6 +145,8 @@ jobs:
type=sha
# Add the dynamically generated semantic version
${{ needs.set-tag.outputs.tag_name }}
# Add latest tag for main branch
${{ needs.set-tag.outputs.is_main_branch == 'true' && 'latest' }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
@@ -168,3 +176,4 @@ jobs:
echo "- Image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
echo "- Tags: ${{ steps.meta.outputs.tags }}"
echo "- New version: ${{ needs.set-tag.outputs.tag_name }}"
echo "- Is main branch: ${{ needs.set-tag.outputs.is_main_branch }}"

21
.gitignore vendored
View File

@@ -115,3 +115,24 @@ Thumbs.db
premium/*
!premium/README-PREMIUM.md
!premium/.gitkeep
.git
.gitignore
node_modules
npm-debug.log
README.md
.env
.nyc_output
coverage
.cache
dist
build
logs
*.tsbuildinfo
# Frontend specific
frontend/dist
frontend/.vite
# Backend specific
backend/dist

View File

@@ -1,5 +1,5 @@
# Multi-stage build for combined frontend + backend
FROM node:20-bullseye AS backend-builder
# Single stage build for workspaces
FROM node:20-bullseye AS builder
WORKDIR /app
@@ -10,80 +10,44 @@ RUN apt-get update && apt-get install -y python3 python3-pip build-essential \
# Create symlink so python3 is callable as python
RUN ln -sf /usr/bin/python3 /usr/bin/python
# Copy ALL package files (root + backend)
COPY package*.json ./
COPY backend/package.json ./backend/
# Copy all files
COPY . .
# Install dependencies using workspaces
RUN npm ci --workspace=backend
# Use npm install instead of npm ci to avoid the bug
RUN npm install
# Copy backend source
COPY backend/src/ ./backend/src/
COPY backend/tsconfig.json ./backend/
# Build backend
# Build backend first
RUN npm run build --workspace=backend
# Copy database files manually
RUN cp -r backend/src/database/ backend/dist/database/
# Verify Python and OR-Tools installation
RUN python -c "from ortools.sat.python import cp_model; print('OR-Tools installed successfully')"
# Frontend build stage
FROM node:20-bullseye AS frontend-builder
WORKDIR /app
# Copy ALL package files (root + frontend)
COPY package*.json ./
COPY frontend/package.json ./frontend/
# Install dependencies using workspaces
RUN npm ci --workspace=frontend
# Copy frontend source
COPY frontend/src/ ./frontend/src/
COPY frontend/public/ ./frontend/public/
COPY frontend/tsconfig.json ./frontend/
# Build frontend
RUN npm run build --workspace=frontend
# Production stage
# Verify Python and OR-Tools installation
RUN python -c "from ortools.sat.python import cp_model; print('OR-Tools installed successfully')"
# Production stage - same as above
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/dist/ ./dist/
COPY --from=backend-builder /app/backend/node_modules/ ./node_modules/
COPY --from=backend-builder /app/backend/package.json ./
COPY --from=builder /app/backend/dist/ ./dist/
COPY --from=builder /app/backend/package*.json ./
COPY --from=builder /app/node_modules/ ./node_modules/
COPY --from=builder /app/frontend/dist/ ./frontend-build/
COPY --from=builder /app/ecosystem.config.cjs ./
# Copy frontend built files
COPY --from=frontend-builder /app/frontend/build/ ./frontend-build/
# Copy PM2 configuration
COPY ecosystem.config.cjs ./
# Create a non-root user and group - DEBIAN STYLE
RUN groupadd -g 1001 nodejs && \
useradd -m -u 1001 -s /bin/bash -g nodejs schichtplan && \
chown -R schichtplan:nodejs /app && \
chmod 755 /app && \
chmod 775 /app/data
# Set PM2 to use app directory instead of home directory
ENV PM2_HOME=/app/.pm2
USER schichtplan
EXPOSE 3002
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \

View File

@@ -15,7 +15,7 @@ This software, "Schichtenplaner", is offered under a dual licensing model.
- Integration into commercial software or distributions
To obtain a commercial license, please contact:
📧 dev.patrick@mahnke-hartmann.de
📧 patrick@mahnke-hartmann.dev
or open an inquiry via GitHub: https://github.com/donpat1to/Schichtenplaner
Without a valid commercial license, all commercial rights are reserved.

3893
backend/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -40,7 +40,7 @@ app.get('/api/health', (req: any, res: any) => {
});
// 🆕 STATIC FILE SERVING FÜR FRONTEND
const frontendBuildPath = path.join(__dirname, '../frontend-build');
const frontendBuildPath = process.env.FRONTEND_BUILD_PATH || '../frontend-build';
console.log('📁 Frontend build path:', frontendBuildPath);
// Überprüfe ob das Verzeichnis existiert

View File

@@ -1,18 +1,17 @@
// ecosystem.config.cjs
module.exports = {
apps: [
{
name: 'schichtplaner',
apps: [{
name: 'schichtplan-app',
script: './dist/server.js',
instances: 1,
exec_mode: 'fork',
env: {
NODE_ENV: 'production',
PORT: 3002
PORT: 3002,
FRONTEND_BUILD_PATH: './frontend-build'
},
error_file: './logs/app-err.log',
out_file: './logs/app-out.log',
error_file: './logs/err.log',
out_file: './logs/out.log',
log_file: './logs/combined.log',
time: true
}
]
}]
};

13
frontend/index.html Normal file
View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Shift Planning App</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>

View File

@@ -4,44 +4,21 @@
"private": true,
"type": "module",
"dependencies": {
"@testing-library/dom": "^10.4.1",
"@testing-library/jest-dom": "^6.9.1",
"@testing-library/react": "^16.3.0",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.5.2",
"@types/node": "^16.18.126",
"@types/react": "^19.2.2",
"@types/react-dom": "^19.2.1",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-router-dom": "^6.28.0"
},
"devDependencies": {
"@types/react": "^19.0.0",
"@types/react-dom": "^19.0.0",
"@types/react-router-dom": "^5.3.3",
"react": "^19.2.0",
"react-dom": "^19.2.0",
"react-router-dom": "^7.9.3",
"react-scripts": "5.0.1",
"typescript": "^4.9.5",
"web-vitals": "^2.1.4"
"@vitejs/plugin-react": "^4.3.3",
"typescript": "^5.7.3",
"vite": "^6.0.7"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
}
}

View File

@@ -1,9 +0,0 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import App from './App';
test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});

View File

@@ -1,4 +1,4 @@
// frontend/src/App.tsx - ONE-REPO SAFE WITHOUT DYNAMIC IMPORTS
// src/App.tsx - UPDATED FOR VITE
import React from 'react';
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
import { AuthProvider, useAuth } from './contexts/AuthContext';
@@ -22,8 +22,8 @@ import About from './components/Layout/FooterLinks/About/About';
import Features from './components/Layout/FooterLinks/Features/Features';
import { CommunityContact, CommunityLegalPage } from './components/Layout/FooterLinks/CommunityLinks/communityLinks';
// Feature flag from environment
const ENABLE_PRO = process.env.ENABLE_PRO === 'true';
// Vite environment variables (use import.meta.env instead of process.env)
const ENABLE_PRO = import.meta.env.ENABLE_PRO === 'true';
// Conditional Premium Components
let PremiumContact: React.FC = CommunityContact;

View File

@@ -1,3 +1,14 @@
/* Reset and base styles */
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
#root {
min-height: 100vh;
}
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',

View File

@@ -1,19 +0,0 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement
);
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();

10
frontend/src/main.tsx Normal file
View File

@@ -0,0 +1,10 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.tsx'
import './index.css'
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<App />
</React.StrictMode>,
)

View File

@@ -1 +0,0 @@
/// <reference types="react-scripts" />

View File

@@ -1,15 +0,0 @@
import { ReportHandler } from 'web-vitals';
const reportWebVitals = (onPerfEntry?: ReportHandler) => {
if (onPerfEntry && onPerfEntry instanceof Function) {
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
getCLS(onPerfEntry);
getFID(onPerfEntry);
getFCP(onPerfEntry);
getLCP(onPerfEntry);
getTTFB(onPerfEntry);
});
}
};
export default reportWebVitals;

View File

@@ -1,5 +0,0 @@
// jest-dom adds custom jest matchers for asserting on DOM nodes.
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom';

12
frontend/src/vite-env.d.ts vendored Normal file
View File

@@ -0,0 +1,12 @@
/// <reference types="vite/client" />
// Define types for environment variables
interface ImportMetaEnv {
readonly VITE_APP_TITLE: string
readonly ENABLE_PRO: string
// more env variables...
}
interface ImportMeta {
readonly env: ImportMetaEnv
}

View File

@@ -1,28 +1,38 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
//"ignoreDeprecations": "6.0",
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"ignoreDeprecations": "6.0",
"jsx": "react-jsx",
"downlevelIteration": true
/* Linting */
"strict": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"noFallthroughCasesInSwitch": true,
/* Path mapping (modern approach) */
"paths": {
"@/*": ["./src/*"],
"@/components/*": ["./src/components/*"],
"@/pages/*": ["./src/pages/*"],
"@/contexts/*": ["./src/contexts/*"],
"@/utils/*": ["./src/utils/*"],
"@/services/*": ["./src/services/*"],
"@/models/*": ["./src/models/*"],
"@/design/*": ["./src/design/*"]
}
},
"include": [
"src"
]
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}

View File

@@ -0,0 +1,10 @@
{
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}

45
frontend/vite.config.ts Normal file
View File

@@ -0,0 +1,45 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { resolve } from 'path'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
server: {
port: 3003,
host: true,
open: true,
proxy: {
'/api': {
target: 'http://localhost:3002',
changeOrigin: true,
secure: false,
}
}
},
build: {
outDir: 'dist',
sourcemap: true,
rollupOptions: {
input: {
main: resolve(__dirname, 'index.html')
}
}
},
resolve: {
alias: {
'@': resolve(__dirname, './src'),
'@/components': resolve(__dirname, './src/components'),
'@/pages': resolve(__dirname, './src/pages'),
'@/contexts': resolve(__dirname, './src/contexts'),
'@/models': resolve(__dirname, './src/models'),
'@/utils': resolve(__dirname, './src/utils'),
'@/services': resolve(__dirname, './src/services'),
'@/design': resolve(__dirname, './src/design')
}
},
// Define environment variables
define: {
'process.env': process.env
}
})

20130
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -7,15 +7,9 @@
"premium"
],
"scripts": {
"dev:frontend": "cd frontend && npm run dev",
"dev:backend": "cd backend && npm run dev",
"build:all": "npm run build:premium && npm run build:backend && npm run build:frontend",
"build:premium": "cd premium && npm run build",
"build:backend": "cd backend && npm run build",
"build:frontend": "cd frontend && npm run build",
"type-check": "npm run type-check:all",
"type-check:all": "cd premium && npx tsc --noEmit && cd ../backend && npx tsc --noEmit && cd ../frontend && npx tsc --noEmit",
"clean": "rm -rf premium/dist backend/dist frontend/dist"
"docker:build": "docker build -t schichtplan-app .",
"docker:run": "docker run -p 3002:3002 schichtplan-app",
"build:all": "npm run build --workspace=backend && npm run build --workspace=frontend"
},
"devDependencies": {
"typescript": "^5.3.3"