Docker ~ Do not use yml for batch deployment service, dockeryml for deployment
Sometimes, in a continuous integration environment, sometimes the yml environment does not exist. It may only provide docker tools, but docker-compose may not be provided, in this way, if we want to automatically build all the projects under the solution, we need to write the sh script, and we need to write the projects that need to be packaged, released, and mirrored into our array, then traverse it!
1. Restore and release projects in batches
#! /Bin/sh # declare the project declare-a projectList = ('.. /Beijing. tax ''.. /Jiangsu. tax ') # recover package dependency and release for project in "$ {projectList [@]}" do echo-e "\ e [33 mWorking on $ (pwd) /$ project "echo-e" \ e [33m \ tRemoving old publish output "pushd $ (pwd) /$ project rm-rf obj/Docker/publish echo-e "\ e [33m \ tRestoring project" dotnet restore echo-e "\ e [33m \ tBuilding and publishing projects" dotnet publish-o obj/Docker/publish popddone
Ii. generate images in batches
#! /Bin/sh export Registry_Url = "ciregistry.i-counting.cn: 8443" # declare the project declare-a projectList = ('.. /Beijing. tax, lind/bejing. tax ''.. /Jiangsu. tax, lind/jiangsu. tax ') for project in "$ {projectList [@]}" doarr = ($ {project //,/}) dir =$ {arr [0]} image =$ {arr [1]} echo "dir" echo $ dirpushd $ (pwd) /$ dirdocker build -- no-cache -- pull-t $ image. /docker tag $ image $ Registry_Url/$ image # docker push $ Registry_Url/$ imagedone
Then we can use docker images "lind/*" to view all image files starting with lind.
Generally, all our scripts are placed in the root directory of the solution, create a deploy, and put the automation script in.
Thank you for reading this article!
Sometimes, there may be a variety of ways to achieve one goal. You can choose one that suits us!