wiremock / wiremock-docker

Wiremock Docker image
https://hub.docker.com/r/wiremock/wiremock
MIT License
223 stars 102 forks source link

Hot reloading of mappings #35

Closed sonOfRa closed 4 years ago

sonOfRa commented 4 years ago

Wiremock itself doesn't contain functionality to automatically reload mappings if they change on the file system.

However, there is an endpoint POST __admin/mappings/reset to reload mappings on demand.

This could be used in two ways to trigger reloading:

1) Run a shell script with a configurable refresh interval that POSTs to that endpoint 2) Run an inotify-check shell script that fires a POST to that endpoint whenever the mappings folder changes.

Our use case for this is that we are using the container in a local dev environment, and the mappings folder is a bind mount into the container. Would you be interested in either of those possibilities being included in the docker images (would require to install inotify-tools and curl, or just curl if the interval method is used).

Currently, we just launch an additional container in our compose file that hits the endpoint every few seconds:

FROM alpine:3.12.0
RUN apk add --no-cache curl
CMD while true; do sleep 5; curl -XPOST http://wiremock:8080/__admin/mappings/reset; done
rodolpheche commented 4 years ago

This repository only handles the Wiremock Docker image build and deployment based on the official Wiremock product.

If you want to suggest a new feature on it, you may do it on the official repository. Although, an issue has already been opened : https://github.com/tomakehurst/wiremock/issues/1243

sonOfRa commented 4 years ago

Yeah, I'm aware this is "only" the docker image. I opened the issue here because I figured it would be useful in the context of the docker image, even if upstream does not have a hot reloading feature.

rodolpheche commented 4 years ago

I understand your need but I want to stay coherent with the official repository