#!/bin/bash

echo "Building YourPart Frontend..."

# Zum Frontend-Verzeichnis wechseln
cd frontend

# Dependencies installieren
echo "Installing dependencies..."
npm ci --production

# Frontend bauen
echo "Building frontend..."
npm run build

# Build-Verzeichnis nach /opt/yourpart kopieren
echo "Copying build to /opt/yourpart/frontend/dist..."
sudo mkdir -p /opt/yourpart/frontend
sudo cp -r dist /opt/yourpart/frontend/

# Berechtigungen setzen
echo "Setting permissions..."
sudo chown -R www-data:www-data /opt/yourpart/frontend
sudo chmod -R 755 /opt/yourpart/frontend

echo "Frontend build completed!"
