Skip to main content

Configuration Guide

Introduction

This page describes the available configuration options for Mockdoor. Configuration can be done via environment variables or updating the appsettings.json files in the source code.

Configuration Structure

"DeploymentConfiguration": {
   "PathBase": "/dev/mockdoor/",
   "SeedOnStartup": null,
   "ForceHttps": false,
   "Debug": false,
   "DebuggerUrl": "https://localhost:7275/dev/mockdoordebugger/debug/default/",
   "DatabaseConfig": {
     "Provider": 2,
     "ConnectionString": "Data Source=Data/mockdoor.debug.db;"
   }
}

Above shows the configuration options available. To set them in an environment varaible use the format "Parent__Child__Property=Value" for example to set the PathBase to "/test/path/" you would put the environment variable DeploymentConfiguration__PathBase=/test/path/".

Docker example

For docker you can set the environment variable using the -e argument when running the container. For example to run the container with the above configuration and also setting the "SeedOnStartup=Data/DemoSampleData.json" you would run the following command

docker run -d -p 44304:80 --name mockdoor -e DeploymentConfiguration__PathBase=/test/path/ -e DeploymentConfiguration__SeedOnStartup=Data/DemoSampleData.json" mockdoor/server


Configuration Details

Property Environment Variable Path Description Example Default
PathBase DeploymentConfiguration__PathBase Sets a custom base path, this changes the path used to access Mockdoor. For example if /test/path/ is used then instead of accessing Mockdoor homepage at https://localhost:44304 you access it from https://localhost:44304/test/path/. This is useful for when Mockdoor is behind a reverse proxy or in a K8 container and is not running on the base address. "/test/path/" /
SeedOnStartup DeploymentConfiguration__SeedOnStartup Sets a json database import file to import during startup. This must be added to the Mockdoor Server project in order to be accessible. There is a sample file under the Data folder called DemoSampleData.json Data/DemoSampleData.json null
ForceHttps DeploymentConfiguration__ForceHttps If true, this forces all request to Mockdoor to redirect to the https standard true false
Debug DeploymentConfiguration__Debug Sets if Mockdoor enables its additional debugging and diagnostics features. If true additional diagnostics page(s) will be enabled when errors occured. This can also affect the level of detail in some error messages in the UI true true when running in debug mode and false if not
DebuggerUrl DeploymentConfiguration__DebuggerUrl This is currently a unsupported feature that allows Mockdoor to send the Live feed feature to an external debugger application. This application has not been released as it does not add to Mockdoor anymore (since the Livefeed is now embedded). This may be improved and updated in the future but for now that makes this setting not useful. https://localhost:7275/debug/ null
Provider DeploymentConfiguration__DatabaseConfig__Provider Defines which database provider to use, 1 = Microsoft SQL Server, 2 = Sqlite 1 null
ConnectionString DeploymentConfiguration__DatabaseConfig__ConnectionString The database connection string to use. Must be the correct format for the provider specified Data Source=Data/mockdoor.debug.db; Data Source=Data/mockdoor.debug.db;

Startup Configuration Diagnostics

During startup the connection string will be tested. If it finds the database it not on the latest version if will list the pending changes (migrations) and ask you to apply them. For new installs or when pointing to a new databse this will always appear the first time you run Mockdoor.

Mockdoor will also Create the database if it does no exist so long as the connection string provided has sufficient permissions to do so. If the connection string fails for any reason and Debug mode is enabled a connection string debugging page appears. Here you can test the connection string in the UI by changing it directly to test the connection until it works. This does not support persisting the configuration so once a working connection string is found you could copy it into the environment variable or appsettings, replacing the bad connection string.


diagnostics screen
Fig.1 - Diagnostic page on invalid database connection string
diagnostics screen
Fig.2 - Diagnostics page on fixing connection string