diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index de4d4c5..7783fdf 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -2,9 +2,9 @@ name: .NET on: push: - branches: [ master ] + branches: [ main ] pull_request: - branches: [ master ] + branches: [ main ] jobs: build: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index da85bfa..c9199ed 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -42,12 +42,14 @@ jobs: STAGE_DIR="spyder-tally-${{ matrix.rid }}" mkdir -p "$STAGE_DIR/bin" - # Copy published binary + # Copy published binary and static web assets cp publish/${{ matrix.rid }}/SpyderTallyControllerWebApp "$STAGE_DIR/bin/" + if [ -d "publish/${{ matrix.rid }}/wwwroot" ]; then + cp -r publish/${{ matrix.rid }}/wwwroot "$STAGE_DIR/bin/" + fi # Copy config and support files cp docs/sd_card/install.sh "$STAGE_DIR/" - cp docs/sd_card/nginx.conf "$STAGE_DIR/" cp docs/sd_card/SpyderTallies.service "$STAGE_DIR/" cp docs/sd_card/appConfig.json "$STAGE_DIR/" cp docs/sd_card/deviceConfig.json "$STAGE_DIR/" diff --git a/docs/sd_card/SpyderTallies.service b/docs/sd_card/SpyderTallies.service index 7a5756f..5c5e02d 100644 --- a/docs/sd_card/SpyderTallies.service +++ b/docs/sd_card/SpyderTallies.service @@ -12,6 +12,12 @@ SyslogIdentifier=SpyderTallies # The install script will replace __USER__ with the installing user User=__USER__ +# Allow binding to port 80 without running as root +AmbientCapabilities=CAP_NET_BIND_SERVICE + +# Listen on port 80 directly (no reverse proxy needed) +Environment=ASPNETCORE_URLS=http://+:80 + # ensure the service restarts after crashing Restart=always # amount of time to wait before restarting the service diff --git a/docs/sd_card/install.sh b/docs/sd_card/install.sh index 291e660..b7b7e51 100644 --- a/docs/sd_card/install.sh +++ b/docs/sd_card/install.sh @@ -69,12 +69,6 @@ if systemctl is-active --quiet "$SERVICE_NAME" 2>/dev/null; then systemctl stop "$SERVICE_NAME" fi -# --- Install nginx --- - -echo "Installing nginx..." -apt-get update -qq -apt-get install -y -qq nginx > /dev/null - # --- Enable I2C --- echo "Enabling I2C interface..." @@ -94,6 +88,12 @@ mkdir -p "$INSTALL_DIR" cp "$SCRIPT_DIR/bin/SpyderTallyControllerWebApp" "$INSTALL_DIR/" chmod +x "$INSTALL_DIR/SpyderTallyControllerWebApp" +# Copy static web assets (CSS, JS, images, etc.) +if [ -d "$SCRIPT_DIR/bin/wwwroot" ]; then + cp -r "$SCRIPT_DIR/bin/wwwroot" "$INSTALL_DIR/" + echo " Installed static web assets" +fi + # Copy default config files (only if they don't already exist, to preserve user settings on upgrade) for config_file in appConfig.json deviceConfig.json; do if [ ! -f "$INSTALL_DIR/$config_file" ]; then @@ -107,14 +107,6 @@ done # Set ownership so the service user can write config files chown -R "$INSTALL_USER":"$INSTALL_USER" "$INSTALL_DIR" -# --- Install nginx config --- - -echo "Installing nginx configuration..." -cp "$SCRIPT_DIR/nginx.conf" /etc/nginx/nginx.conf -nginx -t -q -systemctl restart nginx -systemctl enable nginx - # --- Install systemd service --- echo "Installing systemd service..." diff --git a/docs/sd_card/nginx.conf b/docs/sd_card/nginx.conf deleted file mode 100644 index 4f8839e..0000000 --- a/docs/sd_card/nginx.conf +++ /dev/null @@ -1,44 +0,0 @@ -user www-data; -worker_processes auto; -pid /run/nginx.pid; -include /etc/nginx/modules-enabled/*.conf; - -events { - worker_connections 768; -} - -http { - # Basic Settings - sendfile on; - tcp_nopush on; - types_hash_max_size 2048; - - include /etc/nginx/mime.types; - default_type application/octet-stream; - - # SSL Settings - ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE - ssl_prefer_server_ciphers on; - - # Gzip Settings - gzip on; - - # WebSocket support (required for SignalR) - map $http_upgrade $connection_upgrade { - default upgrade; - '' close; - } - - server { - listen 80 default_server; - location / { - proxy_pass http://127.0.0.1:5000; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-Proto $scheme; - proxy_set_header Host $host; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection $connection_upgrade; - } - } -} diff --git a/src/SpyderTallyControllerWebApp/Program.cs b/src/SpyderTallyControllerWebApp/Program.cs index 8518489..8139b87 100644 --- a/src/SpyderTallyControllerWebApp/Program.cs +++ b/src/SpyderTallyControllerWebApp/Program.cs @@ -8,8 +8,11 @@ var builder = WebApplication.CreateBuilder(args); -//Allow access on outside adapters -builder.WebHost.UseUrls("http://*:5000"); +// Use ASPNETCORE_URLS if set (e.g. http://+:80 in production), otherwise default to port 5000 for development +if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPNETCORE_URLS"))) +{ + builder.WebHost.UseUrls("http://*:5000"); +} builder.Services.AddSingleton(serverEventListener); builder.Services.AddSingleton();