1.package.json中增加专属化构建命令
"build:premises": "npm run build:extend:max && rm -rf ./staticPremises && node premises/cdn.js && cd ./staticPremises && rm -rf ucf-basedoc-fe-premises.zip && zip -r ucf-basedoc-fe-premises.zip ./"
以上 ‘ucf-basedoc-fe-premises.zip’为 扩展文件打包名称。后面会用到,且不可与其他工程冲突。如果之前构建包含node,不可以与之前的包名重复
2.package.json 的”devDependencies”中增加依赖
"cpr": "^3.0.1",
3.根目录下新建增加premises/cdn.js
const fs = require('fs')
const path = require('path')
const cpr = require('cpr').cpr
let staticPremisesPath = path.resolve(__dirname, '../staticPremises');
if (!fs.existsSync(staticPremisesPath)) {
fs.mkdirSync(staticPremisesPath);
}
let staticPremisesCenterPath = path.resolve(__dirname, '../staticPremises/basedoccenter');
if (!fs.existsSync(staticPremisesCenterPath)) {
fs.mkdirSync(staticPremisesCenterPath);
}
cpr(path.resolve(__dirname, '../static/public/basedoccenter'), staticPremisesCenterPath, {}, err => {
});
cpr(path.resolve(__dirname, '../premises-old'), staticPremisesPath, {}, err => {
});
以上代码中’basedoccenter’ 需要改成对应的domainKey
4.修改describe.xml
<?xml version="1.0" encoding="UTF-8"?>
<project>
<name>基础数据-前端</name> //示例
<code>iuap5-basedoc-fe</code>//示例
<description>基础数据前端服务</description> //示例
<nginxCustomTemplate> //示例
location /basedoc-fe/assets/ { //示例 重要! nginx配置模版
alias {{ #package.location }};
}
</nginxCustomTemplate>
<!-- 重点是把变化的配置文件都要列出来 -->
<configUrls>
</configUrls>
<testLink>basedoccenter/version.json</testLink>
<serviceType>NG-FRONT-END</serviceType> //重要! 修改为静态类型
</project>
5.修改出盘流水线的dockfile 示例如下:
如果之前有node类型的流水线,需要重新建一个静态网站类型的流水线
FROM ycr.yonyoucloud.com/base/node:10-alpine
WORKDIR /code
ADD ./ /code
RUN apk add zip
RUN ynpm install && npm run build:premises
# FROM nginx
FROM ycr.yonyoucloud.com/base/nginx:1.15-alpine
RUN mkdir -p /yonyoucloud-buildproduct
COPY --from=0 /code/staticPremises/ucf-basedoc-fe-premises.zip /yonyoucloud-buildproduct/ucf-basedoc-fe-premises.zip
以上ucf-basedoc-fe-premises.zip 为步骤1 中的名称,请确保正确,确保目录正确