mirror of
https://github.com/donpat1to/Schichtenplaner.git
synced 2025-11-30 22:45:46 +01:00
Compare commits
19 Commits
28283fa8bc
...
v0.0.8
| Author | SHA1 | Date | |
|---|---|---|---|
| 22266c765b | |||
| a66609a40c | |||
| 87dda38bc3 | |||
| 9de501c7eb | |||
| 5c6a50ddcf | |||
| 017f5fb2e0 | |||
| 527954befd | |||
| e7d30151b7 | |||
| 4a006a2e69 | |||
| 4b699b05d3 | |||
| dcac0307a2 | |||
| a0cc859935 | |||
| 49afd75ed3 | |||
| ebb9e3f4fe | |||
| 48f140f930 | |||
| b6b31659e3 | |||
| 42e343777a | |||
| aa7af272d8 | |||
| a0d96925c5 |
14
.github/workflows/docker.yml
vendored
14
.github/workflows/docker.yml
vendored
@@ -3,9 +3,8 @@ name: CI/CD Pipeline
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [ main, master, development ]
|
||||
pull_request:
|
||||
branches: [ main, master, development ]
|
||||
branches: [ "development", "main", "staging" ]
|
||||
tags: [ "v*.*.*" ]
|
||||
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
@@ -113,6 +112,7 @@ jobs:
|
||||
permissions:
|
||||
contents: write
|
||||
packages: write
|
||||
id-token: write
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
@@ -164,7 +164,7 @@ jobs:
|
||||
|
||||
- name: Display pushed images
|
||||
run: |
|
||||
echo "✅ Docker images pushed successfully!"
|
||||
echo "📦 Image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
|
||||
echo "🏷️ Tags: ${{ steps.meta.outputs.tags }}"
|
||||
echo "🚀 New version: ${{ needs.set-tag.outputs.tag_name }}"
|
||||
echo "Docker images pushed successfully!"
|
||||
echo "- Image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
|
||||
echo "- Tags: ${{ steps.meta.outputs.tags }}"
|
||||
echo "- New version: ${{ needs.set-tag.outputs.tag_name }}"
|
||||
|
||||
40
Dockerfile
40
Dockerfile
@@ -5,7 +5,7 @@ WORKDIR /app/backend
|
||||
|
||||
# Install Python + OR-Tools
|
||||
RUN apt-get update && apt-get install -y python3 python3-pip build-essential \
|
||||
&& pip install --no-cache-dir ortools
|
||||
&& pip install --no-cache-dir ortools
|
||||
|
||||
# Create symlink so python3 is callable as python
|
||||
RUN ln -sf /usr/bin/python3 /usr/bin/python
|
||||
@@ -23,13 +23,12 @@ COPY backend/src/ ./src/
|
||||
# Build backend
|
||||
RUN npm run build
|
||||
|
||||
# Copy database files manually
|
||||
RUN cp -r src/database/ dist/database/
|
||||
|
||||
# Verify Python and OR-Tools installation
|
||||
RUN python -c "from ortools.sat.python import cp_model; print('OR-Tools installed successfully')"
|
||||
|
||||
#RUN python3 -c "from ortools.sat.python import cp_model; print('OR-Tools installed successfully')"
|
||||
|
||||
|
||||
# Frontend build stage
|
||||
FROM node:20-bullseye AS frontend-builder
|
||||
|
||||
@@ -50,45 +49,42 @@ COPY frontend/public/ ./public/
|
||||
RUN npm run build
|
||||
|
||||
# Production stage
|
||||
FROM node:20-alpine
|
||||
FROM node:20-bookworm
|
||||
|
||||
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
|
||||
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/
|
||||
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 --from=frontend-builder /app/frontend/build/ ./frontend-build/
|
||||
|
||||
# Copy PM2 configuration
|
||||
COPY ecosystem.config.js ./
|
||||
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 -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
|
||||
|
||||
# Verify installations
|
||||
#RUN python --version && \
|
||||
# python -c "from ortools.sat.python import cp_model; print('OR-Tools verified')"
|
||||
|
||||
EXPOSE 3000 3002
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
||||
CMD wget --no-verbose --tries=1 --spider http://localhost:3002/api/health || exit 1
|
||||
|
||||
CMD ["pm2-runtime", "ecosystem.config.js"]
|
||||
CMD ["pm2-runtime", "ecosystem.config.cjs"]
|
||||
@@ -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;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// ecosystem.config.cjs
|
||||
module.exports = {
|
||||
apps: [
|
||||
{
|
||||
@@ -14,7 +15,7 @@ module.exports = {
|
||||
time: true
|
||||
},
|
||||
{
|
||||
name: 'frontend',
|
||||
name: 'frontend',
|
||||
script: 'npx',
|
||||
args: 'serve -s frontend-build -l 3000',
|
||||
instances: 1,
|
||||
@@ -23,7 +24,7 @@ module.exports = {
|
||||
NODE_ENV: 'production'
|
||||
},
|
||||
error_file: './logs/frontend-err.log',
|
||||
out_file: './logs/frontend-out.log',
|
||||
out_file: './logs/frontend-out.log',
|
||||
time: true
|
||||
}
|
||||
]
|
||||
@@ -20,6 +20,7 @@ interface AuthContextType {
|
||||
}
|
||||
|
||||
const AuthContext = createContext<AuthContextType | undefined>(undefined);
|
||||
const API_BASE_URL = process.env.REACT_APP_API_BASE_URL || 'http://localhost:3002/api';
|
||||
|
||||
interface AuthProviderProps {
|
||||
children: ReactNode;
|
||||
@@ -48,7 +49,7 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {
|
||||
const checkSetupStatus = async (): Promise<void> => {
|
||||
try {
|
||||
console.log('🔍 Checking setup status...');
|
||||
const response = await fetch('http://localhost:3002/api/setup/status');
|
||||
const response = await fetch(`${API_BASE_URL}/setup/status`);
|
||||
if (!response.ok) {
|
||||
throw new Error('Setup status check failed');
|
||||
}
|
||||
@@ -72,7 +73,7 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {
|
||||
return;
|
||||
}
|
||||
|
||||
const response = await fetch('http://localhost:3002/api/auth/me', {
|
||||
const response = await fetch(`${API_BASE_URL}/auth/me`, {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`
|
||||
}
|
||||
@@ -104,7 +105,7 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {
|
||||
try {
|
||||
console.log('🔐 Attempting login for:', credentials.email);
|
||||
|
||||
const response = await fetch('http://localhost:3002/api/auth/login', {
|
||||
const response = await fetch(`${API_BASE_URL}/auth/login`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// frontend/src/services/authService.ts
|
||||
import { Employee } from '../models/Employee';
|
||||
const API_BASE = 'http://localhost:3002/api';
|
||||
const API_BASE = process.env.REACT_APP_API_BASE_URL || 'http://localhost:3002/api';
|
||||
|
||||
export interface LoginRequest {
|
||||
email: string;
|
||||
|
||||
Reference in New Issue
Block a user