Bring Your Own Code #BYOC

Take advantage of nanoscale.io's powerful serverless architecture while continuing to leverage your existing programming language skills with Docker images



 

Using Docker Images to Run Custom Code in Nanoscale.io

 
W ouldn’t it be awesome if you could build and deploy microservices, web hooks, or functions-as-a-service with the ease that nanoscale.io provides, while also being able to run your own business logic source code written in any programming language? Now you can, with Docker Remote Endpoints.

With the latest release of nanoscale.io, you can build a microservice that executes Docker containers running programs you created in virtually any programming language or framework (e.g., Ruby, Java, PHP, Node.js, Python, GoLang, Lua, C#, etc.). Your containerized program can be invoked within your microservice either synchronously via a Proxy Endpoint, or asynchronously as a Background Job. You can use this capability to extend your microservice with new business logic written in your language of choice, or execute code that may be part of an existing monolithic application you want to reuse.

Here are the steps to execute custom function code using nanoscale.io cloud:

  1. Create your program in your language of choice (refer to guidelines for programs to run in Docker containers below)
  2. Create a Docker image with your program plus any dependencies, and upload it to a Docker registry such as Docker Hub
  3. Create a Remote Endpoint in nanoscale.io that points to the Docker image
  4. Create a Proxy Endpoint or Background Job and call the Docker Remote Endpoint at the appropriate step in your workflow (you can execute specific commands to start your program)

And you’re done! When your microservice runs, nanoscale.io will create an instance of your program in a container and execute it in our Docker Swarm, automatically managing scalability and resources to ensure it runs smoothly. If you have deployed nanoscale.io in your infrastructure, you need to set up a Docker Swarm to execute the Docker images (contact us via http://support.nanoscale.io for more information or assistance).

We provide Docker image code samples and a brief video to help you get started on how to create Docker Remote Endpoints in nanoscale.io:
http://devhub.nanoscale.io/docs/using-docker-remote-endpoints

 

 

Note that your containerized code will run in a “stateless” manner, only for the duration of the microservice instance, so keep in mind the following guidelines for programs to run in Docker containers:

  • Treat all operations that run in the Docker container as transient (i.e., keep it to business logic)
  • Assume your programs will be interacted with via stdin and stdout at the command line (i.e., calling a Java program via Java’s public static void main(String args[]))
  • Rely on nanoscale.io to handle external integrations and data persistency (i.e., don’t save data within the Docker image)
  • Keep your Docker images lean and keep runtime overhead under 256MB (for better scalability and performance)
  • Keep in mind your timeout limits based on your nanoscale.io plan

 
A few additional notes on running custom code in Docker images on nanoscale.io:

  • Supports “Docker Hub” as the default Docker registry, but any other registries running the Docker Registry HTTP API V2 should work
  • Supports non-public or private Docker registries for secured and Enterprise use cases
  • You can use the latest or any prior versions of your registered Docker images
  • You can specify individual commands to be executed on your Docker images
  • You can further customize the requests and responses of your function in the microservice workflow JavaScript (eg. starting your program with input parameters from an API request)

 
Take advantage of nanoscale.io’s powerful serverless architecture while continuing to leverage your existing programming language skills to develop micoservices.

Take advantage of nanoscale.io’s powerful serverless architecture while continuing to leverage your existing programming language skills…