从.netCore开源项目来看,eShopOnContainers来说,它的布局是跨平台的,可以配备在linux,docker上,在linux上运转它也能够写一些合龙的小本子,那是微信工程师为大家提供1个配备揭橥方案的SH脚本

Linux~Sh脚本一点自身的计算,linuxsh脚本

【澳门金沙国际】run起来之后执行多条命令,Sh脚本一点要好的下结论。从.netCore开源项目来看,eShopOnContainers来说,它的布局是跨平台的,能够布署在linux,docker上,在linux上运转它也足以写一些合并的小本子,那是微信工程师为大家提供1个配备公布方案的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[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
    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[33m\tRemoving old publish output"
done

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

从.netCore开源项目来看,eShopOnContainers来说,它的布置是跨平台的,能够安插在linux,docker上,在linu…

从.netCore开源项目来看,eShopOnContainers来说,它的布局是跨平台的,能够布署在linux,docker上,在linux上运转它也足以写一些并入的小本子,那是微信工程师为大家提供三个配备宣布方案的SH脚本

如今在搞jenkins pipeline的布置工作,而在对.net
core进行安排时不期望安装dotnet
sdk,为了移植性更好,打算直接动用aspnetcore的docker镜像,通过docker去run它,而在这些时间出现了一个标题docker run
aspnetcore:2.0之后假若愿意同时履行多少个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[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
    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.
#!/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[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
    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.
docker run aspnetcore:2.0 ls && ls

地点的消除重庆大学反映了宣布时用的有的指令,如数组,遍历,条件语句,删除文件,公布语句等,笔者要好写练了练手

上边的消除主要反映了发表时用的一些下令,如数组,遍历,条件语句,删除文件,宣布语句等,笔者本人写练了练手

结果是第四个ls突显的是容器里的内容,而第3个ls展现的是本土centos的剧情,那不是五叔希望的!

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[33m\tRemoving old publish output"
done
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[33m\tRemoving old publish output"
done

澳门金沙国际 1

世家在写SH文件时要留意,linux与windows的回车符不一样,大家能够下载notepad++那些工具来展开转码。

大家在写SH文件时要专注,linux与windows的回车符分歧,大家得以下载notepad++那一个工具来开始展览转码。

澳门金沙国际 ,父辈希望三个ls,即多条sh命令都在容器里进行,那样就幸免了新加SH文件的烦躁!

下一场大伯找了有的素材,幸运的是,被四叔找到了!

docker run 5800 sh -c "ls && echo '-------' &&  ls"

实在,正是在run后边加了三个sh -c命令,前边一直加多条语句即可!

澳门金沙国际 2

这一次是本人梦想的结果,终于得以了,未来不要建立SH文件了,本来就不应当建立结余的公文,呵呵

 

相关文章