Compare commits

...

2 Commits

Author SHA1 Message Date
d933c7e812 Semplifica configurazione Docker e gestione porta UI
Riorganizza .env.example lasciando solo EXTERNAL_PORT e spostando tutte le altre impostazioni applicative nella UI web. Il mapping della porta in docker-compose.yml ora usa la variabile EXTERNAL_PORT per una personalizzazione più semplice. Rimosse variabili e opzioni avanzate non essenziali dal compose. Aggiornata la documentazione per riflettere la nuova gestione centralizzata delle impostazioni tramite interfaccia web.
2025-12-15 11:38:36 +01:00
f69d5dd567 Configura Kestrel e accesso browser per Docker/Unraid
- Kestrel ora ascolta su 0.0.0.0:8080 per compatibilità Docker
- HTTPS redirect attivo solo in sviluppo, disabilitato in prod
- Aggiunta sezione "Kestrel" in appsettings.json e nuovo appsettings.Production.json con limiti di sicurezza
- Healthcheck Docker ora usa wget su /health (porta 8080)
- Aggiunta documentazione dettagliata in BROWSER_ACCESS_CONFIG.md
- Migliorata accessibilità browser, supporto reverse proxy e SignalR
2025-12-15 11:32:26 +01:00
5 changed files with 77 additions and 110 deletions

View File

@@ -1,107 +1,44 @@
# TradingBot - Environment Variables Example # TradingBot - Docker Environment Variables
# Copia questo file come .env e personalizza i valori # Copia questo file come .env per personalizzare la configurazione Docker
# ============================================== # ==============================================
# DOCKER CONFIGURATION # DOCKER CONFIGURATION
# ============================================== # ==============================================
# Timezone (importante per trading!) # Porta esterna per accesso WebUI
TZ=Europe/Rome # Modifica se la porta 8080 è già in uso sul tuo sistema
# Default: 8080
# ASP.NET Core Environment
ASPNETCORE_ENVIRONMENT=Production
# Logging Level
# Options: Trace, Debug, Information, Warning, Error, Critical
Logging__LogLevel__Default=Information
# ==============================================
# APPLICATION SETTINGS
# ==============================================
# Modalità Simulazione (true = dati simulati, false = dati reali)
TRADINGBOT__SimulationMode=true
# Auto-start bot all'avvio
TRADINGBOT__AutoStartBot=true
# Intervallo aggiornamento dati (secondi)
# Min: 2, Max: 10, Consigliato: 3
TRADINGBOT__UpdateIntervalSeconds=3
# Notifiche Desktop (true/false)
TRADINGBOT__DesktopNotifications=false
# Conferma operazioni manuali (true/false)
TRADINGBOT__ConfirmManualTrades=false
# Log Level applicazione
# Options: Error, Warning, Info, Debug
TRADINGBOT__LogLevel=Info
# ==============================================
# DOCKER COMPOSE OVERRIDES
# ==============================================
# Porta esterna (modifica se 8080 è già in uso)
EXTERNAL_PORT=8080 EXTERNAL_PORT=8080
# Resource Limits
MEMORY_LIMIT=1G
MEMORY_RESERVATION=256M
CPU_LIMIT=2.0
CPU_RESERVATION=0.5
# ============================================== # ==============================================
# REGISTRY (opzionale - per push immagini) # NOTE IMPORTANTI
# ==============================================
# Docker Registry URL (lascia vuoto se non usi registry privato)
DOCKER_REGISTRY=
# Registry username
REGISTRY_USER=
# Registry password (usa Docker secrets in produzione!)
REGISTRY_PASSWORD=
# ==============================================
# BACKUP (opzionale)
# ==============================================
# Directory backup su host
BACKUP_DIR=/mnt/user/backups/tradingbot
# Retention giorni backup
BACKUP_RETENTION_DAYS=7
# ==============================================
# MONITORING (opzionale)
# ==============================================
# Prometheus metrics endpoint (true/false)
ENABLE_METRICS=false
# Health check interval (seconds)
HEALTHCHECK_INTERVAL=30
# ==============================================
# ADVANCED
# ==============================================
# HTTPS Redirection (true/false)
# Disabilita se usi reverse proxy
ASPNETCORE_HTTPS_PORT=
# Kestrel limits
KESTREL_LIMITS_MAXREQUESTBODYSIZE=10485760
# ==============================================
# NOTES
# ============================================== # ==============================================
# #
# 1. Non committare questo file con credenziali reali! # ?? TUTTE LE ALTRE CONFIGURAZIONI DELL'APPLICAZIONE
# 2. Aggiungi .env al .gitignore # SONO GESTIBILI DALL'INTERFACCIA WEB:
# 3. Usa Docker secrets per password in produzione #
# 4. Restart container dopo modifiche: docker-compose restart # - Fuso orario (Timezone)
# - Auto-start del bot
# - Intervallo aggiornamento dati
# - Modalità simulazione
# - Notifiche
# - Log level
# - E tutte le altre impostazioni
#
# Accedi all'interfaccia web su:
# http://localhost:8080 (o la porta configurata)
#
# Vai su ?? Impostazioni per configurare l'applicazione.
#
# Le impostazioni sono salvate automaticamente nel volume Docker
# e persistono tra i restart del container.
#
# ==============================================
# EXAMPLES
# ==============================================
#
# Se la porta 8080 è occupata, usa un'altra:
# EXTERNAL_PORT=8081
#
# Poi accedi su: http://localhost:8081
# #

View File

@@ -3,6 +3,13 @@ using TradingBot.Services;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
// Configure Kestrel per Docker - Listen su tutte le interfacce
builder.WebHost.ConfigureKestrel(serverOptions =>
{
// Listen su porta 8080 per Docker
serverOptions.ListenAnyIP(8080);
});
// Add services to the container. // Add services to the container.
builder.Services.AddRazorComponents() builder.Services.AddRazorComponents()
.AddInteractiveServerComponents(); .AddInteractiveServerComponents();
@@ -26,7 +33,12 @@ if (!app.Environment.IsDevelopment())
app.UseHsts(); app.UseHsts();
} }
// Disabilita HTTPS redirect in Docker/Production
// Docker gestisce HTTPS tramite reverse proxy se necessario
if (app.Environment.IsDevelopment())
{
app.UseHttpsRedirection(); app.UseHttpsRedirection();
}
app.UseStaticFiles(); app.UseStaticFiles();
app.UseAntiforgery(); app.UseAntiforgery();

View File

@@ -0,0 +1,20 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"Kestrel": {
"Endpoints": {
"Http": {
"Url": "http://0.0.0.0:8080"
}
},
"Limits": {
"MaxRequestBodySize": 10485760
}
}
}

View File

@@ -5,5 +5,12 @@
"Microsoft.AspNetCore": "Warning" "Microsoft.AspNetCore": "Warning"
} }
}, },
"AllowedHosts": "*" "AllowedHosts": "*",
"Kestrel": {
"Endpoints": {
"Http": {
"Url": "http://0.0.0.0:8080"
}
}
}
} }

View File

@@ -8,32 +8,23 @@ services:
context: . context: .
dockerfile: Dockerfile dockerfile: Dockerfile
ports: ports:
- "8080:8080" - "${EXTERNAL_PORT:-8080}:8080"
volumes: volumes:
# Persistenza dati applicazione # Persistenza dati applicazione
- tradingbot-data:/app/data - tradingbot-data:/app/data
# Opzionale: mount locale per sviluppo
# - ./logs:/app/logs
environment: environment:
# Configurazioni applicazione # Configurazioni base (non modificabili)
- ASPNETCORE_ENVIRONMENT=Production - ASPNETCORE_ENVIRONMENT=Production
- ASPNETCORE_URLS=http://+:8080 - ASPNETCORE_URLS=http://+:8080
# Fuso orario (importante per trading!)
- TZ=Europe/Rome
# Opzionali - Configurazioni avanzate
# - TRADINGBOT__SimulationMode=true
# - TRADINGBOT__AutoStartBot=true
# - TRADINGBOT__UpdateIntervalSeconds=3
restart: unless-stopped restart: unless-stopped
healthcheck: healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health"] test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8080/health"]
interval: 30s interval: 30s
timeout: 3s timeout: 3s
retries: 3 retries: 3
start_period: 10s start_period: 10s
networks: networks:
- tradingbot-network - tradingbot-network
# Resource limits (opzionali ma consigliati per Unraid)
deploy: deploy:
resources: resources:
limits: limits: