GlueStick, Docker, and DigitalOcean’s Ubuntu 14.04

Leveraging TrueCar’s open source GlueStick, this tutorial will run through a simple process of setting up a GlueStick app with Docker on an Ubuntu server. Never heard of GlueStick before? GlueStick handles asset package management, server-side rendering, and comes with a fully-functional testing environment and generators to help you move quickly. For more information on why and how we built GlueStick, see our original post here.


For this tutorial you will need a few things before you can start the process. This process will be specifically focused on Mac, but DigitalOcean and Docker have coverage for you “non-Mac” users.

1.Create a Docker repository on docker hub. Think github for Docker.- If you do not already have a docker hub account please create one.

- Once you have an account sign into docker hub and create your first repository.

- Docker provides one free repository.

- Click the big blue button that reads “Create Repository +”.

- Enter a name for your repository. It can be anything you want, but we will refer to the repo as
examplerepo. Docker will expect the names to be all lower case.

- For this tutorial lets go ahead an use our free private repository. Under “Visibility” select
“private” and then hit the create button at the bottom.

- Now if you click the dashboard on docker hub you should see your new repository, username/examplerepo.

2.Docker for Mac

- Docker for mac install package includes everything you will need to run Docker on a mac.

- Please follow the link to the “Get Docker for mac[stable]” and follow the instructions for

- Install docker for mac.

3.Set up a one click DigitalOcean droplet

- Just like docker hub, if you do not have an account at DigitalOcean, please make one.

- Once you are signed in, navigate to “Droplets”.

- In the upper right corner click the green button that reads “Create Droplet”.

- Under choose an image, select “One-click apps”. Then select Docker 1.13.1 on 14.04.

- Scroll down and select standard $10/mo. GlueStick needs about 1 GB to work. (You may be able to find a coupon online to make this completely free.)

- Scroll down even farther to “Choose a datacenter region”. Select the one that is closest to you.

- Do you have an ssh key set up for you machine? A common place to store ssh keys is in ~/.ssh/, you will need to copy your public key, .pub. If you do not have one, take a look at this, how to use ssh keys with DigitalOcean. DigitalOcean has an extensive amount of in depth tutorials to help you through any issues.

- Next you will need to add your ssh keys. If you already have one set up with DigitalOcean, just select the the key you want to use. If you need to add one just select the button “New SSH Key” and add the name of the key and the key itself.

Creating a GlueStick App

To start off we need a GlueStick App. If you have already created one please skip to the next section (“Piecing it all together”).
On your machine you will need to have gluestick installed. If you already have it skip to the next step.

$ npm install gluestick -g

cd into where you want to create your new gluestick app. Once you are there use the following command to generate a new app:

$ gluestick generate new {Name of App}

You can now create whatever you want your app to be. If you are just following along with the tutorial to try out the process, your app is ready to go.

Piecing it all together

On your local machine:
cd into your gluestick app, ("Name of App") and run the command:

$ gluestick dockerize {docker username}/{examplerepo}

This command will convert the gluestick app to run with a docker container. To find your examplerepo, go back to Docker Hub and look at your dashboard.
Next we need to login to docker on your machine. You will need your username and password:

$ docker login

Now we just need to push our app to docker hub.

$ docker push {docker username}/{examplerepo}

Setting up your server:
- cd into your root directory, $ cd.
- ssh into your newly created droplet.

# ssh root@IP_ADDRESS

You can find your IP_ADDRESS at DigitalOcean under "Droplets" (you can just hover over the IP Address and click to copy).
If you have trouble connecting using ssh, here is a tutorial on how to connect to your droplet.
- Now we need to login to docker on our server. You will need your username and password:

# docker login

- Once logged in we need to pull our docker container from Docker Hub onto our server.

# docker pull {docker username}/{examplerepo}

- Let’s see if your app is up and running.

# docker run --name webserver -p 80:8888 {docker username}/{examplerepo}

- --name identifies the container. If you do not assign a container name with the --name option, then the daemon generates a random string name for you.
- -p exposes on port 80 (on the host machine) whatever is exposed on port 8888 in the docker container

Then Hit your IP_ADDRESS in the browser. You should see your app up and running. If you did not change your app you should see "Home" in your browser window.
- Let's configure the docker daemon to run the background process. You can also create the file using touch, or whatever you like to use to create a file. Create the file:

# vim /etc/init/webserver.conf

- Inside webserver.conf add the following scripts:

description "docker web server"
start on filesystem and started docker
stop on runlevel [!2345]
pre-start script
docker rm -f webserver || true
end script
docker run --name webserver -p 80:8888 toddsurfs/ocean-test
end script
post-stop script
docker rm -f webserver
end script

- Once the script has been added run the command:
# service webserver start
You should now have a GlueStick app running with Docker on an Ubuntu 14.04 server! If you have created a personal project where you might want to attach a domain name to your droplet, instead of using the IP Address, DigitalOcean has an easy way to do that here.