-
Notifications
You must be signed in to change notification settings - Fork 2
Docker build stabilization with comprehensive SSL handling and multi-environment support #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Copilot
wants to merge
5
commits into
main
Choose a base branch
from
copilot/fix-78
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c0e2086
Initial plan
Copilot cdff5e5
Add Docker build improvements and SSL certificate handling
Copilot 7eeedbc
Complete Docker build stabilization with GHCR publishing and smoke tests
Copilot f0fdda2
Address PR feedback: improve script robustness, add resource limits, …
Copilot 00ba297
Improve Docker SSL handling and provide comprehensive deployment solu…
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -352,6 +352,25 @@ jobs: | |||||||||
- name: Set up Docker Buildx | ||||||||||
uses: docker/setup-buildx-action@v3 | ||||||||||
|
||||||||||
- name: Log in to GitHub Container Registry | ||||||||||
uses: docker/login-action@v3 | ||||||||||
with: | ||||||||||
registry: ghcr.io | ||||||||||
username: ${{ github.actor }} | ||||||||||
password: ${{ secrets.GITHUB_TOKEN }} | ||||||||||
|
||||||||||
- name: Extract metadata for Docker | ||||||||||
id: meta | ||||||||||
uses: docker/metadata-action@v5 | ||||||||||
with: | ||||||||||
images: ghcr.io/${{ github.repository }}/demo | ||||||||||
tags: | | ||||||||||
type=ref,event=branch | ||||||||||
type=ref,event=pr | ||||||||||
type=semver,pattern={{version}} | ||||||||||
type=semver,pattern={{major}}.{{minor}} | ||||||||||
type=raw,value=latest,enable={{is_default_branch}} | ||||||||||
|
||||||||||
- name: Build Docker image (test build) | ||||||||||
run: | | ||||||||||
echo "🐳 Building Docker image for testing..." | ||||||||||
|
@@ -365,14 +384,29 @@ jobs: | |||||||||
docker run -d --name nlwebnet-test -p 8080:8080 nlwebnet-demo:test | ||||||||||
|
||||||||||
# Wait for container to start | ||||||||||
sleep 5 | ||||||||||
sleep 10 | ||||||||||
|
||||||||||
# Check if container is running (basic test) | ||||||||||
if docker ps | grep nlwebnet-test; then | ||||||||||
echo "✅ Container is running" | ||||||||||
|
||||||||||
# Test health endpoint if available | ||||||||||
echo "🔍 Testing health endpoint..." | ||||||||||
for i in {1..5}; do | ||||||||||
if curl -f -s http://localhost:8080/health >/dev/null 2>&1; then | ||||||||||
echo "✅ Health endpoint responds successfully" | ||||||||||
break | ||||||||||
elif [ $i -eq 5 ]; then | ||||||||||
echo "⚠️ Health endpoint not responding (may be expected)" | ||||||||||
else | ||||||||||
echo "⏳ Waiting for health endpoint... (attempt $i/5)" | ||||||||||
sleep 3 | ||||||||||
fi | ||||||||||
done | ||||||||||
|
||||||||||
# Show container logs for debugging | ||||||||||
echo "📋 Container logs:" | ||||||||||
docker logs nlwebnet-test | ||||||||||
echo "📋 Recent container logs:" | ||||||||||
docker logs --tail 10 nlwebnet-test | ||||||||||
else | ||||||||||
echo "❌ Container failed to start" | ||||||||||
docker logs nlwebnet-test | ||||||||||
|
@@ -383,6 +417,31 @@ jobs: | |||||||||
docker stop nlwebnet-test | ||||||||||
docker rm nlwebnet-test | ||||||||||
|
||||||||||
- name: Build and push Docker image to GHCR | ||||||||||
uses: docker/build-push-action@v5 | ||||||||||
with: | ||||||||||
context: . | ||||||||||
file: deployment/docker/Dockerfile | ||||||||||
push: true | ||||||||||
tags: ${{ steps.meta.outputs.tags }} | ||||||||||
labels: ${{ steps.meta.outputs.labels }} | ||||||||||
cache-from: type=gha | ||||||||||
cache-to: type=gha,mode=max | ||||||||||
|
||||||||||
- name: Generate deployment summary | ||||||||||
run: | | ||||||||||
echo "## 🐳 Docker Build Summary" >> $GITHUB_STEP_SUMMARY | ||||||||||
echo "- **Image**: \`ghcr.io/${{ github.repository }}/demo\`" >> $GITHUB_STEP_SUMMARY | ||||||||||
echo "- **Tags**: ${{ steps.meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY | ||||||||||
echo "- **Build Status**: ✅ Success" >> $GITHUB_STEP_SUMMARY | ||||||||||
echo "- **Smoke Test**: ✅ Passed" >> $GITHUB_STEP_SUMMARY | ||||||||||
echo "" >> $GITHUB_STEP_SUMMARY | ||||||||||
echo "### Usage" >> $GITHUB_STEP_SUMMARY | ||||||||||
echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY | ||||||||||
echo "docker pull ${{ steps.meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY | ||||||||||
echo "docker run -p 8080:8080 ${{ steps.meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same issue as the previous line -
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | ||||||||||
|
||||||||||
# Alternative: .NET SDK Container Build (modern approach) | ||||||||||
dotnet-container-build: | ||||||||||
runs-on: ubuntu-latest | ||||||||||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# Docker ignore file for NLWebNet pre-built approach | ||
# This version allows obj/ folders for pre-restored packages | ||
|
||
# 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 (keep obj/ for restore metadata) | ||
**/bin/ | ||
**/out/ | ||
**/.vs/ | ||
|
||
# Test results | ||
TestResults/ | ||
test-results*.xml | ||
coverage*.xml | ||
*.coverage | ||
*.coveragexml | ||
|
||
# NuGet packages (but not restore metadata) | ||
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* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Multi-stage Dockerfile for NLWebNet Demo Application | ||
# This version is optimized for local development environments with SSL issues | ||
# Pre-restore packages using 'dotnet restore' before building with this Dockerfile | ||
|
||
# Build stage | ||
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build | ||
WORKDIR /src | ||
|
||
# Set essential environment variables for .NET in containerized environments | ||
ENV DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true | ||
ENV DOTNET_CLI_TELEMETRY_OPTOUT=true | ||
ENV NUGET_XMLDOC_MODE=skip | ||
|
||
# Install curl for troubleshooting | ||
RUN apt-get update && \ | ||
apt-get install -y curl && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Copy source files | ||
COPY ["src/", "src/"] | ||
COPY ["samples/", "samples/"] | ||
COPY ["NLWebNet.sln", "./"] | ||
COPY ["Directory.Packages.props", "./"] | ||
COPY ["NuGet.Config", "./"] | ||
|
||
# Build the demo application (assumes packages are pre-restored on host) | ||
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 | ||
|
||
# Install curl for health checks and create a non-root user for security | ||
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* \ | ||
&& 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"] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
steps.meta.outputs.tags
contains multiple tags separated by newlines, but this will only show the first tag in the docker pull command. This could confuse users about which tag to actually pull. Consider using a specific tag likelatest
or the first tag from the list.Copilot uses AI. Check for mistakes.