Autopilot Pattern Touchbase
This repo is a demonstration of a multi-tier application with Node.js, Couchbase, and Nginx, designed to be self-operating according to the autopilot pattern. This application also demonstrates Triton Container Name Service, an automated DNS that makes it easy to address Docker containers on the internet.
- Touchbase, a Node.js application
- Nginx, acting as a load balancer for Touchbase nodes
- Couchbase, for the data tier
- Consul, acting as a service catalog to support discovery
- ContainerPilot, to help with service discovery
- Triton, Joyent's container-native infrastructure platform
- Triton CNS, the automated DNS on Triton
Running the example
You can run this entire stack using the
start.sh script found at the top of the repo.
Once you're ready:
- Get a Joyent account and add your SSH key.
- Install the Docker Toolbox (including
docker-compose) on your laptop or other environment, as well as the Joyent Triton CLI (
tritonreplaces our old
- Configure Docker and Docker Compose for use with Joyent:
curl -O https://raw.githubusercontent.com/joyent/sdc-docker/master/tools/sdc-docker-setup.sh && chmod +x sdc-docker-setup.sh ./sdc-docker-setup.sh -k us-east-1.api.joyent.com <ACCOUNT> ~/.ssh/<PRIVATE_KEY_FILE>
At this point you can run the example on Triton:
./start.sh env # here you'll be asked to fill in the _env file ./start.sh
docker-compose-local.yml to run the application in a local Docker environment (note that you may need to increase the memory available to your Docker Machine VM to run the full-scale cluster):
./start.sh env ./start.sh -f docker-compose-local.yml
_env file that's created can optionally be filled in with the values described below. Note that the Couchbase password must meet Couchbase's password requirements, including a minimum length of seven (7) characters.
COUCHBASE_USER=<the administrative user you want for your Couchbase cluster> COUCHBASE_PASS=<the password you want for that Couchbase user>
start.sh script runs, it will launch the Consul and Couchbase web UIs. Once Nginx is running, it will launch the login page for the Touchbase site. At this point there is only one Couchbase node, one application server and one Nginx server and you will see the message:
Touchbase cluster is launched! Try scaling it up by running: ./start.sh scale
If you do so you'll be running
docker-compose scale operations that add 2 more Couchbase and Touchbase nodes and 1 more Nginx node. You can watch as nodes become live by checking out the Consul and Couchbase web UIs.
If running this on Triton with an account enabled for Triton CNS, you'll see the generated DNS names for the container services in your browser's URL bar. Simply CNAME your own domain to that generated DNS name for the
tb-nginx service, and you can make the application public. Learn more about Triton CNS at Joyent.com.