doc.dev1x.org

hoverflyをdocker-composeで動かしてみる

1. hoverflyとは

2. 特徴

3. セットアップ

version: '3.8'
services:
  hoverfly:
    container_name: hoverfly
    image: spectolabs/hoverfly:latest
    entrypoint:
      [
        "/bin/hoverfly",
        "-listen-on-host=0.0.0.0"
      ]
    ports:
      - 8500:8500
      - 8888:8888
$ docker compose up

4. モックサーバの構成

$ curl -i http://localhost:8500

HTTP/1.1 500 Internal Server Error
Content-Type: text/plain; charset=utf-8
X-Content-Type-Options: nosniff
Date: Sat, 11 Nov 2023 16:25:41 GMT
Content-Length: 64

This is a proxy server. Does not respond to non-proxy requests.
version: '3.8'
services:
  hoverfly:
    container_name: hoverfly
    image: spectolabs/hoverfly:latest
    entrypoint:
      [
        "/bin/hoverfly",
        "-listen-on-host=0.0.0.0",
        "-import=/data/hoverfly.io.json",
        "-webserver"
      ]
    ports:
      - 8500:8500
      - 8888:8888
    volumes:
      - type: bind
        source: "."
        target: "/data"
$ tree
.
├── docker-compose.yaml
└── hoverfly.io.json
$ curl -i http://localhost:8500

HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: max-age=3600
Connection: keep-alive
Content-Type: text/html; charset=utf-8
Date: Tue, 30 May 2017 13:23:09 GMT
Etag: "82b6bafbc0c4af5e3886d07802f4b62d"
Hoverfly: Was-Here
Last-Modified: Fri, 19 May 2017 10:59:12 GMT
Server: nginx
Strict-Transport-Security: max-age=31556926
Vary: Accept-Encoding
Via: 1.1 varnish
X-Cache: HIT
X-Cache-Hits: 1
X-Powered-By: Express
X-Served-By: cache-lhr6323-LHR
X-Timer: S1496150589.426034,VS0,VE0
Transfer-Encoding: chunked

trololou

参考資料