xml地图|网站地图|网站标签 [设为首页] [加入收藏]
来自 IT之家 2019-10-05 01:25 的文章
当前位置: 新濠国际登录平台 > IT之家 > 正文

发布语句等,发布语句等

从.netCore开源项目来看,eShopOnContainers来说,它的部署是跨平台的,可以部署在linux,docker上,在linux上运行它也可以写一些集成的小脚本,这是微信工程师为我们提供一个部署发布方案的SH脚本

Linux~Sh脚本一点自己的总结,linuxsh脚本

从.netCore开源项目来看,eShopOnContainers来说,它的部署是跨平台的,可以部署在linux,docker上,在linux上运行它也可以写一些集成的小脚本,这是微信工程师为我们提供一个部署发布方案的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++这个工具来进行转码。

新濠国际登录平台, 从.netCore开源项目来看,eShopOnContainers来说,它的部署是跨平台的,可以部署在linux,docker上,在linu...

最近在搞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[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.
docker run aspnetcore:2.0 ls && ls

上面的解决主要体现了发布时用的一些命令,如数组,遍历,条件语句,删除文件,发布语句等,我自己写练了练手

结果是第一个ls显示的是容器里的内容,而第二个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[33mtRemoving old publish output"
done

新濠国际登录平台 1

本文由新濠国际登录平台发布于IT之家,转载请注明出处:发布语句等,发布语句等

关键词: