You're reading Mocko v1 (legacy) documentation. Mocko v2 is the current version. View the v2 docs.

Deploying

Get Mocko running on the internet so you can access it from anywhere, not just your local machine.

Standalone mode: Docker

To run Mocko with as few resources as possible, build a container image using gabrielctpinheiro/mocko-proxy as a base. Create this structure:

mocko-project
├── Dockerfile
└── mocks
    └── main.hcl

In your Dockerfile:

FROM 'gabrielctpinheiro/mocko-proxy'
COPY ./mocks ./mocks

To override settings, set environment variables in the Dockerfile:

FROM 'gabrielctpinheiro/mocko-proxy'
COPY ./mocks ./mocks
ENV PROXY_BASE-URI=https://my-real-api.tld/v1

All available environment variables and their defaults are listed in mocko-proxy/default.env.

Complete stack on Kubernetes with Helm

Install the complete stack (proxy + control UI + Redis) in your cluster with three commands.

Helm 3:

$ git clone https://github.com/mocko-app/mocko.git
$ cd mocko

$ helm install mocko ./mocko-helm --set \
redis.host=YOUR.REDIS.HOST,\
redis.password=YOUR_REDIS_PASSWORD,\
proxy.uri=http://your-real-api.url/v1

Helm 2:

$ git clone https://github.com/mocko-app/mocko.git
$ cd mocko

$ helm install ./mocko-helm -n mocko --set \
redis.host=YOUR.REDIS.HOST,\
redis.password=YOUR_REDIS_PASSWORD,\
proxy.uri=http://your-real-api.url/v1

Other chart values you may want to configure:

Chart valueDescriptionDefault
proxy.uriURL of your actual API to proxy; leave blank to disableblank
proxy.timeoutMillisMilliseconds before replying with 504 Gateway Timeout180000
proxy.corsOverride CORS rules (true) or proxy OPTIONS to the API (false)true
proxy.replicasNumber of proxy replicas1
redis.hostRedis hostredis-headless.default.svc.cluster.local
redis.portRedis port6379
redis.passwordRedis passwordblank
redis.databaseRedis database index0