This tutorial will get you setup, building, testing, and deploying an application with Distelli in minutes.
The tutorial assumes you have already:
- Created a free Distelli account
- Have a login to, at least, one of the two public repositories.
The scenario also expects that you have a Destination server available to do deployments of the example application.
To enable auto deployment of an application you must have a destination server to deploy to.
If you don't have a server you can use a virtual server. For a simple guide to setting up a virtual server using Virtualbox and Vagrant see Building Virtual Servers.
You must install the Distelli agent on the server to facilitate deployments. Instructions on installing the Distelli agent can be found here Distelli agent reference guide.
Install the agent and return to this document.
- Ensure you are logged into your Github account. https://github.com/
- Go to this pubilc Distelli repository: https://github.com/distelli/nodejsbuilddeploy.
- Click the Fork button (top right).
You have forked the repository to your Github account. Good job!
You can view the forked repository in your Github account at:
https://github.com/YOUR_GITHUB_USERNAME/nodejsbuilddeploy
You will need to clone a copy of the repository to your local machine. This assume you already have git installed on your local computer. If not you can install git from here: http://git-scm.com/
Use the following syntax to clone the repository:
git clone https://github.com/YOUR_GITHUB_USERNAME/nodejsbuilddeploy.git
Now change to the newly created directory.
cd nodejsbuilddeploy
Note: If your Github account is using Two-factor authentication you will not be able to use the above command to clone and work with the repository. You must:
- Use an SSH key with github https://help.github.com/articles/generating-ssh-keys/
- Use a different git clone syntax. See below:
git clone [email protected]:YOUR_GITHUB_USERNAME/nodejsbuilddeploy.git
The Distelli Manifest file provides the Distelli Platform with the needed information to successfully build and deploy your application. This file must exist before building your application with Distelli.
The sample application you cloned will already have an existing distelli-manifest.yml
file in the application root directory. You will need to make a small change to this file before you can build and deploy the application with Distelli.
Edit the distelli-manifest.yml
file.
On the first line you will see a <username> placeholder, and then the name of the sample application.
Replace the <username> placeholder with your Distelli username. To find your Distelli username see Finding Your Distelli Username.
For example if your username is 'YourUserName' your distelli-manifest.yml
should look like this:
YourUserName/nodejsbuilddeploy:
# Distelli Manifest example
# this example assumes the build and deploy servers are:
# Ubuntu 14.04
PreRelease:
- echo "---Beginning PreRelease---"
- echo "--Installing build dependencies--"
- echo "-Updating apt-get-"
- sudo apt-get -y update
- echo "-Installing nodejs-"
- sudo apt-get -y install nodejs
- echo "-Installing npm-"
- sudo apt-get -y install npm
- echo "--Building--"
- sudo npm install
- echo "--Testing--"
- npm test
PkgInclude:
- '*'
PkgExclude:
- node_modules/
PreInstall:
- echo "---Begining PreInstall---"
- echo "--Installing deploy dependencies--"
- echo "-Updating apt-get-"
- sudo apt-get -y update
- echo "-Installing nodejs-"
- sudo apt-get -y install nodejs
- echo "-Installing npm-"
- sudo apt-get -y install npm
PostInstall:
- echo "Begin PostInstall"
- npm install
Env:
- PORT: 3000
Exec:
- /usr/bin/nodejs app.js
Save your change.
In this step you will use the Distelli new application workflow to create an application that is integrated with the repository you forked above.
To complete this section you will navigate to another set of instructions. There you will walk through those instructions, afterwards returning here.
Certain fields will need tutorial specific information. The table below has that information.
Name | Value |
Name your App Application Name | nodejsbuilddeploy |
Choose a Repo Repository Name | nodejsbuilddeploy |
Choose a Branch Branch Name | master |
After completing the Tutorial Creating an Application from a Repository return to this tutorial document.
Navigate to Tutorial Creating an Application from a Repository, follow the steps in the document, and then return here.
Return here!
-
In the Distelli WebUI click Applications at the top.
-
In the application list click nodejsbuilddeploy name to navigate to the application page.
-
Click the Settings link.
You are now in the application settings page.
-
Check the Automatically build this branch when a new commit is pushed box.
-
Click Save Repo Settings
You have enabled auto build.
If you are interested in building on your own build server(s) see Using your own Build Server.
-
In the Distelli WebUI click the Applications link at the top.
-
In the application list click nodejsbuilddeploy name to navigate to the application page.
-
Click the Settings link.
You are now in the application settings page.
-
Scroll down and find the Repository Settings section.
-
Check the Automatically deploy this branch when a build succeeds box.
-
Click on the nodejsbuilddeploy-beta environment to select it.
-
Click Save Repo Settings
You have enabled auto deploy.
In the last step you enabled auto deploy for the application environment, but this environment currently has no servers in it to deploy to.
In this step you will add the server, from step 1, to the -beta environment.
-
In the Distelli WebUI click the Applications link at the top.
-
In the application list click nodejsbuilddeploy name to navigate to the application page.
-
Click the Environments link.
-
Click the nodejsbuilddeploy-beta environment.
You are now at the environment page.
-
Click the Servers link in the environment section.
-
Click Add Servers.
You should see the server from step 1 in the server list.
-
Check the Add Server box for the server from step 1.
-
Click the Add Selected Servers link near the top left
You have added a server to the environment.
In a previous step you edited and saved the distelli-manifest.yml file in the nodejsbuilddeploy application directory. This constitutes a code change. You will now commit and push that code change up to your repository.
When the repository changes it will notify Distelli that a change occurred. This will trigger a build by Distelli.
Distelli will grab a copy of the repository; build it, test it, and if it is successful will create a release.
When a release is created this will trigger an auto deploy of the application to the -beta environment with the server from step 1.
Enter the following commands in the nodejsbuilddeploy
directory:
git add .
git commit -m "Set username in manifest"
git push -u origin master
This will push your code change up to the repository.
-
Click the Builds link at the top of the Distelli WebUI.
In the builds list page you will see your build queued or in progress
-
Click on the build to navigate to the build page.
From the build page you can watch the build log. If the build fails see the Troubleshooting section below.
To verify the application deployed correctly point your web browser to your destination server IP on port 3000.
http://YOUR_SERVER_IP:3000
The distelli-manifest.yml provides the instructions for building, testing, and deploying the application.
For more information on the Distelli manifest see Distelli Manifest.
If you see the following build failure:
Task Status: Exit=1 Signal=0
Cloning into '/distelli/tasks/d461-762'...
HEAD is now at 7db094e Update distelli-manifest.yml
Expected manifest(s) to contain app 'YourUserName/gobuilddeploy'. Instead the manifest(s) specified:
'<username>/gobuilddeploy'
Ensure that you:
For more information on troubleshooting deploys see Troubleshooting Deploys.
- Tutorials Index
- Manifest Library of Examples
- Read the Knowledge Base articles
- Check out the Reference Guides