Riorganizzazione deployment, doc e publish automatico
- Spostata tutta la configurazione di deployment in /deployment (docker-compose, unraid-template, guide) - Aggiunte e aggiornate guide dettagliate: publishing su Gitea, installazione Unraid, struttura progetto - Migliorato target MSBuild: publish automatico su Gitea Registry da Visual Studio, log dettagliati, condizioni più robuste - Aggiornato e ampliato .gitignore per escludere build, dati e file locali - Rimossi file obsoleti dalla root (ora tutto in /deployment) - Struttura più chiara, zero script esterni, documentazione completa e workflow di deploy semplificato
This commit is contained in:
647
TradingBot/deployment/UNRAID_INSTALL.md
Normal file
647
TradingBot/deployment/UNRAID_INSTALL.md
Normal file
@@ -0,0 +1,647 @@
|
||||
# ?? TradingBot - Installazione su Unraid (Senza Portainer)
|
||||
|
||||
## ? Installazione Diretta da Gitea Registry
|
||||
|
||||
Puoi installare TradingBot direttamente dall'Unraid Docker Manager usando il tuo Gitea Registry!
|
||||
|
||||
---
|
||||
|
||||
## ?? PREREQUISITI
|
||||
|
||||
### 1. Login Gitea Registry su Unraid
|
||||
|
||||
SSH su Unraid:
|
||||
|
||||
```bash
|
||||
ssh root@192.168.30.23 # O IP Tailscale
|
||||
|
||||
# Login al Gitea Registry
|
||||
docker login gitea.encke-hake.ts.net
|
||||
|
||||
# Username: Alby96
|
||||
# Password: [Personal Access Token Gitea]
|
||||
```
|
||||
|
||||
**Output atteso**:
|
||||
```
|
||||
Login Succeeded ?
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ?? METODO 1: Template XML (Consigliato)
|
||||
|
||||
### Step 1: Copia Template su Unraid
|
||||
|
||||
```bash
|
||||
# Su Unraid
|
||||
mkdir -p /boot/config/plugins/dockerMan/templates-user
|
||||
|
||||
# Scarica template
|
||||
wget -O /boot/config/plugins/dockerMan/templates-user/TradingBot.xml \
|
||||
https://gitea.encke-hake.ts.net/Alby96/Encelado/raw/branch/main/TradingBot/deployment/unraid-template.xml
|
||||
```
|
||||
|
||||
### Step 2: Installa Container
|
||||
|
||||
1. Unraid WebUI ? **Docker** tab
|
||||
2. Click **Add Container** (in fondo)
|
||||
3. **Template**: Dropdown ? Seleziona **TradingBot**
|
||||
4. Configura parametri:
|
||||
|
||||
**Parametri Base**:
|
||||
- **Name**: `TradingBot` (già impostato)
|
||||
- **Repository**: `gitea.encke-hake.ts.net/alby96/encelado/tradingbot:latest` (già impostato)
|
||||
|
||||
**Porta WebUI** (Importante!):
|
||||
- **WebUI Port**: `8080` (cambia se occupata, es. `8081`, `9000`, etc.)
|
||||
- Questa è la porta per accedere all'interfaccia web
|
||||
|
||||
**Volume Dati**:
|
||||
- **AppData**: `/mnt/user/appdata/tradingbot` (già impostato)
|
||||
- Puoi cambiare se preferisci altra directory
|
||||
|
||||
**Variabili Ambiente** (Avanzate - opzionali):
|
||||
- **ASPNETCORE_ENVIRONMENT**: `Production` (non modificare)
|
||||
- **ASPNETCORE_URLS**: `http://+:8080` (non modificare)
|
||||
- **TZ**: `Europe/Rome` (cambia per altro timezone)
|
||||
|
||||
5. Click **Apply**
|
||||
|
||||
Unraid farà:
|
||||
- ? Pull immagine da Gitea Registry
|
||||
- ? Crea container con nome "TradingBot"
|
||||
- ? Configura porta WebUI (default 8080)
|
||||
- ? Crea volume per persistenza dati
|
||||
- ? Start automatico
|
||||
|
||||
### Step 3: Accedi WebUI
|
||||
|
||||
**Metodo A: Click su WebUI Icon**
|
||||
|
||||
1. **Docker tab** ? Trova container **TradingBot**
|
||||
2. Nella colonna "WebUI", click sull'**icona globe** ??
|
||||
3. Si aprirà la dashboard nel browser
|
||||
|
||||
**Metodo B: URL Manuale**
|
||||
|
||||
```
|
||||
http://192.168.30.23:8080
|
||||
```
|
||||
|
||||
(Sostituisci `8080` con la porta che hai configurato)
|
||||
|
||||
Dovresti vedere la **Dashboard TradingBot**! ??
|
||||
|
||||
---
|
||||
|
||||
## ?? METODO 2: Installazione Manuale
|
||||
|
||||
Se preferisci non usare template:
|
||||
|
||||
### Step 1: Unraid Docker Tab
|
||||
|
||||
1. **Docker** ? **Add Container**
|
||||
2. **Name**: `TradingBot`
|
||||
|
||||
### Step 2: Configurazione Base
|
||||
|
||||
**Repository**:
|
||||
```
|
||||
gitea.encke-hake.ts.net/alby96/encelado/tradingbot:latest
|
||||
```
|
||||
|
||||
**Network Type**: `Bridge`
|
||||
|
||||
**Console shell command**: `Shell`
|
||||
|
||||
### Step 3: Port Mapping
|
||||
|
||||
Click **Add another Path, Port, Variable, Label or Device**
|
||||
|
||||
**Config Type**: `Port`
|
||||
- **Name**: `WebUI`
|
||||
- **Container Port**: `8080`
|
||||
- **Host Port**: `8080` ? **Cambia questa se occupata!**
|
||||
- **Connection Type**: `TCP`
|
||||
|
||||
### Step 4: Volume Mapping
|
||||
|
||||
Click **Add another Path, Port, Variable, Label or Device**
|
||||
|
||||
**Config Type**: `Path`
|
||||
- **Name**: `AppData`
|
||||
- **Container Path**: `/app/data`
|
||||
- **Host Path**: `/mnt/user/appdata/tradingbot`
|
||||
- **Access Mode**: `Read/Write`
|
||||
|
||||
### Step 5: Environment Variables
|
||||
|
||||
**ASPNETCORE_ENVIRONMENT**:
|
||||
- **Name**: `ASPNETCORE_ENVIRONMENT`
|
||||
- **Value**: `Production`
|
||||
|
||||
**ASPNETCORE_URLS**:
|
||||
- **Name**: `ASPNETCORE_URLS`
|
||||
- **Value**: `http://+:8080`
|
||||
|
||||
**TZ** (Opzionale):
|
||||
- **Name**: `TZ`
|
||||
- **Value**: `Europe/Rome` (o tuo timezone)
|
||||
|
||||
### Step 6: Health Check (Opzionale ma Consigliato)
|
||||
|
||||
**Extra Parameters**:
|
||||
```
|
||||
--health-cmd="wget --no-verbose --tries=1 --spider http://localhost:8080/ || exit 1" --health-interval=30s --health-timeout=3s --health-retries=3 --health-start-period=40s
|
||||
```
|
||||
|
||||
### Step 7: Apply
|
||||
|
||||
Click **Apply** in fondo alla pagina.
|
||||
|
||||
---
|
||||
|
||||
## ?? AGGIORNAMENTO CONTAINER
|
||||
|
||||
### Via Unraid Docker Tab
|
||||
|
||||
1. **Docker** ? Trova **TradingBot**
|
||||
2. Click **icona Stop** (ferma container)
|
||||
3. Click **Force Update** (icona update con freccia circolare)
|
||||
4. Attendi pull dell'immagine aggiornata
|
||||
5. Click **icona Start** (avvia container)
|
||||
|
||||
Unraid farà:
|
||||
- ? Pull ultima immagine da Gitea
|
||||
- ? Ricrea container con nuova immagine
|
||||
- ? Mantiene dati persistenti (volume non viene toccato)
|
||||
- ? Mantiene configurazione (porta, variabili, etc.)
|
||||
|
||||
### Automatico con User Scripts Plugin
|
||||
|
||||
Installa **User Scripts** plugin:
|
||||
|
||||
1. **Apps** ? Cerca "User Scripts"
|
||||
2. Installa
|
||||
|
||||
Crea script update:
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
# Nome: Update TradingBot
|
||||
# Schedula: Weekly (ogni domenica alle 3:00 AM)
|
||||
|
||||
# Stop container
|
||||
docker stop TradingBot
|
||||
|
||||
# Pull latest image
|
||||
docker pull gitea.encke-hake.ts.net/alby96/encelado/tradingbot:latest
|
||||
|
||||
# Start container (Unraid ricrea automaticamente)
|
||||
docker start TradingBot
|
||||
|
||||
# Notifica
|
||||
/usr/local/emhttp/webGui/scripts/notify -s "TradingBot Update" -d "Container aggiornato con successo!" -i "normal"
|
||||
|
||||
echo "Update completato alle $(date)"
|
||||
```
|
||||
|
||||
Schedula: Settimanale o manualmente quando serve.
|
||||
|
||||
---
|
||||
|
||||
## ??? CONFIGURAZIONE PORTA
|
||||
|
||||
### Cambiare Porta WebUI
|
||||
|
||||
Se la porta `8080` è già occupata o vuoi usarne un'altra:
|
||||
|
||||
#### **Via Template (Prima Installazione)**
|
||||
|
||||
Durante Step 2 dell'installazione:
|
||||
- **WebUI Port**: Cambia da `8080` a porta desiderata (es. `8081`, `9000`, `8888`)
|
||||
|
||||
#### **Via Edit (Container Esistente)**
|
||||
|
||||
1. **Docker tab** ? Container **TradingBot**
|
||||
2. Click **Edit** (icona matita)
|
||||
3. Trova sezione **Port Mappings**
|
||||
4. Modifica **Host Port** (es. da `8080` a `8081`)
|
||||
5. **IMPORTANTE**: Non modificare **Container Port** (deve restare `8080`)
|
||||
6. Click **Apply**
|
||||
7. Container si riavvierà automaticamente
|
||||
|
||||
#### **Accesso con Nuova Porta**
|
||||
|
||||
```
|
||||
http://192.168.30.23:NUOVA_PORTA
|
||||
```
|
||||
|
||||
Esempio con porta `8081`:
|
||||
```
|
||||
http://192.168.30.23:8081
|
||||
```
|
||||
|
||||
### Porte Comuni Disponibili
|
||||
|
||||
Se `8080` è occupata, prova queste:
|
||||
- `8081` - Spesso libera
|
||||
- `9000` - Usata da Portainer ma se non hai Portainer è libera
|
||||
- `8888` - Buona alternativa
|
||||
- `7070` - Altra opzione
|
||||
- `3000` - Se libera
|
||||
|
||||
**Check porta disponibile**:
|
||||
```bash
|
||||
netstat -tulpn | grep :8080
|
||||
# Se restituisce risultato, porta occupata
|
||||
# Se vuoto, porta libera
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ?? GESTIONE CONTAINER
|
||||
|
||||
### Start/Stop/Restart
|
||||
|
||||
**Docker tab** ? Container **TradingBot**:
|
||||
- ?? **Start**: Avvia container
|
||||
- ?? **Pause**: Pausa (mantiene in memoria)
|
||||
- ?? **Stop**: Ferma completamente
|
||||
- ?? **Restart**: Riavvia
|
||||
- ??? **Remove**: Elimina container (dati persistenti restano)
|
||||
|
||||
### View Logs
|
||||
|
||||
**Docker tab** ? Container **TradingBot** ? Click **icona logs** (terminale)
|
||||
|
||||
Oppure via SSH:
|
||||
```bash
|
||||
docker logs TradingBot -f
|
||||
# -f = follow (real-time)
|
||||
# Ctrl+C per uscire
|
||||
```
|
||||
|
||||
### Console Access
|
||||
|
||||
**Docker tab** ? Container **TradingBot** ? Click **icona console** (bash)
|
||||
|
||||
Oppure via SSH:
|
||||
```bash
|
||||
docker exec -it TradingBot sh
|
||||
# sh invece di bash (Alpine Linux base)
|
||||
```
|
||||
|
||||
### Statistics
|
||||
|
||||
**Docker tab** ? Container **TradingBot** ? Click **icona stats** (grafico)
|
||||
|
||||
Mostra:
|
||||
- **CPU**: Utilizzo percentuale
|
||||
- **Memory**: RAM utilizzata/disponibile
|
||||
- **Network I/O**: Traffico in/out
|
||||
- **Block I/O**: Lettura/scrittura disco
|
||||
|
||||
---
|
||||
|
||||
## ?? ACCESSO WEBUI
|
||||
|
||||
### Locale (Unraid LAN)
|
||||
|
||||
```
|
||||
http://192.168.30.23:8080
|
||||
```
|
||||
|
||||
Sostituisci:
|
||||
- `192.168.30.23` con IP del tuo Unraid
|
||||
- `8080` con porta configurata
|
||||
|
||||
### Via Tailscale
|
||||
|
||||
Se hai configurato Tailscale su Unraid:
|
||||
|
||||
```
|
||||
http://unraid.encke-hake.ts.net:8080
|
||||
```
|
||||
|
||||
### Via Hostname Unraid
|
||||
|
||||
Se hai configurato hostname:
|
||||
|
||||
```
|
||||
http://tower:8080
|
||||
```
|
||||
|
||||
(Sostituisci `tower` con hostname del tuo Unraid)
|
||||
|
||||
### Reverse Proxy (Accesso HTTPS)
|
||||
|
||||
Se usi **Nginx Proxy Manager** o **Swag**:
|
||||
|
||||
```nginx
|
||||
# Nginx Proxy Manager
|
||||
Upstream: http://192.168.30.23:8080
|
||||
Domain: tradingbot.tuo-dominio.com
|
||||
SSL: Let's Encrypt
|
||||
```
|
||||
|
||||
Poi accedi via:
|
||||
```
|
||||
https://tradingbot.tuo-dominio.com
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ?? SICUREZZA
|
||||
|
||||
### Best Practices
|
||||
|
||||
? **Porta non esposta pubblicamente** (solo LAN o VPN)
|
||||
? **Volume dati protetto** (`/mnt/user/appdata/tradingbot/`)
|
||||
? **Registry privato** (Gitea richiede login)
|
||||
? **Certificati validi** (Tailscale)
|
||||
? **User non-root** (già configurato nel Dockerfile)
|
||||
? **Health checks** attivi per monitoring
|
||||
|
||||
### Backup Dati
|
||||
|
||||
#### **Manuale**
|
||||
|
||||
```bash
|
||||
# Backup
|
||||
tar -czf /mnt/user/backups/tradingbot-$(date +%Y%m%d).tar.gz \
|
||||
/mnt/user/appdata/tradingbot
|
||||
|
||||
# Restore
|
||||
tar -xzf /mnt/user/backups/tradingbot-20241217.tar.gz -C /mnt/user/appdata/
|
||||
```
|
||||
|
||||
#### **Con CA Backup Plugin**
|
||||
|
||||
1. **Apps** ? Installa "**CA Backup / Restore Appdata**"
|
||||
2. **Settings** ? **CA Backup/Restore**
|
||||
3. Aggiungi `/mnt/user/appdata/tradingbot` alla lista
|
||||
4. Configura schedule automatico (es. giornaliero alle 2:00 AM)
|
||||
|
||||
---
|
||||
|
||||
## ?? TROUBLESHOOTING
|
||||
|
||||
### WebUI Non Accessibile
|
||||
|
||||
**Checklist Diagnostica**:
|
||||
|
||||
1. ? **Container Running?**
|
||||
```bash
|
||||
docker ps | grep TradingBot
|
||||
# Deve mostrare: Up X minutes (healthy)
|
||||
```
|
||||
|
||||
2. ? **Porta Corretta?**
|
||||
```bash
|
||||
docker port TradingBot
|
||||
# Output: 8080/tcp -> 0.0.0.0:8080
|
||||
```
|
||||
|
||||
3. ? **Health Check?**
|
||||
```bash
|
||||
docker inspect TradingBot | grep -A5 Health
|
||||
# Status deve essere "healthy"
|
||||
```
|
||||
|
||||
4. ? **Test Locale**:
|
||||
```bash
|
||||
curl http://localhost:8080/
|
||||
# Deve restituire HTML
|
||||
```
|
||||
|
||||
5. ? **Check Logs**:
|
||||
```bash
|
||||
docker logs TradingBot --tail 50
|
||||
# Cerca errori
|
||||
```
|
||||
|
||||
**Soluzioni Comuni**:
|
||||
|
||||
#### Errore: "Cannot access WebUI"
|
||||
|
||||
**Causa**: Porta host occupata o container non started
|
||||
|
||||
**Fix**:
|
||||
```bash
|
||||
# 1. Verifica porta libera
|
||||
netstat -tulpn | grep :8080
|
||||
|
||||
# 2. Se occupata, edit container e cambia porta
|
||||
# Docker tab ? Edit ? Port 8080 ? 8081 ? Apply
|
||||
|
||||
# 3. Restart container
|
||||
docker restart TradingBot
|
||||
```
|
||||
|
||||
#### Errore: "Connection refused"
|
||||
|
||||
**Causa**: Container started ma app non ready
|
||||
|
||||
**Fix**:
|
||||
```bash
|
||||
# Attendi 40 secondi (start period)
|
||||
sleep 40
|
||||
|
||||
# Poi testa
|
||||
curl http://192.168.30.23:8080/
|
||||
```
|
||||
|
||||
#### Errore: "Unhealthy" status
|
||||
|
||||
**Causa**: Health check fallisce
|
||||
|
||||
**Fix**:
|
||||
```bash
|
||||
# Check logs per errori app
|
||||
docker logs TradingBot
|
||||
|
||||
# Possibili cause:
|
||||
# - Porta interna sbagliata in ASPNETCORE_URLS
|
||||
# - App crashed al startup
|
||||
# - Manca volume /app/data
|
||||
|
||||
# Ricrea container:
|
||||
docker stop TradingBot
|
||||
docker rm TradingBot
|
||||
# Reinstalla da template
|
||||
```
|
||||
|
||||
### Container Non Si Avvia
|
||||
|
||||
**Check logs**:
|
||||
```bash
|
||||
docker logs TradingBot
|
||||
```
|
||||
|
||||
**Problemi comuni**:
|
||||
|
||||
#### Porta occupata
|
||||
```
|
||||
Error: address already in use
|
||||
```
|
||||
**Fix**: Cambia **Host Port** in configurazione container (Edit ? Port Mappings)
|
||||
|
||||
#### Pull failed
|
||||
```
|
||||
Error: unauthorized: authentication required
|
||||
```
|
||||
**Fix**:
|
||||
```bash
|
||||
docker login gitea.encke-hake.ts.net
|
||||
# Inserisci credenziali
|
||||
```
|
||||
|
||||
#### Image not found
|
||||
```
|
||||
Error: manifest not found
|
||||
```
|
||||
**Fix**: Verifica immagine esista su Gitea Packages:
|
||||
```
|
||||
https://gitea.encke-hake.ts.net/Alby96/Encelado/-/packages
|
||||
```
|
||||
|
||||
### Performance Issues
|
||||
|
||||
**Check risorse**:
|
||||
```bash
|
||||
docker stats TradingBot
|
||||
```
|
||||
|
||||
**Limiti raccomandati**:
|
||||
- **CPU**: 1-2 cores
|
||||
- **Memory**: 512MB - 1GB
|
||||
|
||||
**Configura limiti** (Edit ? Extra Parameters):
|
||||
```
|
||||
--cpus="1.5" --memory="768m"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ?? CHECKLIST INSTALLAZIONE
|
||||
|
||||
### Pre-Install
|
||||
- [ ] Unraid 6.10+ installato
|
||||
- [ ] Docker service attivo
|
||||
- [ ] Porta 8080 (o alternativa) disponibile
|
||||
- [ ] `docker login gitea.encke-hake.ts.net` successful
|
||||
- [ ] Internet attivo per pull immagine
|
||||
|
||||
### Install
|
||||
- [ ] Template XML scaricato su Unraid
|
||||
- [ ] Container creato da template
|
||||
- [ ] Porta WebUI configurata
|
||||
- [ ] Volume AppData creato
|
||||
- [ ] Container status: **running**
|
||||
|
||||
### Post-Install
|
||||
- [ ] Health check: **healthy** (dopo 40 sec)
|
||||
- [ ] WebUI accessibile (http://IP:PORT)
|
||||
- [ ] Dashboard carica correttamente
|
||||
- [ ] Settings modificabili e salvabili
|
||||
- [ ] Bot avviabile dalla UI
|
||||
|
||||
---
|
||||
|
||||
## ?? VANTAGGI UNRAID NATIVO
|
||||
|
||||
? **Zero dipendenze** (no Portainer, no docker-compose)
|
||||
? **WebUI Unraid integrata** (gestione familiare)
|
||||
? **Auto-start** (container parte con Unraid)
|
||||
? **Backup integrato** (con plugin CA)
|
||||
? **Update semplice** (2 click: Stop ? Update ? Start)
|
||||
? **Template riutilizzabile** (reinstall in 1 minuto)
|
||||
? **Health monitoring** integrato
|
||||
? **Logs accessibili** dalla UI
|
||||
|
||||
---
|
||||
|
||||
## ?? WORKFLOW COMPLETO
|
||||
|
||||
### Sviluppo (PC)
|
||||
```
|
||||
1. ?? Visual Studio ? Codice
|
||||
2. ?? Build ? Publish (Docker profile)
|
||||
3. ? Automatico: Push Gitea Registry
|
||||
4. ?? git push origin main
|
||||
```
|
||||
|
||||
### Deploy (Unraid)
|
||||
```
|
||||
1. ?? Docker tab ? TradingBot
|
||||
2. ?? Stop
|
||||
3. ?? Force Update (pull latest)
|
||||
4. ?? Start
|
||||
5. ? Done! (~ 1 minuto)
|
||||
```
|
||||
|
||||
**Tempo totale**: ~2 minuti dal commit al running!
|
||||
|
||||
---
|
||||
|
||||
## ?? RISORSE
|
||||
|
||||
### Links Utili
|
||||
|
||||
| Risorsa | URL |
|
||||
|---------|-----|
|
||||
| **Template XML** | `https://gitea.encke-hake.ts.net/Alby96/Encelado/raw/branch/main/TradingBot/deployment/unraid-template.xml` |
|
||||
| **Repository Git** | `https://gitea.encke-hake.ts.net/Alby96/Encelado` |
|
||||
| **Docker Image** | `gitea.encke-hake.ts.net/alby96/encelado/tradingbot:latest` |
|
||||
| **Packages** | `https://gitea.encke-hake.ts.net/Alby96/Encelado/-/packages` |
|
||||
| **Support/Issues** | `https://gitea.encke-hake.ts.net/Alby96/Encelado/issues` |
|
||||
|
||||
### Comandi Utili
|
||||
|
||||
```bash
|
||||
# Status container
|
||||
docker ps -a | grep TradingBot
|
||||
|
||||
# Logs real-time
|
||||
docker logs -f TradingBot
|
||||
|
||||
# Statistics
|
||||
docker stats TradingBot --no-stream
|
||||
|
||||
# Health check
|
||||
docker inspect TradingBot --format='{{.State.Health.Status}}'
|
||||
|
||||
# Restart
|
||||
docker restart TradingBot
|
||||
|
||||
# Update
|
||||
docker pull gitea.encke-hake.ts.net/alby96/encelado/tradingbot:latest
|
||||
|
||||
# Remove (mantiene dati)
|
||||
docker rm -f TradingBot
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ?? QUICK START COMPLETO
|
||||
|
||||
**Setup in 3 minuti**:
|
||||
|
||||
```bash
|
||||
# 1. Login (una volta)
|
||||
docker login gitea.encke-hake.ts.net
|
||||
|
||||
# 2. Download template
|
||||
wget -O /boot/config/plugins/dockerMan/templates-user/TradingBot.xml \
|
||||
https://gitea.encke-hake.ts.net/Alby96/Encelado/raw/branch/main/TradingBot/deployment/unraid-template.xml
|
||||
|
||||
# 3. Install via UI
|
||||
# Docker tab ? Add Container ? TradingBot template ? Apply
|
||||
|
||||
# 4. Access
|
||||
# Click WebUI icon or http://192.168.30.23:8080
|
||||
```
|
||||
|
||||
**?? TradingBot pronto su Unraid!**
|
||||
Reference in New Issue
Block a user