Docker–first part–part 17
Trying to put the web into docker. In order to have easy builds for the developer , we copy the sln, then the csproj , then dotnet restore, then copy files. This way we get advantage of Docker caching.
docker build -f dockerForWebAPI.txt -t infovalutar ..
Docker has not recursive copy – https://github.com/moby/moby/issues/15858
Solution: copy the .csproj one by one. ( other solution: .tar file and copy the .csproj into tar, then use ADD command)
So copy the .sln with
COPY InfoValutar/*.sln ./
Then trying to copy files
COPY InfoValutar/InfoValutarDOS/InfoValutarDOS.csproj ./
( not good, same dir)
COPY InfoValutar/InfoValutarDOS/InfoValutarDOS.csproj ./app/InfoValutarDOS/InfoValutarDOS.csproj
(not good , discovered that creates another app folder – thanks for the docker run –rm -it infovalutar:latest /bin/bash )
COPY InfoValutar/InfoValutarDOS/InfoValutarDOS.csproj ./InfoValutarDOS/InfoValutarDOS.csproj
Good. Now copy files and build solution
And now it is the moment when echo and xcopy for plugins will bite me – no xcopy on linux….
The only thing that I know to work in WIndows and Linux is … Powershell.
Any .NET Core 3 has this – run pwsh. It remains to install to my directory – see https://andrewlock.net/new-in-net-core-3-local-tools/
The version of powershell on my PC differs from the version on Windows Container from GitHub actions. Switch to Ubuntu.
Again – does not work . Try with pwsh –Command.
It does work on GitHub actions but NOT on my PC ( does not recognize command. ) . Thinking different pwsh version.
But on thing is the same – running file.
Create a powershell file
Copy-Item -Path $args -Destination $args –Recurse
and running this file with
pwsh $(ProjectDir)pb.ps1 “$(TargetDir)” “$(SolutionDir)plugins\$(ProjectName)”
( Do not forget to run first
dotnet tool restore
in the solution folder!)And one hour passes...
(This is the result of 1 hour per day auto-challenge as a full cycle developer for an exchange rates application)
( You can see the sources at https://github.com/ignatandrei/InfoValutar/ )