DocsPipelines for ApplicationsApplication tutorials
Rust application: Build and deploy

Rust application: Build and deploy


This tutorial will get you setup and deploying a simple Rust & application with Pipelines in minutes. The tutorial assumes you have already:


For this tutorial we will be using a basic “Hello World” Rust & app, but you can use your own custom application if you like. To start you are going to need to open your terminal and navigate to the folder where you would like to store your files. Next we will install if you haven’t already:

$ curl -s | sudo sh

The command above will install the latest version of Rust and Cargo on your machine. You will need both of these to run your application locally.

Next, create a new a project with Nickel:

$ cargo new hello-world --bin && cd nickel-demo

Now that we have everything all set up we can start by creating a basic Rust & “Hello World” app. Open src/main/rs in the text editor of your choice and paste in the below code:

#[macro_use] extern crate nickel;

use nickel::Nickel;

fn main() {
    let mut server = Nickel::new();

    server.utilize(router! {
        get "**" => |_req, _res| {
            "Hello world from Pipelines!"


Now that everything has been created, you can test your application by entering the command:

$ cargo run

This will compile your application and serve it at localhost:6767.

Rust Web Application

Before we move on, make sure you have set up a repository in GitHub or BitBucket.

Step 1. Push your Code to GitHub/BitBucket

The next step to complete is to put your code into a source control repository. If you are unfamiliar with source control the steps below will guide through the process. For this tutorial I am using GitHub as my repository, but you can use BitBucket or GitLab as well without any issue.

First you will need to create a repo in GitHub and push your code to that repository. Once created, open your terminal and make sure you are in the directory that your app’s code is in.

Initialize the local directory as a Git Repo

$ git init

Add the files in your new local repo

$ git add .

Commit the files you have just staged

$ git commit -m "First Commit. Created app.js"

Navigate to your GitHub or BitBucket Repo and find your remote repository URL. Once you have your remote repository URL use the following commands to finish setting up your repo.

$ git remote add origin "Your Remote Repository URL"
# Sets the new URL
$ git remote -v
# Verify the URL

Now push the changes to your repo

$ git push origin master

Step 2. Set Up Your Server

If you do not have a Pipelines account, please Sign Up for one now.

The next step in deploying our app is to make sure you have a server to run your application on. You can use any type of server - public cloud, private cloud or physical. Pipelines will let you deploy your code to Vagrant VMs or servers in a VPC. You can even deploy to the server under your desk. For this tutorial I am going to be deploying to a server hosted by Digital Ocean.

To be able to deploy your application to your server you will need to install the Pipelines Agent. You will need remote access to your server to complete the installation. Please consult the below information on how to install the Pipelines Agent on your server.

Note: This installation requires root (administrator) permissions.

Linux and macOS X

To install on Linux or macOS X you can use either curl or wget with one of the following syntaxes.

wget example

wget -qO- | sh

curl example

curl -sSL | sh


To install on Windows copy and paste the following powershell command into a command (cmd) window.

powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString(''))" & SET PATH=%PATH%;%ProgramFiles%/Distelli

Complete the Install

To complete the install of the agent, you must issue the /usr/local/bin/distelli agent install command.

/usr/local/bin/distelli agent install
ServerA:~$ <b>wget -qO- | sh</b>
This script requires superuser privileges to install packages
Please enter your password at the sudo prompt

[sudo] password for bmcgehee:
    Installing Pipelines CLI 3.51 for architecture 'Linux-x86_64'...
To install the agent, run:
    sudo /usr/local/bin/distelli agent install
ServerA:~$ <b>sudo /usr/local/bin/distelli agent install</b>
Distelli Email:
    1: User: jdoe
    2: Team: janedoe/TeamJane
Team [2]: <b>1</b>
Server Info:
Starting upstart daemon with name:

Verify the Install

To validate the agent is installed and working use the /usr/local/bin/distelli agent status command.

Note: This installation requires root (administrator) permissions.

/usr/local/bin/distelli agent status
Pipelines Agent (serverA) is Running with id

If you would like more information on installing the Pipelines agent, visit Installing the Pipelines Agent.

Step 3. Create Pipelines Application

To create your app in Pipelines, follow these steps:

Click the new application button on your Pipelines account home screen

Create a new Application

Select the Repository type where you are storing your applications files.

Name Your App

After we click the button to connect to our Repository, we then select the appropriate repo that contains your code.

Choose Your Repo

Select the appropriate branch for your deployment. I have only a master branch, but you can deploy any branch from your repo!

Choose Your Repo's Branch

Next Pipelines will ask you set your build steps. For this particular application we will use the PkgInclude section. The Build section is where you would want to include any tests or tasks you would like to run while your application is building. Please make sure your PkgInclude section looks identical to the one below.

Rust & PkgInclude

The final step is select our Build Image. In this case we are going to select Pipelines Base for our Rust & Application. Select the Auto Build checkbox and the the Looks good. Start Build!.

Warning: The Auto-Build feature builds your application everytime you commit code to your repository

Start Build

Now our application should be automatically building. You can watch its progress by navigating to the builds tab on your Pipelines account and clicking on your build.

Step 4. Build & Deploy Steps

Once your build has completed, our next step is to define our Build and Deploy steps for our application. To accomplish this, we will use the In-App Manifest, located in your application page. Navigate to your application’s page and then click the Manifest to get started:

Manifest Tab for App

Build Steps

Expand the Build Manifest section by clicking on the plus sign. This is where we are going to tell Pipelines what commands to run during our Build.


Scroll down to your PreInstall section and enter in the following

Rust & PreBuild Commands


echo "Starting PreBuild"
sudo apt-get update
sudo apt-get install gcc -y
curl -s | sudo sh
sudo ln -sf /usr/local/bin/rustc /usr/bin/rustc


Scroll down to your PreInstall section and enter in the following

Rust & Build Commands


echo "Starting Build"
/usr/local/bin/cargo build

Deploy Steps

Expand the Deployment Manifest section by clicking on the plus sign. This is where we are going to tell Pipelines what commands to run during our Deployment.

Note: This tutorial assumes that the server is out of the box and needs to have your application dependencies installed & configured. Once your application dependencies are installed & configured you can remove those commands from your Manifest.


Scroll down to your PreInstall section and enter in the following

Rust & PreInstall Commands


echo "Starting PreInstall"
sudo apt-get update
# The below commands can be removed after your first deployment
sudo apt-get install gcc -y
curl -s | sudo sh
sudo ln -sf /usr/local/bin/rustc /usr/bin/rustc


Scroll down to your Exec section and enter in the following

Rust & Exec Commands


echo "Starting Application"
/usr/local/bin/cargo run

Re-Build Application

Because we have changed our deployment steps we need to rebuild our application. First save your changes by clicking the “Publish Manifest” button and then rebuild your application. To trigger a new build, click the wrench icon in the right hand corner! That button triggers a build of your latest code, build steps, and deployment steps.

Trigger new build of Rust & Application

Step 5. Deploy Application

Now that we have successfully built our application we are ready to deploy to our server. On the builds page select the “New Deployment” button in the right hand corner.

Rust & Build

Deploy your Rust & Application

Once you click the button, you should be directed to the deployment page. The first step is to select the Deploy a Release option.

Deploy Release

Pipelines will now prompt you to select the application you want to deploy. Please select the application we created earlier in the tutorial.

Select Application for Deployment

Then you will be asked to select the release you would like to deploy. For now there should be only one release for deployment.

Choose Your Release

The last step in our deployment is to select the environment you wish to deploy in. First you will need to create an environment by enter a name and selecting the Add Environment button.

Add Deployment Environment

Next select the Environment you just created and click All Done.

Select Deployment Environment

Now Pipelines will ask you to add your server. Click the Add Servers button to get started. Select the server you configured earlier in the tutorial and add it to your account. Once you have added your server, you can close the Add Servers panel and continue with your deployment. You will see a final option to set your delay between deployments on your servers and a Deploy! button.

Start Your Deployment

Click the Deploy! button to begin your deployment. You will redirected to a page where you can view the progress of your deployment. Click the “log” button on the left side to enable you to view realtime streaming logs for the deployment.

Deployment Successful

View Your Application

And that’s it! Once your application has finished deploying, you can close your deployment log by click the red box, and open your Stdout to watch your deployment finish. Point your browser to http://<-You Server’s IP Address->:6767 and see your Rust & Application!

Rust & Successful Deployment

How helpful was this page?
Puppet sites use proprietary and third-party cookies. By using our sites, you agree to our cookie policy.