A hands-on guide to deploying your first application with Acorn.
NATS is a lightweight, high-performance messaging system for cloud-native applications, IoT messaging, and microservices architectures, known for its simplicity, scalability, and reliability. It is open source, and part of the CNCF.
We're going to deploy NATS in Acorn where you can easily deploy it and connect your app to it. The Acornfile used to create a NATS based Acorn Service is available in the GitHub repository at https://github.com/acorn-io/nats. This service triggers the creation of a NATS message broker running in a single container which can easily be used by an application during development.
This NATS instance generates a password for the admin user, allowed to publish and subscribe to any subjects (>)
The Acorn image of this service is hosted in GitHub container registry at ghcr.io/acorn-io/nats
The examples folder contains the Acornfile of the VotingApp microservice application modified in the way that is uses NATS pub/sub mechanism instead of Redis/Worker/Postgres to propagate votes from the Vote UI to the Result UI. The screenshot below shows both interfaces.
To use this Service, we first define a service property in the Acornfile of the application:
Note: the service is built first if in development mode
Next we define the application containers, both vote and result containers need to connect to NATS so we only give those ones the NATS_URL they need to use. Below is the definition of the vote container:
This example can be run with the following command (to be run from the examples folder)
After a few tens of seconds the http endpoints will be returned allowing to access both vote and result web interfaces.
Instead of managing your own Acorn installation, you can deploy this application in the Acorn cloud, the free SaaS offering provided by Acorn. Access to the platform requires only a GitHub account, which is used for authentication.
An application running in the Acorn as a free instance will automatically shut down after 2 hours, but you can always run a persistent instance if you need to run it longer.