Skip to content

Commit f0fdda2

Browse files
Copilotjongalloway
andcommitted
Address PR feedback: improve script robustness, add resource limits, and fix GitHub Actions
Co-authored-by: jongalloway <[email protected]>
1 parent 7eeedbc commit f0fdda2

File tree

3 files changed

+15
-35
lines changed

3 files changed

+15
-35
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,8 @@ jobs:
438438
echo "" >> $GITHUB_STEP_SUMMARY
439439
echo "### Usage" >> $GITHUB_STEP_SUMMARY
440440
echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
441-
echo "docker pull ghcr.io/${{ github.repository }}/demo:latest" >> $GITHUB_STEP_SUMMARY
442-
echo "docker run -p 8080:8080 ghcr.io/${{ github.repository }}/demo:latest" >> $GITHUB_STEP_SUMMARY
441+
echo "docker pull ${{ steps.meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY
442+
echo "docker run -p 8080:8080 ${{ steps.meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY
443443
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
444444
445445
# Alternative: .NET SDK Container Build (modern approach)

deployment/docker/build-docker.sh

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Build script for Docker container in environments with SSL issues
33
# This script prepares a build-ready environment and builds the Docker image
44

5-
set -e
5+
set -euo pipefail
66

77
echo "🔧 Building NLWebNet Docker image with SSL workarounds..."
88

@@ -19,31 +19,11 @@ dotnet restore
1919
# Build the Docker image with appropriate strategy based on environment
2020
echo "🐳 Building Docker image..."
2121

22-
# Try the standard approach first
22+
# Build the Docker image
2323
if docker build -f deployment/docker/Dockerfile . -t nlwebnet-demo:latest; then
24-
echo "✅ Docker build successful with standard approach"
25-
elif [ -f "deployment/docker/Dockerfile.pre-built" ]; then
26-
echo "⚠️ Standard build failed, trying pre-built approach..."
27-
# Use the pre-built approach if available
28-
cp deployment/docker/.dockerignore-prebuilt .dockerignore.backup
29-
mv .dockerignore .dockerignore.original
30-
cp deployment/docker/.dockerignore-prebuilt .dockerignore
31-
32-
if docker build -f deployment/docker/Dockerfile.pre-built . -t nlwebnet-demo:latest; then
33-
echo "✅ Docker build successful with pre-built approach"
34-
else
35-
echo "❌ Both build approaches failed"
36-
# Restore original .dockerignore
37-
mv .dockerignore.original .dockerignore
38-
rm -f .dockerignore.backup
39-
exit 1
40-
fi
41-
42-
# Restore original .dockerignore
43-
mv .dockerignore.original .dockerignore
44-
rm -f .dockerignore.backup
24+
echo "✅ Docker build successful"
4525
else
46-
echo "❌ Docker build failed and no fallback available"
26+
echo "❌ Docker build failed"
4727
exit 1
4828
fi
4929

deployment/docker/smoke-test.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Smoke test script for NLWebNet Docker container
33
# Tests basic functionality and health endpoints
44

5-
set -e
5+
set -euo pipefail
66

77
CONTAINER_NAME="nlwebnet-test-$(date +%s)"
88
CONTAINER_PORT="8080"
@@ -25,7 +25,7 @@ trap cleanup EXIT
2525

2626
# Start the container
2727
echo "🚀 Starting container..."
28-
if ! docker run -d --name "$CONTAINER_NAME" -p "$HOST_PORT:$CONTAINER_PORT" "$IMAGE_NAME"; then
28+
if ! docker run -d --name "$CONTAINER_NAME" -p "$HOST_PORT:$CONTAINER_PORT" --memory=512m --cpus=1 "$IMAGE_NAME"; then
2929
echo "❌ Failed to start container"
3030
exit 1
3131
fi
@@ -57,11 +57,11 @@ sleep 5
5757

5858
# Test basic health endpoint
5959
echo "🔍 Testing health endpoint..."
60-
if curl -f -s "http://localhost:$HOST_PORT/health" >/dev/null; then
60+
if curl --max-time 10 -f -s "http://localhost:$HOST_PORT/health" >/dev/null; then
6161
echo "✅ Health endpoint responds successfully"
6262

6363
# Get and display health response
64-
health_response=$(curl -s "http://localhost:$HOST_PORT/health")
64+
health_response=$(curl --max-time 10 -s "http://localhost:$HOST_PORT/health")
6565
echo "📊 Health response: $health_response"
6666
else
6767
echo "❌ Health endpoint failed"
@@ -72,27 +72,27 @@ fi
7272

7373
# Test if detailed health endpoint exists
7474
echo "🔍 Testing detailed health endpoint..."
75-
if curl -f -s "http://localhost:$HOST_PORT/health/detailed" >/dev/null; then
75+
if curl --max-time 10 -f -s "http://localhost:$HOST_PORT/health/detailed" >/dev/null; then
7676
echo "✅ Detailed health endpoint responds successfully"
77-
detailed_health=$(curl -s "http://localhost:$HOST_PORT/health/detailed")
77+
detailed_health=$(curl --max-time 10 -s "http://localhost:$HOST_PORT/health/detailed")
7878
echo "📊 Detailed health response: $detailed_health"
7979
else
8080
echo "⚠️ Detailed health endpoint not available or failed (this may be expected)"
8181
fi
8282

8383
# Test basic root endpoint
8484
echo "🔍 Testing root endpoint..."
85-
if curl -f -s "http://localhost:$HOST_PORT/" >/dev/null; then
85+
if curl --max-time 10 -f -s "http://localhost:$HOST_PORT/" >/dev/null; then
8686
echo "✅ Root endpoint responds successfully"
8787
else
8888
echo "⚠️ Root endpoint failed (this may be expected for API-only services)"
8989
fi
9090

9191
# Test if NLWebNet API endpoints are available
9292
echo "🔍 Testing NLWebNet API endpoints..."
93-
if curl -f -s "http://localhost:$HOST_PORT/api/nlweb" >/dev/null 2>&1; then
93+
if curl --max-time 10 -f -s "http://localhost:$HOST_PORT/api/nlweb" >/dev/null 2>&1; then
9494
echo "✅ NLWebNet API endpoint responds"
95-
elif curl -f -s "http://localhost:$HOST_PORT/nlweb" >/dev/null 2>&1; then
95+
elif curl --max-time 10 -f -s "http://localhost:$HOST_PORT/nlweb" >/dev/null 2>&1; then
9696
echo "✅ NLWebNet endpoint responds"
9797
else
9898
echo "⚠️ NLWebNet API endpoints may not be available or configured differently"

0 commit comments

Comments
 (0)