82
CHAPTER 4 | Development process for Docker-based applications
RUN
dotnet restore
It would restore the packages for the whole solution, but then again, it would do it just once, instead
of the 15 times with the current strategy.
However,
dotnet restore
only runs if there’s a single project or solution file in the folder, so
achieving this is a bit more complicated and the way to solve it, without getting into too many details,
is this:
1.
Add the following lines to
.dockerignore
:
–
*.sln
, to ignore all solution files in the main folder tree
–
!eShopOnContainers-ServicesAndWebApps.sln
, to include only this solution file.
2.
Include the
/ignoreprojectextensions:.dcproj
argument to
dotnet restore
, so it also
ignores the docker-compose project and only restores the packages for the
eShopOnContainers-ServicesAndWebApps solution.
For the final optimization, it just happens that line 20 is redundant, as line 23 also builds the
application and comes, in essence, right after line 20, so there goes another time-consuming
command.
The resulting file is then:
1
Dostları ilə paylaş: