Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jun 26, 2025

Problem

The Docker build was failing with the following error:

ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref a502c559-9809-4f96-84c0-6fa0b04836ec::rxxwmphlvzurwko8q21ra0urs: "/samples/AspireHost/NLWebNet.AspireHost.csproj": not found

The Dockerfile was trying to copy samples/AspireHost/NLWebNet.AspireHost.csproj but this file doesn't exist at that path. The actual file is located at samples/AspireDemo/AspireHost/NLWebNet.AspireHost.csproj.

Root Cause

The AspireHost project is part of a separate solution (samples/AspireDemo/NLWebNet.AspireDemo.sln) and is not included in the main solution (NLWebNet.sln) that the Docker build targets. The Dockerfile is designed to build the Demo application, not the AspireHost project.

Solution

Removed the incorrect project reference from the Dockerfile:

 # 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/"]

Changes Made

  • Fixed: deployment/docker/Dockerfile - Removed the line that copied the non-existent AspireHost project file
  • Added: tests/NLWebNet.Tests/Docker/DockerfileTests.cs - Regression tests to ensure:
    • All project files referenced in Dockerfile exist
    • Dockerfile no longer references AspireHost project
  • Added: test-docker-fix.sh - Verification script for manual testing

Verification

  • ✅ Docker build now successfully completes the file copying stage
  • ✅ All 37 tests pass (including 2 new regression tests)
  • ✅ Verified the fix addresses the exact error reported in the issue

This is a minimal, surgical fix that removes only the problematic line without affecting the functionality of the Docker build for the Demo application.

Fixes #29.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI changed the title [WIP] ⚙️ Fix broken Docker build ⚙️ Fix broken Docker build by removing non-existent AspireHost project reference Jun 26, 2025
Copilot AI requested a review from jongalloway June 26, 2025 04:06
Copilot finished work on behalf of jongalloway June 26, 2025 04:06
@jongalloway jongalloway requested a review from Copilot June 26, 2025 04:07
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a broken Docker build by removing an invalid project reference, and adds tests and a helper script to catch similar issues in the future.

  • Removed the non-existent AspireHost project COPY line from the Dockerfile
  • Added DockerfileTests.cs to verify all .csproj references exist and to guard against AspireHost references
  • Added test-docker-fix.sh to manually validate the Dockerfile copy stage

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
deployment/docker/Dockerfile Removed the COPY ["samples/AspireHost/..."] line
tests/NLWebNet.Tests/Docker/DockerfileTests.cs Added MSTest cases to verify referenced project files and ensure no AspireHost reference
test-docker-fix.sh Added a bash script for manual Docker build verification
Comments suppressed due to low confidence (3)

tests/NLWebNet.Tests/Docker/DockerfileTests.cs:29

  • The projectPath from the regex contains forward slashes which may not be recognized on Windows. Consider normalizing separators, e.g., projectPath = projectPath.Replace('/', Path.DirectorySeparatorChar); before combining paths.
            var fullPath = Path.Combine(rootPath, projectPath);

test-docker-fix.sh:1

  • Ensure this script is marked executable (e.g., chmod +x test-docker-fix.sh) so it can be run directly in CI environments.
#!/bin/bash

test-docker-fix.sh:11

  • Using | head -20 truncates the build logs and may hide important failure details. Consider removing | head -20 to preserve the full output in CI logs.
docker build -f deployment/docker/Dockerfile --target build --no-cache -t nlwebnet-build-test . 2>&1 | head -20

@jongalloway jongalloway marked this pull request as ready for review June 26, 2025 04:56
@jongalloway jongalloway merged commit 45db6c0 into main Jun 26, 2025
8 checks passed
@jongalloway jongalloway deleted the copilot/fix-29 branch July 1, 2025 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

⚙️ Fix broken Docker build

2 participants