How to persist APIs After Restart of Gateway

We are installing Tyk Gateway via Docker, the question is… is there a way to preserve all of the APIs, Policies, Keys, etc if the container crashes?

Hello @billo-lm and welcome to the community.

Yes, you can use docker shared volumes or use SCM with CI/CD as mentioned on the thread

If you are using shared volumes and docker compose, then you should have something like this

services:
  tyk-gateway
    image: tykio/tyk-gateway:v3.1.2
    ports: 
      - '8080:8080'
      - '8081:8081'
    volumes:
      - './apis:/opt/tyk-gateway/apps'
      - './certs:/opt/tyk-gateway/certs'
      - './confs/gateway.conf:/opt/tyk-gateway/tyk.conf'
      - './policies/policies.json:/opt/tyk-gateway/policies/policies.json'
      - './middleware:/opt/tyk-gateway/middleware'

The setup above should preserve your API definition and policies as long as you have also setup file based mode for the APIs and policy in the gateway config file

{
  "app_path": "/opt/tyk-gateway/apps/",
  "policies": {
    "policy_source": "file",
    "policy_record_name": "/opt/tyk-gateway/policies/policies.json"
  }
}

As for setting up persistent storage with your keys, this thread some good information.

Hope this helps

1 Like

Yeah that makes a ton of sense… and with EFS makes it super easy… don’t know why I didn’t think of that!!!

Thanks so much!!!