I am new to Docker, but having followed a course (which used Node.js as the app framemwork) and a couple of other tutorials, I have tried to develop an initial test Dockerfile for .NET 9.0 Blazor WASM as a stand-alone PWA, and will attempt to link later to various associated .NET 9.0 APIs I also built. I began with the template from VS 2022, and chose not to include the .csproj file in the solution folder (which is apparently a requirement for .NET Aspire), with no changes to the template project structure, and no new code added, just the basic template itself completely unchanged.
Project structure (as per VS template) is as follows:
docker-test - docker-test - bin - Debug - Release - Layout - obj - Pages - Properties - wwwroot ... additional template files including docker-test.csproj (unchanged) ... - docker-test.sln - DockerfileI ran the publish of the project as a first step, as per the instructions at:https://learn.microsoft.com/en-us/dotnet/core/docker/build-container?tabs=windows&pivots=dotnet-9-0
The Dockerfile I have developed by following tutorials and the course is below:
# Dev portionFROM mcr.microsoft.com/dotnet/aspnet:9.0 AS baseWORKDIR ./EXPOSE 7149EXPOSE 5108# Restore portionFROM mcr.microsoft.com/dotnet/sdk:9.0 AS buildARG BUILD_CONFIGURATION=ReleaseWORKDIR ./docker-testCOPY . ./RUN dotnet restore# Build portionWORKDIR ./docker-testRUN dotnet build ./docker-test.csproj -c $BUILD_CONFIGURATION -o ./build#Publish portionFROM build AS publish ARG BUILD_CONFIGURATION=ReleaseWORKDIR ./docker-test/buildRUN dotnet publish -c $BUILD_CONFIGURATION -o ./docker-test/build/publish apphost=false# Image build portionFROM base AS finalWORKDIR ./docker-test/build/publish COPY --from=publish /docker-test/build/publish .ENTRYPOINT ["dotnet", "docker-test.dll"]The error in the terminal states:
ERROR: failed to solve: process "/bin/sh -c dotnet publish -c Release -o ./docker-test/build/publish apphost=false" did not complete successfully: exit code: 1I have attempted various changes to the specified publish statement itself, and consulted the tutorials and course content again, but not sure where I am making the error (although I'm certain it is a rookie mistake).
Any support with correcting this error so that I can learn how to get it right in future would be extremely appreciated, with thanks in advance for your time.