Erstelle separate Startskripte für Frontend und Backend
- Erstelle start-frontend.sh für den Frontend-Rechner - Erstelle start-backend.sh für den Backend-Rechner - Beide Skripte enthalten vollständige Installation und Konfiguration - Reduziere Verwirrung durch zu viele Startskripte 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
951473d1ec
commit
fc62086a50
102
start-backend.sh
Executable file
102
start-backend.sh
Executable file
@ -0,0 +1,102 @@
|
||||
#!/bin/bash
|
||||
|
||||
# MYP Backend Installationsskript
|
||||
# Dieses Skript installiert und startet nur das Backend
|
||||
|
||||
set -e # Bei Fehler beenden
|
||||
|
||||
# Farbcodes für Ausgabe
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[0;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Funktion zur Ausgabe mit Zeitstempel
|
||||
log() {
|
||||
echo -e "${BLUE}[$(date +'%Y-%m-%d %H:%M:%S')]${NC} $1"
|
||||
}
|
||||
|
||||
# Prüfen ob Docker installiert ist
|
||||
check_docker() {
|
||||
if ! command -v docker &> /dev/null; then
|
||||
log "${RED}Docker ist nicht installiert. Bitte installieren Sie Docker.${NC}"
|
||||
log "Installiere Docker mit:"
|
||||
echo "sudo apt update && sudo apt install -y docker.io docker-compose"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Backend installieren und starten
|
||||
setup_backend() {
|
||||
log "${GREEN}Starte Installation des Backends...${NC}"
|
||||
|
||||
# In das Backend-Verzeichnis wechseln
|
||||
cd "$(dirname "$0")/backend"
|
||||
|
||||
# .env Datei erstellen mit den korrekten Daten
|
||||
log "${YELLOW}Erstelle .env Datei mit korrekten Zugangsdaten${NC}"
|
||||
cat > .env << EOL
|
||||
SECRET_KEY=7445630171969DFAC92C53CEC92E67A9CB2E00B3CB2F
|
||||
DATABASE_PATH=instance/myp.db
|
||||
TAPO_USERNAME=till.tomczak@mercedes-benz.com
|
||||
TAPO_PASSWORD=744563017196A
|
||||
PRINTERS={"Printer 1": {"ip": "192.168.0.100"}, "Printer 2": {"ip": "192.168.0.101"}, "Printer 3": {"ip": "192.168.0.102"}, "Printer 4": {"ip": "192.168.0.103"}, "Printer 5": {"ip": "192.168.0.104"}, "Printer 6": {"ip": "192.168.0.106"}}
|
||||
EOL
|
||||
|
||||
# Docker-Compose Datei anpassen (falls nötig)
|
||||
log "Überprüfe docker-compose.yml"
|
||||
cat > docker-compose.yml << EOL
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
backend:
|
||||
build: .
|
||||
container_name: myp-backend
|
||||
network_mode: host
|
||||
environment:
|
||||
- SECRET_KEY=7445630171969DFAC92C53CEC92E67A9CB2E00B3CB2F
|
||||
- DATABASE_PATH=instance/myp.db
|
||||
- TAPO_USERNAME=till.tomczak@mercedes-benz.com
|
||||
- TAPO_PASSWORD=744563017196A
|
||||
- PRINTERS={"Printer 1": {"ip": "192.168.0.100"}, "Printer 2": {"ip": "192.168.0.101"}, "Printer 3": {"ip": "192.168.0.102"}, "Printer 4": {"ip": "192.168.0.103"}, "Printer 5": {"ip": "192.168.0.104"}, "Printer 6": {"ip": "192.168.0.106"}}
|
||||
volumes:
|
||||
- ./logs:/app/logs
|
||||
- ./instance:/app/instance
|
||||
restart: unless-stopped
|
||||
EOL
|
||||
|
||||
# Logs-Verzeichnis erstellen
|
||||
log "Erstelle Logs-Verzeichnis"
|
||||
mkdir -p logs
|
||||
|
||||
# Instance-Verzeichnis für SQLite erstellen
|
||||
log "Erstelle Instance-Verzeichnis für Datenbank"
|
||||
mkdir -p instance
|
||||
|
||||
# Docker-Image bauen und starten
|
||||
log "Baue und starte Backend-Container"
|
||||
docker-compose up -d --build
|
||||
|
||||
log "${GREEN}Backend erfolgreich installiert und gestartet!${NC}"
|
||||
log "Zugriff unter: http://localhost:5000"
|
||||
}
|
||||
|
||||
# Hauptprogramm
|
||||
main() {
|
||||
log "${BLUE}=== MYP Backend Installation ===${NC}"
|
||||
|
||||
# Prüfen ob Docker vorhanden ist
|
||||
check_docker
|
||||
|
||||
# Backend installieren
|
||||
setup_backend
|
||||
|
||||
log "${GREEN}=== Installation abgeschlossen ===${NC}"
|
||||
|
||||
# Status anzeigen
|
||||
docker ps | grep myp-backend
|
||||
}
|
||||
|
||||
# Ausführen
|
||||
main
|
140
start-frontend.sh
Executable file
140
start-frontend.sh
Executable file
@ -0,0 +1,140 @@
|
||||
#!/bin/bash
|
||||
|
||||
# MYP Frontend Installationsskript
|
||||
# Dieses Skript installiert und startet nur das Frontend
|
||||
|
||||
set -e # Bei Fehler beenden
|
||||
|
||||
# Farbcodes für Ausgabe
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[0;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Funktion zur Ausgabe mit Zeitstempel
|
||||
log() {
|
||||
echo -e "${BLUE}[$(date +'%Y-%m-%d %H:%M:%S')]${NC} $1"
|
||||
}
|
||||
|
||||
# Prüfen ob Docker installiert ist
|
||||
check_docker() {
|
||||
if ! command -v docker &> /dev/null; then
|
||||
log "${RED}Docker ist nicht installiert. Bitte installieren Sie Docker.${NC}"
|
||||
log "Installiere Docker mit:"
|
||||
echo "sudo apt update && sudo apt install -y docker.io docker-compose"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Frontend installieren und starten
|
||||
setup_frontend() {
|
||||
log "${GREEN}Starte Installation des Frontends...${NC}"
|
||||
|
||||
# In das Frontend-Verzeichnis wechseln
|
||||
cd "$(dirname "$0")/packages/reservation-platform"
|
||||
|
||||
# .env Datei erstellen mit den korrekten Daten
|
||||
log "${YELLOW}Erstelle .env Datei${NC}"
|
||||
cat > .env << EOL
|
||||
# Basic Server Configuration
|
||||
RUNTIME_ENVIRONMENT=prod
|
||||
DB_PATH=db/sqlite.db
|
||||
|
||||
# OAuth Configuration (Bitte anpassen)
|
||||
OAUTH_CLIENT_ID=client_id
|
||||
OAUTH_CLIENT_SECRET=client_secret
|
||||
EOL
|
||||
|
||||
# Datenbank-Verzeichnis erstellen
|
||||
log "Erstelle Datenbankverzeichnis"
|
||||
mkdir -p db
|
||||
|
||||
# Docker-Compose Datei erstellen (falls nicht vorhanden)
|
||||
if [ ! -f docker-compose.yml ]; then
|
||||
log "Erstelle docker-compose.yml"
|
||||
cat > docker-compose.yml << EOL
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
frontend:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
container_name: myp-frontend
|
||||
network_mode: host
|
||||
environment:
|
||||
- RUNTIME_ENVIRONMENT=\${RUNTIME_ENVIRONMENT:-prod}
|
||||
- OAUTH_CLIENT_ID=\${OAUTH_CLIENT_ID:-client_id}
|
||||
- OAUTH_CLIENT_SECRET=\${OAUTH_CLIENT_SECRET:-client_secret}
|
||||
volumes:
|
||||
- ./db:/app/db
|
||||
restart: unless-stopped
|
||||
EOL
|
||||
fi
|
||||
|
||||
# Dockerfile erstellen (falls nicht vorhanden)
|
||||
if [ ! -f Dockerfile ]; then
|
||||
log "Erstelle Dockerfile"
|
||||
cat > Dockerfile << EOL
|
||||
FROM node:20-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install system dependencies
|
||||
RUN apk add --no-cache python3 build-base g++ make
|
||||
|
||||
# Install pnpm
|
||||
RUN npm install -g pnpm
|
||||
|
||||
# Copy package files
|
||||
COPY package.json pnpm-lock.yaml ./
|
||||
|
||||
# Install dependencies
|
||||
RUN pnpm install --frozen-lockfile
|
||||
|
||||
# Copy source code
|
||||
COPY . .
|
||||
|
||||
# Create database directory and run migrations
|
||||
RUN mkdir -p db/
|
||||
RUN pnpm db:generate-sqlite
|
||||
RUN pnpm db:migrate
|
||||
|
||||
# Build the application
|
||||
RUN pnpm build
|
||||
|
||||
# Expose the port
|
||||
EXPOSE 3000
|
||||
|
||||
# Start the application
|
||||
CMD ["pnpm", "start"]
|
||||
EOL
|
||||
fi
|
||||
|
||||
# Docker-Image bauen und starten
|
||||
log "Baue und starte Frontend-Container"
|
||||
docker-compose up -d --build
|
||||
|
||||
log "${GREEN}Frontend erfolgreich installiert und gestartet!${NC}"
|
||||
log "Zugriff unter: http://localhost:3000"
|
||||
}
|
||||
|
||||
# Hauptprogramm
|
||||
main() {
|
||||
log "${BLUE}=== MYP Frontend Installation ===${NC}"
|
||||
|
||||
# Prüfen ob Docker vorhanden ist
|
||||
check_docker
|
||||
|
||||
# Frontend installieren
|
||||
setup_frontend
|
||||
|
||||
log "${GREEN}=== Installation abgeschlossen ===${NC}"
|
||||
|
||||
# Status anzeigen
|
||||
docker ps | grep myp-frontend
|
||||
}
|
||||
|
||||
# Ausführen
|
||||
main
|
Loading…
x
Reference in New Issue
Block a user