Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Docker ignore file for NLWebNet
# Optimizes Docker build context by excluding unnecessary files

# Git
.git
.gitignore
.gitattributes

# GitHub workflows and metadata
.github/
copilot-setup-steps.yml

# IDE and editor files
.vs/
.vscode/
*.user
*.suo
*.userosscache
*.sln.docstates
.idea/

# Build outputs
**/bin/
**/obj/
**/out/
**/.vs/

# Test results
TestResults/
test-results*.xml
coverage*.xml
*.coverage
*.coveragexml

# NuGet
packages/
*.nupkg
*.snupkg
**/packages/*
!**/packages/build/

# Runtime logs
logs/
*.log

# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# Temporary files
tmp/
temp/
*.tmp
*.temp

# Documentation (not needed in container)
README.md
doc/
*.md

# Scripts (not needed in runtime)
scripts/

# License files
LICENSE*
COPYING*

# Docker files (avoid recursion)
Dockerfile*
docker-compose*
.dockerignore

# Environment specific files (use volume mounts instead)
appsettings.*.json
!appsettings.json
*.env
.env*
40 changes: 40 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,43 @@ jobs:
tag_name: ${{ github.ref_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

docker-build:
runs-on: ubuntu-latest
needs: [check-changes, build]
if: needs.check-changes.outputs.should-skip != 'true' && (github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')))

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build Docker image (test build)
run: |
echo "๐Ÿณ Building Docker image for testing..."
docker build -t nlwebnet-demo:test .
echo "โœ… Docker build successful"

- name: Test Docker image
run: |
echo "๐Ÿงช Testing Docker image..."
# Start container in background
docker run -d --name nlwebnet-test -p 8080:8080 nlwebnet-demo:test

# Wait for container to start
sleep 10

# Test health endpoint
if curl -f http://localhost:8080/health; then
echo "โœ… Health check passed"
else
echo "โŒ Health check failed"
Comment on lines +294 to +301
Copy link

Copilot AI Jun 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider increasing the sleep duration before testing the health endpoint to accommodate slower container startup times in some environments.

Suggested change
# Wait for container to start
sleep 10
# Test health endpoint
if curl -f http://localhost:8080/health; then
echo "โœ… Health check passed"
else
echo "โŒ Health check failed"
# Wait for container to start dynamically
echo "โณ Waiting for container to become ready..."
for i in {1..30}; do
if curl -f http://localhost:8080/health; then
echo "โœ… Health check passed"
break
else
echo "โณ Health check attempt $i failed, retrying in 2 seconds..."
sleep 2
fi
done
# Verify health check success
if ! curl -f http://localhost:8080/health; then
echo "โŒ Health check failed after multiple attempts"

Copilot uses AI. Check for mistakes.
docker logs nlwebnet-test
exit 1
fi

# Cleanup
docker stop nlwebnet-test
docker rm nlwebnet-test
60 changes: 60 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Multi-stage Dockerfile for NLWebNet Demo Application
# Based on .NET 9 runtime and optimized for production deployment

# Build stage
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
WORKDIR /src

# Copy solution file and project files for dependency resolution
COPY ["NLWebNet.sln", "./"]
COPY ["src/NLWebNet/NLWebNet.csproj", "src/NLWebNet/"]
COPY ["samples/Demo/NLWebNet.Demo.csproj", "samples/Demo/"]
COPY ["samples/AspireHost/NLWebNet.AspireHost.csproj", "samples/AspireHost/"]
COPY ["tests/NLWebNet.Tests/NLWebNet.Tests.csproj", "tests/NLWebNet.Tests/"]

# Restore dependencies
RUN dotnet restore "samples/Demo/NLWebNet.Demo.csproj"

# Copy source code
COPY . .

# Build the demo application
WORKDIR "/src/samples/Demo"
RUN dotnet build "NLWebNet.Demo.csproj" -c Release -o /app/build

# Publish stage
FROM build AS publish
RUN dotnet publish "NLWebNet.Demo.csproj" -c Release -o /app/publish /p:UseAppHost=false

# Runtime stage
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS final

# Create a non-root user for security
RUN groupadd -r nlwebnet && useradd -r -g nlwebnet nlwebnet

# Set working directory
WORKDIR /app

# Copy published application
COPY --from=publish /app/publish .

# Create directory for logs and ensure proper permissions
RUN mkdir -p /app/logs && chown -R nlwebnet:nlwebnet /app

# Switch to non-root user
USER nlwebnet

# Configure ASP.NET Core
ENV ASPNETCORE_ENVIRONMENT=Production
ENV ASPNETCORE_URLS=http://+:8080
ENV ASPNETCORE_HTTP_PORTS=8080

# Expose port
EXPOSE 8080

# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8080/health || exit 1

# Entry point
ENTRYPOINT ["dotnet", "NLWebNet.Demo.dll"]
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,41 @@ builder.Services.Configure<AzureSearchOptions>(
builder.Configuration.GetSection("AzureSearch"));
```

## ๐Ÿš€ Deployment

NLWebNet supports multiple deployment options for different environments:

### ๐Ÿณ Docker Deployment
```bash
# Quick start with Docker Compose
git clone https://github.com/jongalloway/NLWebNet.git
cd NLWebNet
docker-compose up --build
```

### โ˜๏ธ Azure Cloud Deployment
```bash
# Deploy to Azure Container Apps
./scripts/deploy/deploy-azure.sh -g myResourceGroup -t container-apps

# Deploy to Azure App Service
./scripts/deploy/deploy-azure.sh -g myResourceGroup -t app-service
```

### โš™๏ธ Kubernetes Deployment
```bash
# Deploy to any Kubernetes cluster
kubectl apply -f k8s/
```

### ๐Ÿ“ฆ Container Registry
Pre-built images available soon. For now, build locally:
```bash
./scripts/deploy/build-docker.sh -t latest
```

๐Ÿ“– **[Complete Deployment Guide](doc/deployment/README.md)** - Comprehensive instructions for all deployment scenarios.

## ๐Ÿ› ๏ธ Development Status

This is a **proof of concept implementation** of the NLWeb protocol, available as an **alpha prerelease package** for testing and evaluation purposes only.
Expand Down
Loading