Pipelines for Applications

Use Pipelines to call any CLI or API during builds or deploys.

Before you begin the tutorial you must:

  • Install the Pipelines CLI on the development system. Installing the CLI
  • Ensure git is installed on the development system. Download Git
  • Have a destination server available to deploy software to.
  • Install the Pipelines agent on the destination server. Installing the agent

This tutorial is an exercise in implementing the Joyent triton implementation in this repository https://github.com/autopilotpattern/wordpress with Pipelines.

“This project uses the Autopilot Pattern to automate operations, including discovery and configuration, for scaling to any size. All component containers use ContainerPilot and Consul to configure themselves. This also allows each service to be scaled independently to handle incoming traffic and as more services are added, the containers that consume these services will reconfigure themselves accordingly.”

That is a quote from the repository Readme. There are a several advanced options described in the repository, that this tutorial does not cover, but can easily be extended to those advanced configurations.

Ultimately, this will create a Wordpress service accessible to the public.

Create a Joyent Account

To implement this tutorial, you must have an account in Joyent. You can create one here. You must have a paid account for the features in this tutorial.

Create Manta Bucket

You must first setup a Manta “directory” or “bucket” to store information. I recommend creating this “bucket” in the stor directory. See the Manta Docs for more information.

Setup a Build Server

To complete this tutorial, you must next setup a Pipelines build server. You can follow the steps here.

Install Prerequisites

On the build server you will have to install prerequisites. These should distinctly be installed under the distelli user account. One way to ensure the prerequisites are installed under the distelli account is to switch user to the distelli account like this:

sudo su - distelli

Install Docker and Docker-Compose

As the distelli user, on the build server, you must install Docker. Instructions for installing Docker can be found here.

The distelli user should have full access to the docker daemon. This can be accomplished by adding the distelli user to the docker group. Note, you must restart the distelli supervise process after adding it to the docker group.

sudo distelli supervise stop
sudo distelli supervise start

Install NodeJS and NPM

This example uses Joyent triton. To install triton, you must first install nodejs. The following exemplifies installing nodeJS on Ubuntu 16.04.

sudo apt install -y nodejs npm
sudo ln -s /uar/bin/nodejs /usr/bin/node

Install Triton, Smartdc, and Json

sudo npm install -g triton
sudo npm install -g smartdc
sudo npm install -g json

Create SSH key and add to Joyent

Next you will have to create an SSH key, on the build server, and add it to Joyent. Use the ssh-keygen command. You can add your ssh key to Joyent here.

Remember, this must be done for the distelli user.

When adding the key to Joyent, ensure the key has access to Manta.

Configure Triton Profile

You will have to create a triton profile on the build server. You can begin this process with triton profile create. I would recommend the following values:

  • name wordpress
  • fingerprint SSH_KEY_FINGERPRINT

Remember, this must be done as the distelli user.

Note, SSH_KEY_FINGERPRINT is typically ~/.ssh/id_rsa.pub

Validate Triton

You can validate your install by creating an instance in Joyent with the CLI. Here is an example CLI command.

triton instance create -w --name=distelliexample ubuntu-certified-14.04 k4-general-kvm-3.75G

Don’t forget to terminate this to ensure you are not billed.

You may need to run the following first.

eval $(triton env --docker)

Setup CNS

This exercise requires that you have enabled Container Name Server (CNS) in Joyent. Note, this may also be referred to as consul server in this document and the repository referenced above.

By default, this tutorial distinctly expects the CNS server to be named “consul”. Here is an example CLI command to create the server. Note, you must first enable CNS on your Joyent account.

triton instance create -w --name=consul -t triton.cns.services=consul ubuntu-certified-14.04 k4-general-kvm-3.75G

Fork the Repository

You must create a fork of the example repository</a> https://github.com/autopilotpattern/wordpress

Setup Pipelines Application

Now we are ready to create an application in Pipelines for the forked repository. To create an application, please see Creating an Application.

This application will be connected to the repository you forked above.

You will need to add the following build environment variables:

  • MANTA_BUCKET - The folder/bucket name in Joyent Manta
  • MANTA_USER - The user that has access (via ssh key) to the Manta folder/bucket


The final setup is to add the appropriate steps to the Pipelines manifest.

You will add these steps in the AfterBuildSuccess section of the manifest. On a successful build, the steps will initiate the wordpress cluster in Joyent.

    - eval $(triton env)
    - ./setup.sh ~/.ssh/id_rsa.pub
    - sed -i "s|MANTA_BUCKET= # an existing Manta bucket|MANTA_BUCKET=$MANTA_BUCKET|g" _env
    - sed -i "s|MANTA_USER= # a user with access to that bucket|MANTA_USER=$MANTA_USER|g" _env
    - docker-compose up -d
    - echo "The Wordpress URL is:"
    - grep "WORDPRESS_URL=htt" _env

To break this down, here is what is occurring.

  • eval $(triton env) - Setup the Joyent triton environment.
  • ./setup.sh ~/.ssh/id_rsa.pub - Create the _env file
  • sed -i "s|MANTA_BUCKET= # an existing Manta bucket|MANTA_BUCKET=$MANTA_BUCKET|g" _env - Update the _env filw with the appropriate values
  • sed -i "s|MANTA_USER= # a user with access to that bucket|MANTA_USER=$MANTA_USER|g" _env - Update the _env file with the appropriate values
  • docker-compose up -d - Bring the service up
  • cat _env | grep URL - Find the triton CNS (DNS) name for the service

Once you have those steps configured, build your application! Note, the services take 10-20 minutes to come up.

Back to top
The page rank or the 1 our of 5 rating a user has given the page.
The email address of the user submitting feedback.
The URL of the page being ranked/rated.