Skip to main content
Version: v22.10

1. 开发环境

环境准备

  • 操作系统: Windows 或 macOS,暂不支持 ubuntu 等 Linux 发行版
  • 内存:8GB+
  • nodejs:12+

腾讯问卷提供的前置材料

  • git.code.tencent.com Git 代码仓库(包含指定分支与 Tag)
  • 测试环境地址
  • 流水线
    • 当向 git.code.tencent.com push 代码时将自动触发构建,并将对应代码部署到上述的测试环境中

步骤

1. 使用本地前端代码替换私有化部署中的前端组件

  1. 使用 Git Clone 后启动本地前端代码

  2. 修改私有化部署中的文件 tgw/nginx/conf/nginx_htdocs/server.upstream,根据实际情况取消代码中的注释,或添加注释

    # 1. 使用自带容器
    # server ur-plugin-example-server:12008 weight=1 max_fails=2 fail_timeout=30s;

    # 2. 在本地编译
    # 访问宿主机的端口(根据本地的docker选择以下一项)
    # https://stackoverflow.com/questions/31324981/how-to-access-host-port-from-docker-container
    # For macOS and Windows

    #
    # Docker v 18.03 and above
    # server host.docker.internal:12008 weight=5 max_fails=2 fail_timeout=1s;

    #
    # Docker for Mac v 17.12 to v 18.02
    # server docker.for.mac.host.internal:12004 weight=5 max_fails=2 fail_timeout=1s;

    # Docker for Mac v 17.06 to v 17.11
    # server docker.for.mac.localhost:12004 weight=5 max_fails=2 fail_timeout=1s;
  3. 完成第2步后,使用命令 docker restart tgw 重启 Docker-Compose 中的 tgw 容器

2. 新增服务器端接口

当浏览器端需要新的 HTTP API 时,可通过此方法进行新增 API

  1. 开发 HTTP 服务,并在本地启动
  2. 修改私有化部署中的文件 tgw/nginx/conf/nginx_htdocs/server.conf ,根据需求新增 API 前缀,修改 Nginx 配置文件,使用 location 语法将请求进行统一转发