1.package.json中增加专属化构建命令

  1. "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”中增加依赖

  1. "cpr": "^3.0.1",

3.根目录下新建增加premises/cdn.js

  1. const fs = require('fs')
  2. const path = require('path')
  3. const cpr = require('cpr').cpr
  4. let staticPremisesPath = path.resolve(__dirname, '../staticPremises');
  5. if (!fs.existsSync(staticPremisesPath)) {
  6. fs.mkdirSync(staticPremisesPath);
  7. }
  8. let staticPremisesCenterPath = path.resolve(__dirname, '../staticPremises/basedoccenter');
  9. if (!fs.existsSync(staticPremisesCenterPath)) {
  10. fs.mkdirSync(staticPremisesCenterPath);
  11. }
  12. cpr(path.resolve(__dirname, '../static/public/basedoccenter'), staticPremisesCenterPath, {}, err => {
  13. });
  14. cpr(path.resolve(__dirname, '../premises-old'), staticPremisesPath, {}, err => {
  15. });

以上代码中’basedoccenter’ 需要改成对应的domainKey

4.修改describe.xml

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project>
  3. <name>基础数据-前端</name> //示例
  4. <code>iuap5-basedoc-fe</code>//示例
  5. <description>基础数据前端服务</description> //示例
  6. <nginxCustomTemplate> //示例
  7. location /basedoc-fe/assets/ { //示例 重要! nginx配置模版
  8. alias {{ #package.location }};
  9. }
  10. </nginxCustomTemplate>
  11. <!-- 重点是把变化的配置文件都要列出来 -->
  12. <configUrls>
  13. </configUrls>
  14. <testLink>basedoccenter/version.json</testLink>
  15. <serviceType>NG-FRONT-END</serviceType> //重要! 修改为静态类型
  16. </project>

5.修改出盘流水线的dockfile 示例如下:

如果之前有node类型的流水线,需要重新建一个静态网站类型的流水线

  1. FROM ycr.yonyoucloud.com/base/node:10-alpine
  2. WORKDIR /code
  3. ADD ./ /code
  4. RUN apk add zip
  5. RUN ynpm install && npm run build:premises
  6. # FROM nginx
  7. FROM ycr.yonyoucloud.com/base/nginx:1.15-alpine
  8. RUN mkdir -p /yonyoucloud-buildproduct
  9. COPY --from=0 /code/staticPremises/ucf-basedoc-fe-premises.zip /yonyoucloud-buildproduct/ucf-basedoc-fe-premises.zip

以上ucf-basedoc-fe-premises.zip 为步骤1 中的名称,请确保正确,确保目录正确