1. 程式人生 > 其它 >docker 安裝 jenkins 打包釋出 netcore 專案

docker 安裝 jenkins 打包釋出 netcore 專案


docker run -u root --rm -d -p 8080:8080 --name dotnetjenkins2 \
-v /usr/bin/docker:/usr/bin/docker \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /etc/sysconfig/docker:/etc/sysconfig/docker \
-v /home/dockerVolumes2/jenkins_home:/var/jenkins_home \
xsw2014/net-jenkins:1.0


這句話第一行意思是用8080對映docker裡面8080埠如果你想外網訪問的時候用5050那麼就修改為
5050:8080

第二至第四行的意思是docker內部可以呼叫外部docker來進行打包,這是什麼意思呢
應為jenkins實在docker容器內那麼容器內是沒法再使用docker命令打包的這個時候我們需要
第二至第四行的語句實現內部呼叫docker了

第五行的意思為將本地的/home/dockerVolumes2/jenkins_home對映到/var/jenkins_home 
如果你後面dotnet publish了需要打包後的檔案就可以到本地的/home/dockerVolumes2/jenkins_home查看了

第六行是使用xsw2014/net-jenkins:1.0這個映象如果你的不是這個映象或者前面你按照你自己的構建的請將這裡換成自己的



/**************************************************/


dotnet restore
dotnet build 
dotnet publish 
echo "Successfully!!!! ^ please see the file ."
pwd

#docker stop helloworldcontainer
#docker rm helloworldcontainer
#docker rmi hello-world
docker build -t hello-world .
docker run --name helloworldcontainer -p 5000:80 -d hello-world


其中
dotnet restore 重新生成專案
dotnet build  重新構建專案
dotnet publish  打包專案
echo "Successfully!!!! ^ please see the file ." 打包成功輸出Successfully
pwd  輸出當前所在資料夾位置

#docker stop helloworldcontainer  停止容器 第一次請註釋第二次放開註釋
#docker rm helloworldcontainer    刪除容器 第一次請註釋第二次放開註釋
#docker rmi hello-world                 刪除映象 第一次請註釋第二次放開註釋

docker build -t hello-world .     通過dodckerfile打包映象注意最後有一個英文的小點
docker run --name helloworldcontainer -p 5000:80 -d hello-world  執行容器

/**************************************************/

jenkins 裡面的構建 shell 命令

dotnet restore
dotnet build 
dotnet publish 
echo "Successfully!!!! ^ please see the file ."
pwd

#docker stop jenkinsdemo
#docker rm jenkinsdemo
#docker rmi hello-jenkins
docker build -t hello-jenkins .
docker run --name jenkinsdemo -p 5000:80 -d hello-jenkins