Deploying
Now that you know how to use Mocko, let's get it running in the internet so you can access it from anywhere, not only your computer.
The free, easiest and quickest way
Click the button below to deploy the app to glitch.com, it's free and you don't need to register:
Wait until the app is deployed (check Logs
in the bottom) and access it with the URL provided in the Preview
button also in the bottom.
In the files drawer on the left, you can change the mocks inside the mocks
folder and they'll update in real time, check our Getting Started guide for usage.
To one-click deploy to other PaaS providers like Heroku or DigitalOcean's App Platform, check mocko-example's README.md
.
Standalone mode
Our CLI is cross-platform so you could easily install it in a VPS or container. However, its additional development features (like watch mode, the CLI itself, update checking) make it less lightweight than running mocko-proxy itself.
To run Mocko using as little resources as possible, you can create a container
image with your mocks and gabrielctpinheiro/mocko-proxy
as a base. Create a file
structure like so:
mocko-project
├── Dockerfile
└── mocks
└── main.hcl
Inside Dockerfile
put:
FROM 'gabrielctpinheiro/mocko-proxy'
COPY ./mocks ./mocks
And in the mocks
folder you can create your mock definitions, check our Getting Started guide for usage.
To change Mocko settings you can define envionment variables in your Dockerfile
like so:
FROM 'gabrielctpinheiro/mocko-proxy'
COPY ./mocks ./mocks
ENV PROXY_BASE-URI=https://my-real-api.tld/v1
You can check all the available and default values here:
https://github.com/mocko-app/mocko/blob/master/mocko-proxy/default.env
Complete stack on Kubernetes with Helm
You can easily install Mocko complete stack (with just three commands) in your cluster using Helm:
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
The other chart values you might want to change are:
Chart Value | Description | Default |
---|---|---|
proxy.uri | URL of your actual API which will be proxied by mocko, leave it blank to disable proxying | blank |
proxy.timeoutMillis | Milliseconds to wait for a response before replying with 504 Gateway Timeout | 180000 |
proxy.cors | Set to true to override the cors rules defined by the API. Set to false to proxy OPTIONS requests to the API | true |
proxy.replicas | Number of proxy replicas | 1 |
redis.host | Redis host | redis-headless.default.svc.cluster.local |
redis.port | Redis port | 6379 |
redis.password | Redis password | blank |
redis.database | Redis database | 0 |