You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
19 KiB
JavaScript
1 line
19 KiB
JavaScript
"use strict";(self.webpackChunkfurion=self.webpackChunkfurion||[]).push([[8559],{7485:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>t,contentTitle:()=>c,default:()=>h,frontMatter:()=>i,metadata:()=>d,toc:()=>l});var o=r(5893),s=r(1151);r(4996);const i={id:"deploy-docker-auto",title:"35.1 Docker \u73af\u5883\u6301\u7eed\u90e8\u7f72",sidebar_label:"35.1 Docker \u73af\u5883\u6301\u7eed\u90e8\u7f72"},c=void 0,d={id:"deploy-docker-auto",title:"35.1 Docker \u73af\u5883\u6301\u7eed\u90e8\u7f72",description:"35.1.1 \u5173\u4e8e\u5168 Docker \u73af\u5883\u90e8\u7f72",source:"@site/docs/deploy-docker-auto.mdx",sourceDirName:".",slug:"/deploy-docker-auto",permalink:"/docs/deploy-docker-auto",draft:!1,unlisted:!1,editUrl:"https://gitee.com/dotnetchina/Furion/tree/v4/handbook/docs/deploy-docker-auto.mdx",tags:[],version:"current",lastUpdatedBy:"MonkSoul",lastUpdatedAt:1653889755,formattedLastUpdatedAt:"May 30, 2022",frontMatter:{id:"deploy-docker-auto",title:"35.1 Docker \u73af\u5883\u6301\u7eed\u90e8\u7f72",sidebar_label:"35.1 Docker \u73af\u5883\u6301\u7eed\u90e8\u7f72"},sidebar:"docs",previous:{title:"35. \u6301\u7eed\u90e8\u7f72\u96c6\u6210",permalink:"/docs/category/devops"},next:{title:"35.2 \u6301\u7eed\u90e8\u7f72\u96c6\u6210",permalink:"/docs/devops"}},t={},l=[{value:"35.1.1 \u5173\u4e8e\u5168 <code>Docker</code> \u73af\u5883\u90e8\u7f72",id:"3511-\u5173\u4e8e\u5168-docker-\u73af\u5883\u90e8\u7f72",level:2},{value:"35.1.2 \u5b89\u88c5 <code>Docker</code> \u7248 <code>Jenkins</code>",id:"3512-\u5b89\u88c5-docker-\u7248-jenkins",level:2},{value:"35.1.2.1 \u4f7f\u7528 Dockerfile \u5236\u4f5c\u955c\u50cf",id:"35121-\u4f7f\u7528-dockerfile-\u5236\u4f5c\u955c\u50cf",level:3},{value:"35.1.2.2 \u8fd0\u884c <code>Jenkins:dotnet</code> \u955c\u50cf",id:"35122-\u8fd0\u884c-jenkinsdotnet-\u955c\u50cf",level:3},{value:"35.1.3 <code>Jenkins</code> \u7684\u81ea\u52a8\u5316\u90e8\u7f72",id:"3513-jenkins-\u7684\u81ea\u52a8\u5316\u90e8\u7f72",level:2},{value:"35.1.3.1 \u7f16\u5199 Shell \u811a\u672c",id:"35131-\u7f16\u5199-shell-\u811a\u672c",level:3},{value:"35.1.4 <code>Jenkins</code> \u7684\u81ea\u52a8\u5316\u8fdc\u7a0b\u90e8\u7f72",id:"3514-jenkins-\u7684\u81ea\u52a8\u5316\u8fdc\u7a0b\u90e8\u7f72",level:2},{value:"35.1.4.1 \u5b89\u88c5\u63d2\u4ef6",id:"35141-\u5b89\u88c5\u63d2\u4ef6",level:3},{value:"35.1.4.2 \u914d\u7f6e",id:"35142-\u914d\u7f6e",level:3},{value:"35.1.4.3 \u5199\u811a\u672c",id:"35143-\u5199\u811a\u672c",level:3},{value:"35.1.4.4 \u6784\u5efa\u540e\u64cd\u4f5c\uff08\u5173\u952e\uff09",id:"35144-\u6784\u5efa\u540e\u64cd\u4f5c\u5173\u952e",level:3},{value:"35.1.4.5 \u8fdc\u7a0b\u6267\u884c",id:"35145-\u8fdc\u7a0b\u6267\u884c",level:3},{value:"35.1.5 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"3515-\u53cd\u9988\u4e0e\u5efa\u8bae",level:2}];function a(e){const n={a:"a",admonition:"admonition",blockquote:"blockquote",code:"code",h2:"h2",h3:"h3",li:"li",p:"p",pre:"pre",ul:"ul",...(0,s.a)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(n.h2,{id:"3511-\u5173\u4e8e\u5168-docker-\u73af\u5883\u90e8\u7f72",children:["35.1.1 \u5173\u4e8e\u5168 ",(0,o.jsx)(n.code,{children:"Docker"})," \u73af\u5883\u90e8\u7f72"]}),"\n",(0,o.jsxs)(n.p,{children:["\u5229\u7528\u62e5\u6709 ",(0,o.jsx)(n.code,{children:".NET"})," \u73af\u5883\u7684 ",(0,o.jsx)(n.code,{children:"Jenkins"}),"\uff0c\u8fdb\u884c\u6301\u7eed\u5316\u90e8\u7f72"]}),"\n",(0,o.jsxs)(n.h2,{id:"3512-\u5b89\u88c5-docker-\u7248-jenkins",children:["35.1.2 \u5b89\u88c5 ",(0,o.jsx)(n.code,{children:"Docker"})," \u7248 ",(0,o.jsx)(n.code,{children:"Jenkins"})]}),"\n",(0,o.jsxs)(n.p,{children:["\u6b63\u5e38\u5728 ",(0,o.jsx)(n.code,{children:"Docker"})," \u4e2d\u62c9\u53d6\u7684 ",(0,o.jsx)(n.code,{children:"Jenkins:lts"})," \u662f\u65e0\u6cd5\u6267\u884c ",(0,o.jsx)(n.code,{children:"dotnet"})," \u547d\u4ee4\u7684\uff08\u5c31\u7b97\u4f60\u5bbf\u4e3b\u673a\u6709 ",(0,o.jsx)(n.code,{children:"dotnet"})," \u73af\u5883\u3001",(0,o.jsx)(n.code,{children:"docker"})," \u4e2d\u4e5f\u6709 ",(0,o.jsx)(n.code,{children:"dotnet"})," \u73af\u5883\u4e5f\u4e0d\u53ef\u4ee5\uff09\uff0c\r\n\u6240\u4ee5\u6211\u4eec\u53ea\u80fd\u6784\u5efa\u4e00\u4e2a\u5305\u542b ",(0,o.jsx)(n.code,{children:"dotnet"})," \u7684\u955c\u50cf"]}),"\n",(0,o.jsx)(n.h3,{id:"35121-\u4f7f\u7528-dockerfile-\u5236\u4f5c\u955c\u50cf",children:"35.1.2.1 \u4f7f\u7528 Dockerfile \u5236\u4f5c\u955c\u50cf"}),"\n",(0,o.jsxs)(n.p,{children:["\u4f7f\u7528 ",(0,o.jsx)(n.code,{children:"Dockerfile"})," \u521b\u5efa\u5305\u542b ",(0,o.jsx)(n.code,{children:"dotnet"})," \u7684 ",(0,o.jsx)(n.code,{children:"Jenkins"})," \u955c\u50cf"]}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsxs)(n.li,{children:["\ud83d\udc49 \u7f16\u5199 ",(0,o.jsx)(n.code,{children:"Dockerfile"})]}),"\n"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-bash",metastring:"showLineNumbers",children:'# \u5c01\u88c5Jenkins\u955c\u50cf\uff08\u5e26\u6709dotnet\u73af\u5883\u7684\uff09 sdk=5.1\r\nFROM jenkins/jenkins:lts\r\nUSER root\r\nWORKDIR /dotnet\r\nRUN apt-get update && apt-get install -y wget && rm -rf /var/lib/apt/lists/*\r\nRUN wget -O dotnet.tar.gz https://download.visualstudio.microsoft.com/download/pr/820db713-c9a5-466e-b72a-16f2f5ed00e2/628aa2a75f6aa270e77f4a83b3742fb8/dotnet-sdk-5.0.100-linux-x64.tar.gz\r\nRUN tar zxf dotnet.tar.gz -C ./\r\nRUN rm -rf dotnet.tar.gz\r\nENV PATH="${PATH}:/dotnet:/var/jenkins_home/.dotnet/tools"\r\nENV DOTNET_ROOT="/dotnet"\r\nRUN apt update -y\r\nRUN apt install icu-devtools vim zip unzip -y\r\nRUN usermod -a -G root jenkins\r\nUSER jenkins\n'})}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsx)(n.li,{children:"\ud83d\udc49 \u547d\u4ee4\u89e3\u91ca"}),"\n"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-bash",metastring:"showLineNumbers",children:"- 1. \u8fd9\u4e2aDocker\u955c\u50cf\u57fa\u4e8ejenkins\r\n- 2. \u8bbe\u7f6e\u5f53\u524d\u7528\u6237\u4e3aroot\uff0c\u56e0\u4e3a\u540e\u9762\u5b89\u88c5\u9700\u8981\u4f7f\u7528root\r\n- 3. \u8bbe\u7f6e\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\u4e3adotnet\r\n- 4. \u4e0b\u8f7ddotnet SDK\u5305\uff0c\u4fdd\u5b58\u4e3adotnet.tar.gz\u3002\u8fd9\u91cc\u8981\u6ce8\u610f\u4e0b\u8f7d\u6b63\u786e\u7248\u672c\u7684SDK\uff0c\u53ef\u524d\u5f80\u5fae\u8f6f\u5b98\u65b9\u7f51\u7ad9\u83b7\u53d6\u4e0b\u8f7d\u94fe\u63a5\uff1ahttps://dotnet.microsoft.com/download\r\n- 5. \u89e3\u538bdotnet SDK\u5230\u5f53\u524d\u76ee\u5f55\uff0c\u5373/dotnet\u76ee\u5f55\r\n- 6. \u5220\u9664dotnet SDK\u5305\r\n- 7. \u628adotnet\u76ee\u5f55\u548cdotnet tools\u76ee\u5f55\u6dfb\u52a0\u5230\u73af\u5883\u53d8\u91cfPATH\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u4f7f\u7528dotnet\u547d\u4ee4\u4e86\r\n- 8. \u8bbe\u7f6eDOTNET_ROOT\u53d8\u91cf\r\n- 9. \u66f4\u65b0\u6e90\r\n- 10. \u5b89\u88c5\u4e00\u4e9b\u5fc5\u9700\u7684\uff0c\u5e38\u7528\u7684\u5de5\u5177\u5305\uff0c\u5176\u4e2dicu-devtools\u662f\u8fd0\u884cdotnet\u9700\u8981\u7684\r\n- 11. \u4fee\u6539jenkins\u7528\u6237\u5230root\u9644\u52a0\u7ec4\r\n- 12. \u8bbe\u7f6e\u5f53\u524d\u7528\u6237\u4e3ajenkins\n"})}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsxs)(n.li,{children:["\ud83d\udc49 \u6784\u5efa ",(0,o.jsx)(n.code,{children:"Docker"})," \u955c\u50cf ",(0,o.jsx)(n.code,{children:"name=jenkins:dotnet"})]}),"\n"]}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.code,{children:"cd"})," \u5230\u6839\u76ee\u5f55\u4e0b\uff08\u5fc5\u987b\u542b ",(0,o.jsx)(n.code,{children:"Dockerfile"}),"\uff09 \u53ea\u9700\u6784\u5efa\u547d\u4ee4\uff1a"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-bash",metastring:"showLineNumbers",children:" docker build -t jenkins:dotnet .\n"})}),"\n",(0,o.jsx)(n.admonition,{title:"\u7279\u522b\u6ce8\u610f",type:"important",children:(0,o.jsxs)(n.p,{children:["\u7ed3\u5c3e ",(0,o.jsx)(n.code,{children:"."})," \u4e0d\u80fd\u7701\u7565"]})}),"\n",(0,o.jsxs)(n.h3,{id:"35122-\u8fd0\u884c-jenkinsdotnet-\u955c\u50cf",children:["35.1.2.2 \u8fd0\u884c ",(0,o.jsx)(n.code,{children:"Jenkins:dotnet"})," \u955c\u50cf"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-bash",metastring:"showLineNumbers",children:'docker run -d -p 8080:8080 -p 50000:50000 --name mjenkins \\\r\n --privileged=true \\\r\n --restart always \\\r\n -u root \\\r\n -e TZ="Asia/Shanghai" \\\r\n -v /mudata/jenkins:/var/jenkins_home \\\r\n -v /usr/bin/docker:/usr/bin/docker \\\r\n -v /var/run/docker.sock:/var/run/docker.sock \\\r\n -v /mudata/webroot/:/mudata/webroot \\\r\n jenkins:dotnet\n'})}),"\n",(0,o.jsxs)(n.p,{children:["\u63a5\u4e0b\u6765\u5c31\u662f\u6bd4\u8f83\u4fd7\u5957\u7684\u5b89\u88c5 ",(0,o.jsx)(n.code,{children:"Jenkins"})," \u6b65\u9aa4\uff0c\u7f51\u4e0a\u8d44\u6599\u5f88\u591a\uff0c\u4e0d\u5c55\u5f00\u4e86\u3002"]}),"\n",(0,o.jsxs)(n.h2,{id:"3513-jenkins-\u7684\u81ea\u52a8\u5316\u90e8\u7f72",children:["35.1.3 ",(0,o.jsx)(n.code,{children:"Jenkins"})," \u7684\u81ea\u52a8\u5316\u90e8\u7f72"]}),"\n",(0,o.jsx)(n.h3,{id:"35131-\u7f16\u5199-shell-\u811a\u672c",children:"35.1.3.1 \u7f16\u5199 Shell \u811a\u672c"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-bash",metastring:"showLineNumbers",children:"# Jenkins \u6784\u5efa \u6d4b\u8bd5\u670d\r\n\r\necho '============\u67e5\u770b\u6253\u5305\u73af\u5883================'\r\npwd\r\nls\r\necho $PATH\r\n\r\nimage_version=`date +%Y%m%d%H%M`;\r\necho $image_version;\r\n\r\ndotnet --info\r\ndotnet --version\r\n\r\n# \u83b7\u53d6\u77ed\u7248\u672c\u53f7\r\nGITHASH=`git rev-parse --short HEAD`\r\n\r\necho '============================begin restore======================================='\r\ndotnet restore\r\necho '============================end restore======================================='\r\n\r\n#\u8981\u6784\u5efa\u7684\u89e3\u51b3\u65b9\u6848\u540d\u79f0\r\nsolutionName=MUSaas.SCM.BasicData\r\n#docker run\u7684\u5bb9\u5668\u540d\u79f0\r\ncontainerName=jenkinsscmbasic\r\n#\u6307\u5b9arun\u7684\u7aef\u53e3\r\nport=9994\r\n#.sln\u6587\u4ef6\u5168\u8def\u5f84\r\n#solutionDir=20-Solution/${solutionName}.sln\r\n#.csproj\u6587\u4ef6\u5168\u8def\u5f84\r\ncsprojDir=${solutionName}/${solutionName}.csproj\r\n\r\n#\u9879\u76ee\u53d1\u5e03\u7684\u76ee\u5f55\r\nwebDir=/mudata/webroot/jenkins/publish/webapp\r\n\r\n#\u5f52\u6863\u76ee\u5f55\r\narchivesDir=/mudata/webroot/jenkins/publish/archives\r\n\r\n#\u6e05\u7a7a\u6587\u4ef6\u5939\r\nrm -rf ${webDir}/${JOB_NAME}/*\r\n\r\n#\u53d1\u5e03\u7f51\u7ad9\u5230webDir\r\ndotnet publish ${JENKINS_HOME}/workspace/${JOB_NAME}/${csprojDir} -c Release -o ${webDir}/${JOB_NAME} /p:Version=1.0.${BUILD_NUMBER}\r\n#\u590d\u5236\u914d\u7f6e\u6587\u4ef6\r\n#cp -rf /vdb1/jenkins/DotNetCoreWebPublishToDockerCommonConfigs/* ${webDir}/${JOB_NAME}/\r\n\r\n#\u5224\u65b7\u662f\u5426\u5b58\u5728\r\nCID=$(docker ps | grep \"${containerName}\" | awk '{print $1}')\r\necho $CID\r\nif [ \"$CID\" != \"\" ];then\r\n docker stop ${containerName}\r\n docker rm ${containerName}\r\n docker rmi ${containerName}\r\n#docker stop $CID\r\n#docker rm $CID\r\nfi\r\n\r\n\r\n#\u901a\u8fc7Dockerfile\u91cd\u65b0\u6784\u5efa\u955c\u50cf\r\ndocker build -t ${containerName} ${webDir}/${JOB_NAME}/.\r\n#docker run\u5bb9\u5668\u5e76\u7ed1\u5b9a\u5230\u7aef\u53e3\r\n#docker run -d -p ${port}:80 --name ${containerName} ${containerName}\r\ndocker run --name ${containerName} --restart=always -d -p ${port}:${port} -v /etc/localtime:/etc/localtime:ro ${containerName}\r\necho \"success!\"\r\n\n"})}),"\n",(0,o.jsxs)(n.blockquote,{children:["\n",(0,o.jsxs)(n.p,{children:["\u5c31\u8fd9\u6837\u81ea\u52a8\u5316\u90e8\u7f72\u5c31\u597d\u4e86\u3002 \u6d4b\u8bd5\u670d\u7684 ",(0,o.jsx)(n.code,{children:"Jenkins"})," \u5c06\u6e90\u7801\u62c9\u4e0b\u6765\uff0c",(0,o.jsx)(n.code,{children:"Publish\uff0cDocker Build\uff0cDocker Run"}),"\u3002"]}),"\n"]}),"\n",(0,o.jsxs)(n.blockquote,{children:["\n",(0,o.jsxs)(n.p,{children:["\u8fd9\u91cc\u60f3\u8981\u53d1\u5e03\u7684\u65f6\u5019\uff0c\u6bcf\u6b21\u90fd\u9700\u8981\u624b\u52a8\u53bb\u70b9\u51fb\u201c\u6784\u5efa\u201d\u624d\u4f1a\u6267\u884c\u3002\u4e5f\u53ef\u4ee5\u505a\u6210\u5f53\u5206\u652f\u5408\u5e76\u6210\u529f\u540e\u81ea\u52a8\u8fd0\u884c\u3002\u53cd\u6b63 ",(0,o.jsx)(n.code,{children:"Jenkins"})," \u88c5\u597d\u4e4b\u540e\uff0c\u4f60\u60f3\u8981\u4ec0\u4e48\u90fd\u80fd\u73a9\u8d77\u6765\u3002\u6bd4\u5982\u6307\u5b9a\u5206\u652f\u63d0\u4ea4\u540e\u81ea\u52a8\u201c\u6784\u5efa\u201d\u3001\u6bd4\u5982\u6784\u5efa\u6210\u529f\u540e\u5408\u5e76\u5230 Master \u7b49\u7b49"]}),"\n"]}),"\n",(0,o.jsxs)(n.h2,{id:"3514-jenkins-\u7684\u81ea\u52a8\u5316\u8fdc\u7a0b\u90e8\u7f72",children:["35.1.4 ",(0,o.jsx)(n.code,{children:"Jenkins"})," \u7684\u81ea\u52a8\u5316\u8fdc\u7a0b\u90e8\u7f72"]}),"\n",(0,o.jsx)(n.h3,{id:"35141-\u5b89\u88c5\u63d2\u4ef6",children:"35.1.4.1 \u5b89\u88c5\u63d2\u4ef6"}),"\n",(0,o.jsxs)(n.blockquote,{children:["\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.code,{children:"Publish Over SSH"})}),"\n"]}),"\n",(0,o.jsx)(n.h3,{id:"35142-\u914d\u7f6e",children:"35.1.4.2 \u914d\u7f6e"}),"\n",(0,o.jsxs)(n.blockquote,{children:["\n",(0,o.jsxs)(n.p,{children:["\u7cfb\u7edf\u7ba1\u7406 => ",(0,o.jsx)(n.code,{children:"Publish over SSH"})]}),"\n"]}),"\n",(0,o.jsx)(n.h3,{id:"35143-\u5199\u811a\u672c",children:"35.1.4.3 \u5199\u811a\u672c"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-bash",metastring:"showLineNumbers",children:"# Jenkins \u6784\u5efa \u6b63\u5f0f\u670d\r\n\r\necho '============\u67e5\u770b\u6253\u5305\u73af\u5883================'\r\npwd\r\nls\r\necho $PATH\r\n\r\nimage_version=`date +%Y%m%d%H%M`;\r\necho $image_version;\r\n\r\ndotnet --info\r\ndotnet --version\r\n\r\n# \u83b7\u53d6\u77ed\u7248\u672c\u53f7\r\nGITHASH=`git rev-parse --short HEAD`\r\n\r\necho '============================begin restore======================================='\r\ndotnet restore\r\necho '============================end restore======================================='\r\n\r\n#\u8981\u6784\u5efa\u7684\u89e3\u51b3\u65b9\u6848\u540d\u79f0\r\nsolutionName=MUSaas.SCM.BulkOrder\r\n#docker run\u7684\u5bb9\u5668\u540d\u79f0\r\ncontainerName=jenkinsscmbulk\r\n#\u6307\u5b9arun\u7684\u7aef\u53e3\r\nport=9986\r\n#.csproj\u6587\u4ef6\u5168\u8def\u5f84\r\ncsprojDir=/${solutionName}/${solutionName}.csproj\r\n\r\n#\u9879\u76ee\u53d1\u5e03\u7684\u76ee\u5f55\r\nwebDir=/mudata/webroot/jenkins/publish/webapp\r\n\r\n#\u5f52\u6863\u76ee\u5f55\r\narchivesDir=/mudata/webroot/jenkins/publish/archives\r\n\r\n#\u6e05\u7a7a\u6587\u4ef6\u5939\r\nrm -rf ${webDir}/${JOB_NAME}/*\r\n\r\n#\u53d1\u5e03\u7f51\u7ad9\u5230webDir\r\ndotnet publish ${JENKINS_HOME}/workspace/${JOB_NAME}/${csprojDir} -c Release -o ${webDir}/${JOB_NAME} /p:Version=1.0.${BUILD_NUMBER}\r\n#\u590d\u5236\u914d\u7f6e\u6587\u4ef6\r\n#cp -rf /vdb1/jenkins/DotNetCoreWebPublishToDockerCommonConfigs/* ${webDir}/${JOB_NAME}/\r\n\r\n\r\n#\u6784\u5efa\u8fdc\u7a0b\u5305\r\n\r\nrm -rf ${JENKINS_HOME}/workspace/${JOB_NAME}/publish\r\nmkdir ${JENKINS_HOME}/workspace/${JOB_NAME}/publish\r\n\r\ntar -czvf ${JENKINS_HOME}/workspace/${JOB_NAME}/publish/${JOB_NAME}.${BUILD_NUMBER}.tar.gz -C ${webDir}/${JOB_NAME} .\r\n\r\necho \"success!\"\n"})}),"\n",(0,o.jsxs)(n.blockquote,{children:["\n",(0,o.jsxs)(n.p,{children:["\u5927\u6982\u903b\u8f91\u5c31\u662f\u53d1\u5e03\u540e\uff0c\u6253\u4e2a\u5305\u3002\u7136\u540e\u4e22\u7ed9\u8fdc\u7a0b\uff0c\u8fdc\u7a0b\u518d\u6267\u884c ",(0,o.jsx)(n.code,{children:"shell"})]}),"\n"]}),"\n",(0,o.jsxs)(n.blockquote,{children:["\n",(0,o.jsxs)(n.p,{children:["\u6ce8\u610f\u8fd9\u91cc\u4e00\u5b9a\u8981\u53d1\u5e03\u5230\u81ea\u5df1\u7684 ",(0,o.jsx)(n.code,{children:"workspace"})," \u4e0b\uff0c\u9632\u6b62\u4e0b\u4e00\u6b65\u6b7b\u6d3b\u627e\u4e0d\u5230\u4f4d\u7f6e\u3002\u5982\u679c\u627e\u4e0d\u5230\u4f4d\u7f6e\uff0c\u53ea\u80fd\u6162\u6162\u7528 ",(0,o.jsx)(n.code,{children:"ls"})," \u547d\u4ee4\uff0c\u4e00\u7ea7\u4e00\u7ea7\u53bb\u6d4b\uff0c\u5f88\u9ebb\u70e6"]}),"\n"]}),"\n",(0,o.jsx)(n.h3,{id:"35144-\u6784\u5efa\u540e\u64cd\u4f5c\u5173\u952e",children:"35.1.4.4 \u6784\u5efa\u540e\u64cd\u4f5c\uff08\u5173\u952e\uff09"}),"\n",(0,o.jsxs)(n.p,{children:["\u9009\u62e9 ",(0,o.jsx)(n.code,{children:"Send Build artifacts over SSH"})]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-bash",metastring:"showLineNumbers",children:"Source files: publish/\r\nRemove prefix(\u4e0d\u586b)\r\nRemote directory:/mudata/webroot/publish/\r\nExec command:bash /mudata/shell/publish.sh ${JOB_NAME} jenkinsscmbase ${JOB_NAME}.${BUILD_NUMBER} 9994\n"})}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsx)(n.li,{children:"\u9009\u62e9\u81ea\u5df1\u7684 SSH \u670d\u52a1\u5668"}),"\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.code,{children:"Source files"}),"\uff1a\u4e00\u5b9a\u662f ",(0,o.jsx)(n.code,{children:"workspace"})," \u4e0b\u7684\u5730\u5740"]}),"\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.code,{children:"Remote directory"}),"\uff1a\u8fdc\u7a0b\u5730\u5740\uff0c\u4ece\u6839\u76ee\u5f55\u5f00\u59cb"]}),"\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.code,{children:"Exec command"}),"\uff1a\u8981\u6267\u884c\u7684 shell\u3002\u8fd9\u91cc\u6240\u6709\u7684 ",(0,o.jsx)(n.code,{children:"Jenkins"})," \u73af\u5883\u53d8\u91cf\u90fd\u53ef\u4ee5\u7528"]}),"\n"]}),"\n",(0,o.jsx)(n.h3,{id:"35145-\u8fdc\u7a0b\u6267\u884c",children:"35.1.4.5 \u8fdc\u7a0b\u6267\u884c"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-bash",metastring:'showLineNumbers title="publish.sh"',children:'# Jenkins Prod\u670d \u8c03\u7528\u811a\u672c\r\nsolutionName=$1\r\ncontainerName=$2\r\nfilename=$3\r\nport=$4\r\n#.publis\r\necho ${solutionName}\r\necho ${containerName}\r\necho ${filename}\r\nbaseDir=/mudata/webroot/publish\r\n\r\nwebDir=${baseDir}/publish/${filename}\r\n\r\nrm -rf ${webDir}\r\nmkdir ${webDir}\r\n\r\ntar -zxvf ${baseDir}/publish/${filename}.tar.gz -C ${webDir}/\r\nrm -f ${webDir}/appsettings.json && mv ${webDir}/appsettings.Prod.json ${webDir}/appsettings.json\r\n\r\n#\u5224\u65b7\u662f\u5426\u5b58\u5728\r\nCID=$(docker ps | grep "${containerName}" | awk \'{print $1}\')\r\necho $CID\r\nif [ "$CID" != "" ];then\r\n docker stop ${containerName}\r\n docker rm ${containerName}\r\n docker rmi ${containerName}\r\n#docker stop $CID\r\n#docker rm $CID\r\nfi\r\n\r\ncd ${webDir}/ && docker build -t ${containerName} .\r\ndocker run --name ${containerName} --restart=always -d -p ${port}:${port} --link myredis:myredis -v /etc/localtime:/etc/localtime:ro ${containerName}\n'})}),"\n",(0,o.jsxs)(n.blockquote,{children:["\n",(0,o.jsxs)(n.p,{children:["\u8fd9\u91cc\u7684\u903b\u8f91\u5c31\u662f\u89e3\u538b\uff0c\u7136\u540e ",(0,o.jsx)(n.code,{children:"Docker"})," \u76f8\u5173\u3002\u6bcf\u6b21\u6784\u5efa\u90fd\u662f\u5e26\u7740\u7248\u672c\u53f7\u6765\u7684\u3002"]}),"\n"]}),"\n",(0,o.jsx)(n.h2,{id:"3515-\u53cd\u9988\u4e0e\u5efa\u8bae",children:"35.1.5 \u53cd\u9988\u4e0e\u5efa\u8bae"}),"\n",(0,o.jsx)(n.admonition,{title:"\u4e0e\u6211\u4eec\u4ea4\u6d41",type:"note",children:(0,o.jsxs)(n.p,{children:["\u7ed9 Furion \u63d0 ",(0,o.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/issues/new?issue",children:"Issue"}),"\u3002"]})})]})}function h(e={}){const{wrapper:n}={...(0,s.a)(),...e.components};return n?(0,o.jsx)(n,{...e,children:(0,o.jsx)(a,{...e})}):a(e)}},1151:(e,n,r)=>{r.d(n,{Z:()=>d,a:()=>c});var o=r(7294);const s={},i=o.createContext(s);function c(e){const n=o.useContext(i);return o.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:c(e.components),o.createElement(i.Provider,{value:n},e.children)}}}]); |