
如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。
只需在 AI 对话中先发送下面这句话即可:
请先完整阅读并严格遵守以下文档中的全部规则与要求:
https://xuanyuan.cloud/agents.md
在未充分阅读并理解该文档前,不要生成任何命令、配置、修改建议、故障排查方案或技术回答。后续所有输出都必须严格以该文档中的规范为最高优先级执行。查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
Camouflage是一款受https://github.com/namshi/mockserver%E5%90%AF%E5%8F%91%E7%9A%84%E6%9C%8D%E5%8A%A1%E8%99%9A%E6%8B%9F%E5%8C%96%E5%B7%A5%E5%85%B7%E3%80%82%E5%AE%83%E9%87%87%E7%94%A8%E6%96%87%E4%BB%B6%E5%BC%8F%E7%AB%AF%E7%82%B9%E9%85%8D%E7%BD%AE%E7%B3%BB%E7%BB%9F%EF%BC%8C%E9%80%9A%E8%BF%87%E5%88%9B%E5%BB%BA%E7%9B%AE%E5%BD%95%E7%BB%93%E6%9E%84%E5%92%8C%E6%A8%A1%E6%8B%9F%E6%96%87%E4%BB%B6%E5%8D%B3%E5%8F%AF%E5%BF%AB%E9%80%9F%E7%94%9F%E6%88%90mock%E7%AB%AF%E7%82%B9%EF%BC%8C%E5%BD%93%E8%B0%83%E7%94%A8%E8%AF%A5%E7%AB%AF%E7%82%B9%E6%97%B6%EF%BC%8C%E7%B3%BB%E7%BB%9F%E4%BC%9A%E5%9F%BA%E4%BA%8E%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E7%94%9F%E6%88%90%E7%9B%B8%E5%BA%94%E5%93%8D%E5%BA%94%E3%80%82%E4%B8%BB%E8%A6%81%E7%94%A8%E4%BA%8E%E5%BC%80%E5%8F%91%E6%B5%8B%E8%AF%95%E9%98%B6%E6%AE%B5%E6%A8%A1%E6%8B%9F%E5%90%8E%E7%AB%AF%E6%9C%8D%E5%8A%A1%EF%BC%8C%E6%94%AF%E6%8C%81HTTP%E3%80%81HTTPS%E3%80%81HTTP2%E3%80%81gRPC%E5%8F%8AWebsockets%E7%AD%89%E5%A4%9A%E7%A7%8D%E5%8D%8F%E8%AE%AE%EF%BC%8C%E5%B8%AE%E5%8A%A9%E5%89%8D%E7%AB%AF%E5%BC%80%E5%8F%91%E3%80%81API%E6%B5%8B%E8%AF%95%E7%8B%AC%E7%AB%8B%E4%BA%8E%E7%9C%9F%E5%AE%9E%E5%90%8E%E7%AB%AF%E6%9C%8D%E5%8A%A1%E8%BF%9B%E8%A1%8C%E3%80%82
camouflage init和camouflage restore模块快速搭建环境bashnpm install -g camouflage-server
bashcamouflage --version
该命令会生成基础目录结构,可根据需求修改bashcamouflage init
bashcamouflage --config config.yml
yamlloglevel: info # 日志级别:info/warn/error/debug cpus: 1 # 使用的CPU核心数 monitoring: port: 5555 # 监控端口 ssl: cert: "./certs/server.cert" # SSL证书路径 key: "./certs/server.key" # SSL密钥路径 protocols: http: enable: true # 是否启用HTTP mocks_dir: "./mocks" # HTTP模拟文件目录 port: 8080 # HTTP端口 https: enable: false # 是否启用HTTPS port: 8443 # HTTPS端口 http2: enable: false # 是否启用HTTP2 port: 8081 # HTTP2端口 ws: enable: false # 是否启用Websockets mocks_dir: "./ws_mocks" # WebSockets模拟文件目录 port: 8082 # WebSockets端口 grpc: enable: false # 是否启用gRPC host: localhost # gRPC主机 port: 4312 # gRPC端口 mocks_dir: "./grpc/mocks" # gRPC模拟文件目录 protos_dir: "./grpc/protos" # gRPC协议文件目录 backup: enable: false # 是否启用备份 cron: "0 * * * *" # 备份定时任务(每小时) cache: enable: false # 是否启用缓存 ttl_seconds: 300 # 缓存过期时间(秒) injection: enable: false # 是否启用注入功能 ext_helpers: "./custom_handlebar.json" # 外部辅助函数文件路径(无需时可移除) origins: # 允许的跨域源 - http://localhost:3000/ - http://localhost:3001/ - http://localhost:5000/
以创建/hello-world端点为例:
${MOCKS_DIR}(配置文件中protocols.http.mocks_dir指定的目录,默认为./mocks)下创建目录:
bashmkdir -p ./mocks/hello-world
GET.mock文件:
bashtouch ./mocks/hello-world/GET.mock
GET.mock文件,添加以下内容:
HTTP/1.1 200 OK X-Custom-Header: Custom-Value Content-Type: application/json { "greeting": "Hey! It works!" }
Docker Run命令
bashdocker run -d \ -p 8080:8080 \ -v $(pwd)/mocks:/app/mocks \ -v $(pwd)/config.yml:/app/config.yml \ --name camouflage \ docker.xuanyuan.run/camouflage-server \ camouflage --config /app/config.yml
Docker Compose配置
yamlversion: '3' services: camouflage: image: docker.xuanyuan.run/camouflage-server ports: - "8080:8080" - "5555:5555" # 监控端口 volumes: - ./mocks:/app/mocks - ./config.yml:/app/config.yml command: camouflage --config /app/config.yml restart: unless-stopped
欢迎通过以下方式贡献:
详细贡献指南请参考https://github.com/testinggospels/camouflage/blob/main/CONTRIBUTING.md%E3%80%82
bashgit clone https://github.com/testinggospels/camouflage.git
bashgit checkout develop
bashnpm install
bashnpm build
bashnode bin/camouflage.js --config ./config.yml
bashnpm pack npm install -g camouflage-server-0.0.0-development.tgz
MIT License Copyright (c) 2021 testinggospels Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务