PolySwarmPolySwarmPolySwarmPolySwarm
Go to PolySwarm
Home

Setting Up Your Web Service Component

Engines need an HTTP server to receive Webhooks. This server needs to be WSGI-compatible to run the Flask app in microengine-webhooks-py. In addition, the server needs to accessible at a fully qualified domain name (FQDN), and support HTTPS requests.

Running a Webservice using Nginx Unit

The example project, microengine-webhooks-py uses Nginx Unit as a webserver. Nginx Unit is preconfigured in the nginx/ directory for servicing engines built with microengine-webhooks-py.

For more information about Nginx Unit, visit the Nginx Unit website.

Running the webserver is simple with the included Dockerfile. Use our trusty Terminal to run the following docker-compose command:

(psvenv) $ docker-compose -f docker/docker-compose.yaml up --build --no-deps microengine-webhooks

Now, we have a running webserver, so we need to make it accessible on a public IP at a FQDN using HTTPS.

Making our webservice publicly available over HTTPS using Ngrok

The basic requirements that we need to support are to allow PolySwarm to send webhooks to our webservice using:

  1. A FQDN
  2. HTTPS
  3. On a publicly accessible IP address

There are a number of ways you can support these requirements.

As one example, you could run your web service in a hosting provider like AWS, use the elastic IP to get a FQDN and use nginx to support HTTPS with certbot managing SSL certificates.

Meeting these requirements may seem daunting at first, especially if you don't have anywhere to run a server. Don't despair, to make these instructions simple, you can use ngrok to run your web server locally without setting up your own SSL certificates. ngrok allows you to make a service, running in your local environment, publicly accessible using a FQDN with support for HTTPS. Visit the ngrok homepage for setup and installation instructions.

ngrok is for testing only!

Production deployments must use a properly registered domain name, valid SSL certificates, and a web hosting solution that can host your web service to make it accessible at a public IP address over HTTPS. We discuss production deployment steps later in the documentation.


Next Steps

Next, we need to create your engine in the PolySwarm UI.

2024 © PolySwarm Pte. Ltd.