能够配备在linux

从.netCore开源项目来看,eShopOnContainers来讲,它的布局是跨平台的,能够配备在linux,docker上,在linux上运维它也得以写一些并入的小本子,那是Wechat程序猿为大家提供叁个结构公布方案的SH脚本

#!/bin/bash
declare -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

for project in "${projectList[@]}"
do
    echo -e "e[33mWorking on $(pwd)/$project"
    echo -e "e[33mtRemoving old publish output"
    pushd $(pwd)/$project
    rm -rf obj/Docker/publish
    echo -e "e[33mtRestoring project"
    dotnet restore
    echo -e "e[33mtBuilding and publishing projects"
    dotnet publish -o obj/Docker/publish
    popd
done

# 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) -f
fi

# 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.

地点的清除珍视反映了宣布时用的片段发令,如数组,遍历,条件语句,删除文件,公布语句等,小编自个儿写练了练手

declare -a arr=(1
2
3
4
5
)
for i in "${arr[@]}"
do 
if [ $i == 2 ]
then
   echo "a is equal to 2"
else
   echo "a is not equal to 2"
fi

done


declare -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'
)

for project in "${projectList[@]}"
do
    echo -e "e[33m工作在目录 $(pwd)/$project"
    echo -e "e[33mtRemoving old publish output"
done

大家在写SH文件时要留心,linux与windows的回车符不均等,我们得以下载notepad++这几个工具来进行转码。