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.
Created dockerForWebAPI.txt
and run
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
Version 1
COPY InfoValutar/InfoValutarDOS/InfoValutarDOS.csproj ./
( not good,same dir)
Version 2
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 )
Version 3
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[0] -Destination $args[1] –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!)
Leave a Reply