jlaurila / SoapUI-MockService-Docker-image

An extensible docker image for running a Mock-Service with SOAP-UI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SoapUI Mock-Service Docker image

This project builds a docker container for running a Mock-Service with SOAP-UI

    $ docker build -t fbascheper/soapui-mockservice-runner .

Running the image

You can run the mock-service container interactively with the following command:

    $ docker run -P -it --rm -e MOCK_SERVICE_NAME=BLZ-SOAP11-MockService  <<image-id>>

    $ docker run -P -it --rm \
        -e MOCK_SERVICE_NAME=BLZ-SOAP11-MockService \
        -e MOCK_SERVICE_PATH=/BLZMockService \
        -e PROJECT=/home/soapui/soapui-prj/default-soapui-project.xml \
         <<image-id>>

And of course you can also run it as a daemon, e.g. using:

    $ docker run --name soapui-daemon -d -e MOCK_SERVICE_NAME=BLZ-SOAP11-MockService  <<image-id>>

Mounting a local directory

Thanks to Jun SAITO it is also possible to mount a host directory and deploy a mock service in a locally stored SoapUI project XML file. The example below demonstrates this by downloading the SoapUI project in the docker image in a newly created soapui-test-project directory of the $HOME directory.

    $ mkdir -p $HOME/soapui-test-project
    $ cd $HOME/soapui-test-project 
    $ wget https://raw.githubusercontent.com/fbascheper/SoapUI-MockService-Docker-image/master/soapui-prj/default-soapui-project.xml

    $ docker run -P -it --rm \
        -p 8080:8080 \
        -v "$HOME/soapui-test-project:/home/soapui/soapui-prj/" \
        -e MOCK_SERVICE_NAME="BLZ-SOAP11-MockService" \
        -e PROJECT=/home/soapui/soapui-prj/default-soapui-project.xml \
        --privileged \
         <<image-id>>

If all goes well, you should now be able to access the WSDL at the location http://localhost:8080/BLZ-SOAP11-MockService?WSDL

Supported environment variables

The following environment variables are supported:

Name Required Default value Description
MOCK_SERVICE_NAME YES Empty Name of the mock service in the SoapUI project file
MOCK_SERVICE_PATH NO Empty Path used to publish the mock service, if empty the path in the SoapUI project file is used
PROJECT NO /home/soapui/soapui-prj/default-soapui-project.xml The complete path to the SoapUI project file

Creating mock services based on this image

The extension-mechanism works in the same fashion as the postgresql docker image, i.e. by adding your own shell script in the docker-entrypoint-initdb directory. But as a rule this should not be necessary.

The best practice for creating a new image is to add your own SoapUI project in the soapui-prj directory and reference this project using the supported environment variables.

About

An extensible docker image for running a Mock-Service with SOAP-UI

License:Apache License 2.0


Languages

Language:Dockerfile 56.4%Language:Shell 43.6%