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:
2025-12-17 23:15:46 +01:00
parent 5532ad2473
commit cc34d2b57f
11 changed files with 2125 additions and 475 deletions

View File

@@ -0,0 +1,413 @@
# ?? Publishing Guide - TradingBot
Guida completa per pubblicare TradingBot su Gitea Container Registry usando **SOLO** Visual Studio e MSBuild integrato.
---
## ? Setup Prerequisiti (Una Volta)
### 1. Login Gitea Registry
Apri PowerShell/Terminal:
```powershell
docker login gitea.encke-hake.ts.net
# Username: Alby96
# Password: [Personal Access Token Gitea]
```
Output:
```
Login Succeeded ?
```
### 2. Verifica Docker Desktop
Assicurati che Docker Desktop sia in running:
```powershell
docker --version
# Docker version 24.x.x o superiore
```
---
## ?? Publishing Workflow
### Metodo Unico: Visual Studio + MSBuild Automatico
#### Step 1: Seleziona Release Configuration
1. **Build menu** ? **Configuration Manager**
2. **Active solution configuration**: Seleziona **Release**
3. Click **Close**
#### Step 2: Publish con Profilo Docker
1. **Solution Explorer** ? Right-click **TradingBot**
2. Click **Publish...**
3. Seleziona profilo **"Docker"**
4. Click sul pulsante **"Publish"**
#### Step 3: Automatico! ?
Visual Studio esegue automaticamente:
```
1. ? Compila progetto in Release mode
2. ? Build immagine Docker (tradingbot:latest)
3. ? Post-build MSBuild target (AUTOMATICO):
- Verifica condizioni (Release + Docker profile)
- Tag gitea.encke-hake.ts.net/alby96/encelado/tradingbot:latest
- Tag gitea.encke-hake.ts.net/alby96/encelado/tradingbot:1.0.0
- Push entrambi i tag su Gitea Registry
4. ? Mostra conferma nell'Output Window
```
?? **Tempo**: 3-5 minuti (prima volta), 1-2 minuti (successive)
---
## ?? Verifica Output
### Output Window
Durante il publish, monitora l'**Output Window**:
```
View ? Output (Ctrl+Alt+O)
Dropdown: "Build"
```
**Dovresti vedere**:
```
========== Build started ==========
1> Building Docker image...
...
1> Successfully built abc123def456
1> Successfully tagged tradingbot:latest
========================================
?? Gitea Container Registry Push
========================================
??? Tagging images...
? Tagged successfully
?? Pushing to gitea.encke-hake.ts.net...
The push refers to repository [gitea.encke-hake.ts.net/alby96/encelado/tradingbot]
latest: digest: sha256:... size: 1234
========================================
? Successfully pushed to Gitea Registry!
========================================
?? Published images:
- gitea.encke-hake.ts.net/alby96/encelado/tradingbot:latest
- gitea.encke-hake.ts.net/alby96/encelado/tradingbot:1.0.0
?? Verify at:
https://gitea.encke-hake.ts.net/Alby96/Encelado/-/packages
========== Publish: 1 succeeded ==========
```
---
## ?? Verifica su Gitea
Dopo il publish, apri browser:
```
https://gitea.encke-hake.ts.net/Alby96/Encelado/-/packages
```
Dovresti vedere:
```
?? tradingbot
??? latest (280 MB)
? ??? Pushed 2 minutes ago
??? 1.0.0 (280 MB)
??? Pushed 2 minutes ago
```
---
## ?? Aggiornamento Versione
### Incrementa Versione
Modifica `TradingBot.csproj`:
```xml
<PropertyGroup>
<Version>1.0.1</Version> <!-- Incrementa qui -->
<AssemblyVersion>1.0.1.0</AssemblyVersion>
<FileVersion>1.0.1.0</FileVersion>
</PropertyGroup>
```
### Publish Nuova Versione
Esegui di nuovo il workflow di publish. Verranno creati:
- `gitea.encke-hake.ts.net/alby96/encelado/tradingbot:latest` (aggiornato)
- `gitea.encke-hake.ts.net/alby96/encelado/tradingbot:1.0.1` (nuovo)
---
## ?? Come Funziona (Dettagli Tecnici)
### Post-Build MSBuild Target
Il file `TradingBot.csproj` contiene un target MSBuild che si attiva automaticamente:
```xml
<Target Name="PushToGiteaRegistry"
AfterTargets="Publish"
Condition="'$(Configuration)' == 'Release' And
'$(DOTNET_RUNNING_IN_CONTAINER)' != 'true' And
'$(DockerPublish)' == 'true'">
<!-- Tag e push automatici -->
</Target>
```
**Condizioni di attivazione**:
1. ? Configuration = **Release**
2. ? Non siamo dentro un container Docker
3. ? Profilo Docker in uso (`DockerPublish='true'`)
**Cosa fa**:
1. Tag immagine locale `tradingbot:latest`
2. Tag con `gitea.encke-hake.ts.net/alby96/encelado/tradingbot:latest`
3. Tag con `gitea.encke-hake.ts.net/alby96/encelado/tradingbot:{Version}`
4. Push entrambi i tag su Gitea Registry
5. Mostra messaggi nell'Output Window
---
## ?? Troubleshooting
### Errore: "docker: command not found"
**Causa**: Docker non in PATH o non installato
**Fix**:
1. Verifica Docker Desktop sia installato e running
2. Restart Visual Studio
3. Verifica in PowerShell: `docker --version`
### Errore: "unauthorized: authentication required"
**Causa**: Non loggato a Gitea Registry
**Fix**:
```powershell
docker logout gitea.encke-hake.ts.net
docker login gitea.encke-hake.ts.net
# Inserisci credenziali
```
### Errore: "denied: requested access to the resource is denied"
**Causa**: Permessi insufficienti o repository non esiste
**Fix**:
1. Verifica che il repository packages esista su Gitea
2. Verifica che il token abbia scope `write:packages`
3. Verifica username corretto nel `.csproj` (`ContainerRepository`)
### Post-Build Non Si Attiva
**Causa**: Condizioni non soddisfatte
**Fix - Verifica**:
1. ? **Configuration Manager** ? **Release** attivo
2. ? Profilo **"Docker"** selezionato (non altri profili)
3. ? Docker Desktop running
4. ? `docker login` eseguito
**Diagnosi**:
```powershell
# Verifica immagine locale esista dopo publish
docker images | findstr tradingbot
# Dovresti vedere: tradingbot latest ...
```
Se l'immagine locale esiste ma il push non parte:
- Controlla Output Window per messaggi di errore
- Verifica che `DockerPublish='true'` sia nel profilo Docker.pubxml
### Errore: "La ricompilazione non è riuscita"
**Causa**: Errore durante build o post-build
**Fix**:
1. **View** ? **Output** ? Dropdown: **Build**
2. Cerca errori specifici (linea rossa)
3. Se errore docker: verifica Docker Desktop running
4. Se errore MSBuild: verifica sintassi `.csproj`
**Clean & Rebuild**:
```
Build ? Clean Solution
Build ? Rebuild Solution
Build ? Publish (retry)
```
---
## ?? Checklist Publish
### Pre-Publish
- [ ] Docker Desktop running
- [ ] `docker login gitea.encke-hake.ts.net` successful
- [ ] Configuration Manager ? Release
- [ ] Codice committato su Git (opzionale ma consigliato)
### During Publish
- [ ] Visual Studio ? Build ? Publish
- [ ] Profilo "Docker" selezionato
- [ ] Build completa senza errori
- [ ] Output mostra "Successfully pushed to Gitea Registry!"
### Post-Publish
- [ ] Verifica su Gitea Packages
- [ ] Tag `latest` e versione presenti
- [ ] (Opzionale) Deploy su Unraid
---
## ?? Best Practices
### Versioning
Usa [Semantic Versioning](https://semver.org/):
- **MAJOR**: Breaking changes (2.0.0)
- **MINOR**: New features (1.1.0)
- **PATCH**: Bug fixes (1.0.1)
### Git Workflow
```bash
# 1. Sviluppo feature
git checkout -b feature/new-feature
# 2. Commit changes
git add .
git commit -m "feat: Add new feature"
# 3. Merge in main
git checkout main
git merge feature/new-feature
# 4. Tag release
git tag -a v1.0.1 -m "Release 1.0.1"
git push origin main --tags
# 5. Publish Docker image (Visual Studio)
```
### Testing
Prima di ogni publish:
1. Test locale (F5 in Debug)
2. Test in Docker locale (profilo Docker, F5)
3. Verifica funzionalità critiche
4. Publish su Gitea (Release mode)
5. Deploy su Unraid per test finale
---
## ?? Workflow Completo: Dev ? Production
```
1. ?? Sviluppo in Visual Studio
?? F5 per test locale (HTTP profile)
?? F5 con Docker profile per test container
?? Commit su Git
2. ?? Build & Publish
?? Configuration ? Release
?? Build ? Publish (Docker profile)
?? MSBuild automatico: tag & push Gitea ?
3. ?? Verifica Gitea Packages
?? Browser: packages disponibili
4. ?? Deploy su Unraid
?? Docker tab ? Stop
?? Force Update (pull latest)
?? Start
5. ? Test in Production
?? http://192.168.30.23:8080
```
**Tempo totale**: ~10 minuti (compresi test)
---
## ?? Risorse
### File di Configurazione
- **`TradingBot.csproj`**: Contiene il post-build target `PushToGiteaRegistry`
- **`Properties/PublishProfiles/Docker.pubxml`**: Profilo publish Docker
- **`Dockerfile`**: Multi-stage build configuration
### Links Utili
- [MSBuild Targets](https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-targets)
- [Docker CLI Reference](https://docs.docker.com/engine/reference/commandline/cli/)
- [Gitea Packages](https://docs.gitea.com/usage/packages/container)
---
## ?? Tips & Tricks
### Debug Post-Build Target
Per vedere cosa sta facendo il post-build:
1. **Output Window** ? Dropdown: **Build**
2. Cerca sezione:
```
========================================
?? Gitea Container Registry Push
========================================
```
### Build Solo Docker (Senza Push)
Se vuoi solo buildare l'immagine senza push:
**Opzione 1**: Usa Debug mode
```
Configuration Manager ? Debug
Build ? Publish (Docker)
# Post-build NON si attiva (serve Release)
```
**Opzione 2**: Build manuale
```powershell
docker build -t tradingbot:latest .
# Crea solo immagine locale
```
### Push Manuale (Se Serve)
Se hai già l'immagine locale e vuoi solo push:
```powershell
docker tag tradingbot:latest gitea.encke-hake.ts.net/alby96/encelado/tradingbot:latest
docker push gitea.encke-hake.ts.net/alby96/encelado/tradingbot:latest
```
---
**?? Publish integrato completamente in Visual Studio!**
**Zero script esterni, tutto automatico con MSBuild!** ?

View File

@@ -0,0 +1,168 @@
# ?? Deployment Resources
Questa cartella contiene tutti i file e le guide necessarie per il deployment di TradingBot.
---
## ?? Contenuto
### ?? Guide
- **[PUBLISHING_GUIDE.md](PUBLISHING_GUIDE.md)** - Guida completa per pubblicare su Gitea Registry da Visual Studio
- **[UNRAID_INSTALL.md](UNRAID_INSTALL.md)** - Installazione nativa su Unraid senza Portainer
### ?? Docker Files
- **[docker-compose.yml](docker-compose.yml)** - Configurazione Docker Compose per deploy rapido
- **[unraid-template.xml](unraid-template.xml)** - Template XML per installazione 1-click su Unraid
### ?? Dockerfile
Il `Dockerfile` principale si trova nella **root del progetto** per compatibilità con Visual Studio Container Tools.
---
## ?? Quick Start
### Publish da Visual Studio
```
1. Build ? Configuration Manager ? Release
2. Build ? Publish TradingBot
3. Seleziona profilo "Docker"
4. Click "Publish"
5. ? Automatico: Build + Push su Gitea Registry
```
**Guida dettagliata**: [PUBLISHING_GUIDE.md](PUBLISHING_GUIDE.md)
### Deploy su Unraid
```bash
# 1. Login Gitea Registry
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 Docker tab
```
**Guida dettagliata**: [UNRAID_INSTALL.md](UNRAID_INSTALL.md)
### Deploy con Docker Compose
```bash
# Clone repository
git clone https://gitea.encke-hake.ts.net/Alby96/Encelado
cd Encelado/TradingBot/deployment
# Deploy
docker-compose up -d
# Accedi: http://localhost:8080
```
---
## ?? Workflow Consigliato
```
Sviluppo (PC) Publish Deploy (Unraid)
????????????? ??????? ???????????????
Visual Studio ? Gitea Registry ? Unraid Docker
- Codice - Container - Pull image
- Test F5 - Versioning - Start
- Commit - Latest + v1.0.0 - WebUI ready
```
---
## ?? Gestione Versioni
### File di Configurazione
La versione è definita in `TradingBot.csproj`:
```xml
<PropertyGroup>
<Version>1.0.0</Version>
</PropertyGroup>
```
### Tag Generati Automaticamente
Ogni publish crea 2 tag:
- `latest` - Sempre ultima versione
- `1.0.0` - Versione specifica
### Rollback
Per tornare a una versione precedente:
```bash
# Su Unraid
docker pull gitea.encke-hake.ts.net/alby96/encelado/tradingbot:1.0.0
docker stop TradingBot
docker rm TradingBot
# Ricrea container con versione specifica
```
---
## ?? Registry Access
### Gitea Container Registry
- **URL**: `gitea.encke-hake.ts.net`
- **Repository**: `alby96/encelado/tradingbot`
- **Auth**: Personal Access Token con scope `write:packages`
### Login
```bash
docker login gitea.encke-hake.ts.net
# Username: Alby96
# Password: [token]
```
---
## ?? Risorse Aggiuntive
### Documentation
- [Dockerfile](../Dockerfile) - Multi-stage build configuration
- [README.md](../README.md) - Documentazione principale progetto
- [.dockerignore](../.dockerignore) - File esclusi dal build context
### Repository
- **Git**: `https://gitea.encke-hake.ts.net/Alby96/Encelado`
- **Packages**: `https://gitea.encke-hake.ts.net/Alby96/Encelado/-/packages`
- **Issues**: `https://gitea.encke-hake.ts.net/Alby96/Encelado/issues`
---
## ? Checklist Deployment
### Setup Iniziale
- [ ] Docker Desktop installato e running
- [ ] Login Gitea Registry successful
- [ ] Unraid Docker service attivo (se deploy su Unraid)
### Ogni Deploy
- [ ] Codice committato su Git
- [ ] Versione incrementata (se necessario)
- [ ] Publish da Visual Studio successful
- [ ] Verifica packages su Gitea
- [ ] Pull & deploy su target environment
- [ ] Test funzionalità in production
---
**?? Deployment semplificato e automatizzato!**
**No script esterni, tutto integrato in Visual Studio e MSBuild!** ?

View 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!**

View File

@@ -0,0 +1,38 @@
version: '3.8'
services:
tradingbot:
container_name: tradingbot
image: gitea.encke-hake.ts.net/alby96/encelado/tradingbot:latest
ports:
- "${EXTERNAL_PORT:-8080}:8080"
volumes:
- tradingbot-data:/app/data
environment:
- ASPNETCORE_ENVIRONMENT=Production
- ASPNETCORE_URLS=http://+:8080
restart: unless-stopped
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8080/health"]
interval: 30s
timeout: 3s
retries: 3
start_period: 10s
networks:
- tradingbot-network
deploy:
resources:
limits:
cpus: '2.0'
memory: 1G
reservations:
cpus: '0.5'
memory: 256M
volumes:
tradingbot-data:
driver: local
networks:
tradingbot-network:
driver: bridge

View File

@@ -0,0 +1,38 @@
<?xml version="1.0"?>
<Container version="2">
<Name>TradingBot</Name>
<Repository>gitea.encke-hake.ts.net/alby96/encelado/tradingbot:latest</Repository>
<Registry>https://gitea.encke-hake.ts.net</Registry>
<Network>bridge</Network>
<MyIP/>
<Shell>sh</Shell>
<Privileged>false</Privileged>
<Support>https://gitea.encke-hake.ts.net/Alby96/Encelado</Support>
<Project>https://gitea.encke-hake.ts.net/Alby96/Encelado</Project>
<Overview>Automated Crypto Trading Bot con Blazor UI. Analisi tecnica, simulazione trading e gestione portfolio automatizzata.</Overview>
<Category>Tools:Productivity Status:Stable</Category>
<WebUI>http://[IP]:[PORT:8080]/</WebUI>
<TemplateURL>https://gitea.encke-hake.ts.net/Alby96/Encelado/raw/branch/main/TradingBot/deployment/unraid-template.xml</TemplateURL>
<Icon>https://raw.githubusercontent.com/walkxcode/dashboard-icons/main/png/dotnet.png</Icon>
<ExtraParams>--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</ExtraParams>
<PostArgs/>
<CPUset/>
<DateInstalled/>
<DonateText>Se trovi utile questo progetto, considera di supportare lo sviluppo!</DonateText>
<DonateLink/>
<DonateImg/>
<Requires/>
<!-- Port Configuration -->
<Config Name="WebUI Port" Target="8080" Default="8080" Mode="tcp" Description="Porta HTTP per accedere alla WebUI (default: 8080)" Type="Port" Display="always-hide" Required="true" Mask="false">8080</Config>
<!-- Volume Configuration -->
<Config Name="AppData" Target="/app/data" Default="/mnt/user/appdata/tradingbot" Mode="rw" Description="Directory per persistenza dati (settings, trade history, logs)" Type="Path" Display="always-hide" Required="true" Mask="false">/mnt/user/appdata/tradingbot</Config>
<!-- Environment Variables -->
<Config Name="ASPNETCORE_ENVIRONMENT" Target="ASPNETCORE_ENVIRONMENT" Default="Production" Mode="" Description="Ambiente di esecuzione ASP.NET Core" Type="Variable" Display="advanced-hide" Required="true" Mask="false">Production</Config>
<Config Name="ASPNETCORE_URLS" Target="ASPNETCORE_URLS" Default="http://+:8080" Mode="" Description="URL di binding interno (deve matchare la porta container)" Type="Variable" Display="advanced-hide" Required="true" Mask="false">http://+:8080</Config>
<Config Name="TZ" Target="TZ" Default="Europe/Rome" Mode="" Description="Timezone per log e timestamp" Type="Variable" Display="advanced-hide" Required="false" Mask="false">Europe/Rome</Config>
</Container>