DEV Community

Cover image for Build once, deploy everywhere question
Lou Elston
Lou Elston

Posted on

Build once, deploy everywhere question

New here, not sure I am in the right place. Trying to follow along on https://dev.to/ibrahimbioabu/build-once-deploy-everywhere-deploying-a-net-8-api-with-docker-aks-github-actions-4h4o.

2.3 Build & Test Container

Ended with...
ERROR: failed to build: failed to solve: failed to compute cache key: failed to calculate checksum of ref wil4ejbxf8ux5bfumculze42j::glt1esrn4utnnfanocc0zel6y: "/WeatherApp": not found

The requirements to follow along state .NET 8 SDK, why then does the Dockerfile FROM's reference 9.0? Is this the problem?

Top comments (1)

Collapse
 
loue_iarx profile image
Lou Elston

Copilot chat had to modify it several times. It also did require the Dockerfile change from 9.0 to 8.0...

=========================

Runtime

=========================

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 8080
ENV ASPNETCORE_URLS=http://+:8080
ENV ASPNETCORE_ENVIRONMENT=Production

=========================

Build

=========================

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src

Copy project file and restore

COPY WeatherApp.csproj ./
RUN dotnet restore WeatherApp.csproj

Copy everything else

COPY . .

Publish (EXPLICIT project path)

RUN dotnet publish WeatherApp.csproj \
-c Release \
-o /app/publish \
/p:UseAppHost=false

=========================

Final

=========================

FROM base AS final
WORKDIR /app
COPY --from=build /app/publish .
ENTRYPOINT ["dotnet", "WeatherApp.dll"]