Hello,
while daggerizing an existing application, we are tempted to re-use the existing multi-stage Dockerfile by executing Directory.docker_build(): https://dagger-io.readthedocs.io/en/latest/client.html#dagger.Directory.docker_build
The general structure of the Dockerfile is like this:
FROM (...)/dotnet/sdk:8.0 AS restore
WORKDIR /src
COPY ["src/MyProject/MyProject.csproj", "src/MyProject/"]
COPY ["nuget.config", "."]
RUN dotnet restore "src/MyProject/MyProject.csproj"
FROM restore AS build
ARG BUILD_VERSION
ENV BUILD_VERSION=${BUILD_VERSION:-0.0.0}
COPY . .
WORKDIR "/src/src/MyProject"
RUN dotnet publish "MyProject.csproj" --no-restore -c Release -o /app/publish -p:Version=$BUILD_VERSION
# Final Stage
FROM ${REPO_LOCATION}/dotnet/aspnet:8.0
WORKDIR /app
COPY --from=build /app/publish .
ENV HTTP_PORTS=80
EXPOSE 80
ENTRYPOINT ["dotnet", "MyProject.dll"]
For now we stumble upon a dotnet build failure ("missing dependency") as if the restore stage result is not correctly passed to the build stage.
Is it a good way to proceed or are we totally wrong on the approach?