标签:build one 服务 debug mirror erro 图片 number java
以前有写过简单的容器集成,以下是关于s3集成的,主要是测试数据的捕捉以及回放
简单说明
gor 与openresty 部署在一起,为了方便基于supervisord 管理,默认已经开启请求捕捉(80端口),同时supervisord集成了管理,可以通过ui操作是否捕捉
对于捕捉的数据存储在minio s3中,如果需要回放操作,我们直接可以基于gor tools 将存储的数据回放给需要测试的服务
version: "3"
services:
minio:
image: minio/minio
command: server /data
volumes:
- "./data:/data"
ports:
- "9000:9000"
environment:
- "MINIO_ACCESS_KEY=minio"
- "MINIO_SECRET_KEY=minio123"
api:
image: dalongrong/openresty-gor:s3
build:
dockerfile: ./Dockerfile-openresty
context: ./
privileged: true
cap_add:
- ALL
volumes:
- "./supervisor.conf:/etc/supervisord.conf"
- "./nginx.conf:/usr/local/openresty/nginx/conf/nginx.conf"
- "./demoapps:/opt/demoapps"
- "./capture:/app/capture"
- "./logs/access-test.log:/usr/local/openresty/nginx/logs/access-test.log"
ports:
- "80:80"
- "8080:8080"
- "9001:9001"
[program:website]
command = /usr/local/openresty/bin/openresty
[inet_http_server]
port = :9001
?
[program:gor]
# 此处需要指定关于s3 的配置
environment=AWS_ACCESS_KEY_ID="minio",AWS_SECRET_ACCESS_KEY="minio123",AWS_REGION="demo",AWS_ENDPOINT_URL="http://minio:9000",AWS_DEBUG="true"
stdout_logfile = gor.log, /dev/stdout
command = gor --input-raw :80 --output-file s3://logs/%Y-%m-%d-%H-%M.gz
FROM openresty/openresty:alpine
ENV PATH=$PATH:/app
RUN /bin/sed -i ‘s,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g‘ /etc/apk/repositories
ENV TZ Asia/Shanghai
RUN apk add --update --no-cache \
tzdata && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
COPY --from=dalongrong/gor /app/gor /app/gor
COPY --from=ochinchina/supervisord:latest /usr/local/bin/supervisord /usr/local/bin/supervisord
EXPOSE 9001 8080 80
COPY supervisor.conf /etc/supervisor.conf
CMD ["/usr/local/bin/supervisord"]
docker-compose up -d
我使用了本地工具,同时注意需要配置关于s3的信息
export AWS_ACCESS_KEY_ID=minio
export AWS_REGION=demo
export AWS_SECRET_ACCESS_KEY=minio123
export AWS_ENDPOINT_URL=http://127.0.0.1:9000
export AWS_DEBUG=true
./gor-mac --input-file s3://logs/2020-07-20-10-19_13.gz --output-http "http://localhost"
对于回放效果的查看可以通过查看openresty 的log
mountebank(可以mock http,https,tcp,smtp),diffy (请求比较,主要是http)
hoverfly 一个不错的流量处理工具,nginx 的mirrror也是一个不错的选择
以上只是一个简单的集成试用,实际如果我们需要基于捕捉的数据进行业务操作回放,还有好多事情需要做
https://github.com/buger/goreplay
https://github.com/opendiffy/diffy
https://github.com/bbyars/mountebank
https://github.com/spectolabs/hoverfly
https://github.com/rongfengliang/openresty_rewrite_static/tree/gor
标签:build one 服务 debug mirror erro 图片 number java
原文地址:https://www.cnblogs.com/rongfengliang/p/13344164.html