Load Python Bundle right away from the local file system rather than an HTTP server

Hi,
I am actually bit new to Tyk. I was wondering if is it possible to use my python plugin directly from the tyk-gateway container filesystem. Instead of that currently I want to spin up an entire http server to serve this plugin bundle. Unfortunately I didn’t find any related documentation. A reply will be greatly appreciated.

BTW, I intend to deploy the system as a container

No worries!
I did some “code reading”. As mentioned over here , there is no explicit mechanism to directly load bundles from diskspace, but a caching mechanism is there, and we can utilize it. (the code works for v5.1.

The steps are as follows,

  1. find the md5sum of the custom_middleware_bundle name we have specified at app config. I used this handy command printf $(BUNDLE_NAME) | md5sum -z | cut -d ' ' -f 1 (replace the bundle name accordingly)
  2. then create the bundle, and unzip it into /opt/tyk/middleware/bundles/<md5sum of bundle name>/
  3. at the end make sure there is this files /opt/tyk/middleware/bundles/<md5sum of bundle name>/manifest.json and the remaining files from the bundle zip, at the destination.

NB: if you insist one can remove the bundling part with simply copying the source files and manifest.json over there.

Thank you!

Hi,

I was wondering if is it possible to use my python plugin directly from the tyk-gateway container filesystem.

This should be possible but currently isn’t. We have an internal defect to get it fixed. Until it’s picked up the only option is to use bundles.

find the md5sum of the custom_middleware_bundle name we have specified at app config. I used this handy command printf $(BUNDLE_NAME) | md5sum -z | cut -d ' ' -f 1 (replace the bundle name accordingly)

Nice work! Yeah, Tyk depends on the bundle file name changing whenever its contents change so that it knows when to check against the http server for an update.

Bear in mind that the http server only needs to run when there is a change to the bundle file name so it can be down almost all of the time. But you’ve found a nice work around!

Cheers,
Pete

1 Like