setup script update
This commit is contained in:
@@ -77,4 +77,105 @@ After=network.target
|
||||
User=$USER_ROOT
|
||||
WorkingDirectory=$BACKEND_DIR
|
||||
ExecStart=$BACKEND_DIR/venv/bin/uvicorn src.main:app --host 0.0.0.0 --port 8000
|
||||
Restar
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOL
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable $BACKEND_SERVICE
|
||||
systemctl restart $BACKEND_SERVICE
|
||||
|
||||
# -----------------------------
|
||||
# Nginx Setup
|
||||
# -----------------------------
|
||||
echo "==> Configure Nginx"
|
||||
cat >$NGINX_SITE <<EOL
|
||||
server {
|
||||
listen 80;
|
||||
|
||||
server_name _;
|
||||
|
||||
# Frontend
|
||||
root $FRONTEND_DIR/build;
|
||||
index index.html;
|
||||
|
||||
location / {
|
||||
try_files \$uri /index.html;
|
||||
}
|
||||
|
||||
# Backend API
|
||||
location /api/ {
|
||||
proxy_pass http://127.0.0.1:8000/;
|
||||
proxy_set_header Host \$host;
|
||||
proxy_set_header X-Real-IP \$remote_addr;
|
||||
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto \$scheme;
|
||||
}
|
||||
}
|
||||
EOL
|
||||
|
||||
ln -sf $NGINX_SITE /etc/nginx/sites-enabled/
|
||||
nginx -t
|
||||
systemctl restart nginx
|
||||
|
||||
# -----------------------------
|
||||
# Gitea Runner installieren
|
||||
# -----------------------------
|
||||
echo "==> Install Gitea Runner"
|
||||
RUNNER_DIR="/opt/gitea-runner"
|
||||
mkdir -p $RUNNER_DIR
|
||||
cd $RUNNER_DIR
|
||||
|
||||
# Download aktueller gitea-runner (Linux x64)
|
||||
GITEA_RUNNER_BIN="actions-runner-linux-x64-2.305.0.tar.gz"
|
||||
wget -O $GITEA_RUNNER_BIN "https://dl.gitea.io/gitea/runner/latest/actions-runner-linux-x64.tar.gz"
|
||||
tar xzf $GITEA_RUNNER_BIN
|
||||
rm $GITEA_RUNNER_BIN
|
||||
|
||||
# Runner konfigurieren
|
||||
./config.sh --url "https://gitea.malmert.de/marcus/mitm-webserver" --token $RUNNER_TOKEN --name $RUNNER_NAME --unattended --replace
|
||||
|
||||
# Systemd Service für Runner
|
||||
./svc.sh install
|
||||
./svc.sh start
|
||||
|
||||
# -----------------------------
|
||||
# Gitea Runner Job Script
|
||||
# -----------------------------
|
||||
echo "==> Setup auto-build script"
|
||||
BUILD_SCRIPT="$RUNNER_DIR/build.sh"
|
||||
cat >$BUILD_SCRIPT <<'EOL'
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
APP_DIR="/opt/mitm-webserver"
|
||||
FRONTEND_DIR="$APP_DIR/frontend"
|
||||
BACKEND_DIR="$APP_DIR/backend"
|
||||
BACKEND_SERVICE="mitm-backend"
|
||||
|
||||
cd $APP_DIR
|
||||
git reset --hard
|
||||
git pull
|
||||
|
||||
# Build Frontend
|
||||
cd $FRONTEND_DIR
|
||||
npm install
|
||||
npm run build
|
||||
|
||||
# Backend Dependencies
|
||||
cd $BACKEND_DIR
|
||||
source venv/bin/activate
|
||||
pip install -r requirements.txt
|
||||
deactivate
|
||||
|
||||
# Restart backend
|
||||
systemctl restart $BACKEND_SERVICE
|
||||
EOL
|
||||
|
||||
chmod +x $BUILD_SCRIPT
|
||||
|
||||
echo "==> Setup complete! Gitea Runner will automatically build on push."
|
||||
echo "Frontend: http://<server_ip>/"
|
||||
echo "Backend API: http://<server_ip>/api/"
|
||||
|
||||
Reference in New Issue
Block a user