Linux ~ THE Sh script is a summary of its own, and the linuxsh script
From. from the perspective of the netCore open-source project, eShopOnContainers is deployed across platforms. It can be deployed on linux, docker, and linux. It can also write integrated small scripts, this is an SH script for engineers to provide us with a deployment and release solution.
#!/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:prodfor project in "${projectList[@]}"do echo -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# do that using the images and containers defined in the docker-compose.yml file.
The above solution mainly reflected some commands used during the release, such as arrays, traversal, conditional statements, deletion of files, and release statements. I wrote and practiced it myself.
Declare-a arr = (12345) for I in "$ {arr [@]}" do if [$ I = 2] then echo "a is equal to 2" else echo "a is not equal to 2" fidonedeclare-a projectList = ('.. /src/Services/Catalog. API ''.. /src/Services/Basket. API ''.. /src/Services/Ordering. API ''.. /src/Services/Identity. API ''.. /src/Web/WebMVC ''.. /src/Web/WebSPA ''.. /src/Web/WebStatus ') for project in "$ {projectList [@]}" do echo-e "\ e [33m working in directory $ (pwd) /$ project "echo-e" \ e [33m \ tRemoving old publish output "done
When writing SH files, you should note that the carriage returns for linux and windows are different. We can download the notepad ++ tool for transcoding.