From the. Netcore Open source project, Eshoponcontainers, its deployment is cross-platform, can be deployed on Linux,docker, run on Linux it can also write some integrated small scripts, This is an SH script that engineers provide us with a deployment release scenario
#!/bin/Bashdeclare-A projectlist=( '.. /src/services/catalog/catalog.api' '.. /src/services/basket/basket.api' '.. /src/services/ordering/ordering.api' '.. /src/services/identity/identity.api' '.. /src/web/webmvc' '.. /src/web/webspa' '.. /src/web/webstatus') # Build SPA app# pushd $ (pwd) :/src/web/webspa# NPM Run Build:prod forProjectinch "${projectlist[@]}" DoEcho-E"\e[33mworking 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# Remove old Docker images:images=$ (Docker images--filter=reference="eshop/*"-q)if[-N"$images" ]; Then Docker RM $ (Docker PS-A-Q)-F Echo"Deleting eShop images in local Docker repo"Echo $images Docker RMI $ (Docker images--filter=reference="eshop/*"-Q)-ffi# No need to build the images, Docker build or Docker compose will# DoThatusingThe images and containers definedinchThe Docker-compose.yml file.
The above solution mainly embodies the release of some of the commands used, such as arrays, traversal, conditional statements, delete files, publish statements, etc., I write my own practice practiced hand
Declare-a arr= (12345) forIinch "${arr[@]}" Do if[$i = =2]then Echo"A is equal to 2"ElseEcho"a is not equal to 2"Fidonedeclare-A projectlist=( '.. /src/services/catalog/catalog.api' '.. /src/services/basket/basket.api' '.. /src/services/ordering/ordering.api' '.. /src/services/identity/identity.api' '.. /src/web/webmvc' '.. /src/web/webspa' '.. /src/web/webstatus') forProjectinch "${projectlist[@]}" DoEcho-E"\e[33m working in directory $ (PWD)/$project"Echo-E"\e[33m\tremoving old publish output" Done
When you write the sh file, be aware that Linux and Windows are not the same as the carriage return, we can download notepad++ this tool for transcoding.
Linux~sh script a bit of your own summary