- 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>
140 lines
3.0 KiB
Bash
Executable File
140 lines
3.0 KiB
Bash
Executable File
#!/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 |