none
Docker build step COPY --from=publish /app . takes a long time... any thoughts why? RRS feed

  • Question

  • I have a docker file that essentially looks like this.

    FROM  mcr.microsoft.com/windows/servercore:1809 as base

    SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]


    RUN iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')); \
        choco install dotnetcore-runtime --version 2.2.6 -y; \
        choco install aspnetcore-runtimepackagestore --version 2.2.6 -y

    ENV ASPNETCORE_URLS http://*:80
    WORKDIR /app
    EXPOSE 80

    FROM mcr.microsoft.com/dotnet/core/sdk:2.2-nanoserver-1809 AS build

    USER Administrator

    ADD https://nodejs.org/dist/v10.7.0/node-v10.7.0-win-x64.zip C:\\build\\node-v10.7.0-win-x64.zip
    RUN mkdir "C:\\Program Files\\node" && \
      tar.exe -xf C:\\build\\node-v10.7.0-win-x64.zip -C "C:\\Program Files\\node" --strip-components=1
    RUN setx /M PATH "C:\Program Files\node;%PATH%"

    RUN RMDIR /s /q c:\\build

    WORKDIR /src
    COPY . .

    COPY .nuget/nuget.config .
    RUN dotnet restore "something.csproj" --configfile nuget.config
    # COPY . .
    WORKDIR "/src/something.csproj folder"
    RUN dotnet build "something.csproj" -c Release -o /app


    FROM build AS publish
    RUN dotnet publish "something.csproj" -c Release -o /app

    FROM base AS final
    WORKDIR /app
    COPY --from=publish /app .
    copy buildnumber.html /app/wwwroot
    ENTRYPOINT ["dotnet", "something.dll"]

    the command Copy . .   sometimes takes 10 min

    The command  RUN dotnet build "something.csproj" -c Release -o /app     took 25 min with the copy to the /app folder taking 20 min

    build	01-Oct-2019 12:04:05	  Something.csproj -> C:\app\
    build	01-Oct-2019 12:23:26	Removing intermediate container d31f13da795d


    Any ideas on why this takes some long and what can be done to optimize?

    • Edited by LanceLyons Tuesday, October 1, 2019 5:37 PM
    Tuesday, October 1, 2019 5:04 PM

All replies

  • Greetings,

    Please open "Resource Monitor", and pay attention to these small files operations.


    Sic Parvis Magna

    Monday, October 7, 2019 1:56 PM