fix: Ensure static web content is properly deployed and served
- Added UseDefaultFiles middleware to serve index.html by default - Explicitly copy wwwroot contents during installation - Added checks in test script to verify static content - Added fallback to /index.html endpoint if root path doesn't respond - Enhanced test script to diagnose and fix common deployment issues 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
573031fcc9
commit
5d6faef880
@ -150,9 +150,16 @@ echo "Building project from: $PROJECT_DIR"
|
|||||||
cd "$PROJECT_DIR"
|
cd "$PROJECT_DIR"
|
||||||
dotnet restore
|
dotnet restore
|
||||||
dotnet build -c Release
|
dotnet build -c Release
|
||||||
# Publish as framework-dependent, not self-contained
|
# Publish as framework-dependent, not self-contained, ensuring static content is included
|
||||||
dotnet publish -c Release -o $INSTALL_DIR/publish --no-self-contained -f net7.0 -p:PublishSingleFile=false
|
dotnet publish -c Release -o $INSTALL_DIR/publish --no-self-contained -f net7.0 -p:PublishSingleFile=false
|
||||||
|
|
||||||
|
# Ensure the wwwroot folder is properly copied
|
||||||
|
echo "Copying static web content..."
|
||||||
|
if [ -d "$PROJECT_DIR/src/Web/wwwroot" ]; then
|
||||||
|
mkdir -p "$INSTALL_DIR/publish/wwwroot"
|
||||||
|
cp -r "$PROJECT_DIR/src/Web/wwwroot/"* "$INSTALL_DIR/publish/wwwroot/"
|
||||||
|
fi
|
||||||
|
|
||||||
# Copy configuration
|
# Copy configuration
|
||||||
cp "$CONFIG_DIR/appsettings.json" "$INSTALL_DIR/publish/appsettings.json"
|
cp "$CONFIG_DIR/appsettings.json" "$INSTALL_DIR/publish/appsettings.json"
|
||||||
|
|
||||||
|
@ -43,6 +43,8 @@ if (app.Environment.IsDevelopment())
|
|||||||
app.UseSwaggerUI();
|
app.UseSwaggerUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Configure static files to serve index.html as the default file
|
||||||
|
app.UseDefaultFiles();
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
app.UseRouting();
|
app.UseRouting();
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
@ -77,6 +77,37 @@ fi
|
|||||||
|
|
||||||
echo -e "${GREEN}✓${NC} Runtime configuration file found"
|
echo -e "${GREEN}✓${NC} Runtime configuration file found"
|
||||||
|
|
||||||
|
# Check for static web content
|
||||||
|
if [ ! -d "$PUBLISH_DIR/wwwroot" ]; then
|
||||||
|
echo -e "${RED}ERROR: wwwroot directory not found. Static content is missing!${NC}"
|
||||||
|
echo -e "${YELLOW}Creating wwwroot directory and copying static content...${NC}"
|
||||||
|
|
||||||
|
# Try to find the wwwroot directory in the source
|
||||||
|
WWWROOT_SOURCE=$(find $INSTALL_DIR -path "*/Web/wwwroot" -type d 2>/dev/null | head -n 1)
|
||||||
|
|
||||||
|
if [ -n "$WWWROOT_SOURCE" ]; then
|
||||||
|
# Found the static content, copy it
|
||||||
|
mkdir -p "$PUBLISH_DIR/wwwroot"
|
||||||
|
cp -r "$WWWROOT_SOURCE/"* "$PUBLISH_DIR/wwwroot/"
|
||||||
|
echo -e "${GREEN}✓${NC} Static content copied from $WWWROOT_SOURCE"
|
||||||
|
|
||||||
|
# Restart the service to apply changes
|
||||||
|
systemctl restart transmission-rss-manager
|
||||||
|
echo -e "${YELLOW}Service restarted. Please try accessing the web interface again.${NC}"
|
||||||
|
else
|
||||||
|
echo -e "${RED}Could not find source wwwroot directory to copy static content from.${NC}"
|
||||||
|
echo -e "${YELLOW}Please copy static content manually to $PUBLISH_DIR/wwwroot${NC}"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# Check if index.html exists
|
||||||
|
if [ ! -f "$PUBLISH_DIR/wwwroot/index.html" ]; then
|
||||||
|
echo -e "${RED}ERROR: index.html not found in wwwroot directory!${NC}"
|
||||||
|
ls -la "$PUBLISH_DIR/wwwroot"
|
||||||
|
else
|
||||||
|
echo -e "${GREEN}✓${NC} Static content found (wwwroot/index.html exists)"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Check web service response
|
# Check web service response
|
||||||
echo -e "${YELLOW}Checking web service (this may take a few seconds)...${NC}"
|
echo -e "${YELLOW}Checking web service (this may take a few seconds)...${NC}"
|
||||||
for i in {1..15}; do
|
for i in {1..15}; do
|
||||||
@ -86,6 +117,19 @@ for i in {1..15}; do
|
|||||||
WEB_OK=true
|
WEB_OK=true
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# If root URL doesn't work, try direct access to index.html
|
||||||
|
if [ "$i" -eq 5 ]; then
|
||||||
|
echo -e "${YELLOW}Root path not responding, trying explicit index.html...${NC}"
|
||||||
|
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:5000/index.html 2>/dev/null || echo "000")
|
||||||
|
if [ "$HTTP_STATUS" = "200" ] || [ "$HTTP_STATUS" = "302" ]; then
|
||||||
|
echo -e "${GREEN}✓${NC} Web service is responsive at /index.html (HTTP $HTTP_STATUS)"
|
||||||
|
echo -e "${YELLOW}Access the app at http://localhost:5000/index.html${NC}"
|
||||||
|
WEB_OK=true
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user