Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Dockerizing Your Homemade IoT Christmas Light Controller

DZone's Guide to

Dockerizing Your Homemade IoT Christmas Light Controller

What's better than making your own light controller? Making it into a Docker image. Follow along to learn how it's done.

· IoT Zone
Free Resource

Build an open IoT platform with Red Hat—keep it flexible with open source software.

In my previous article, I explained how to build your own IoT Christmas Light Controller by having Arduino Light Controller devices connect to an online server running on a VPS. After reading several really good Docker tutorials on DZone, I decided to Dockerize the IoT Light Controller server applications and make the application available as a Docker image. Docker is a project that automates the deployment of Linux applications inside software containers. You do not need to understand anything about Docker when following the installation sequence below. You can simply copy and paste the commands.

Light Controller Docker Image

Docker images can make deployment very easy and service providers could make it super easy to install a Docker image by simply providing a web form where you enter the Docker image name. However, Docker is still fairly new, thus most service providers require that you install the Docker image by using the command line. In this article, I'll show you how to install the Light Controller Docker image on the Google Cloud Platform and on Azure.

All service providers give you a free trial period, but Google also provides a free quota after the trial for low capacity web applications. The Light Controller is very resource light and should fit within the free quota allowed by Google.

Quoting Google:

Google App Engine has a free quota that applies regardless of whether you're in the free trial. This means you can run a web application at low traffic and capacity for free, both during and after the free trial.

Installing the Light Controller on the Google Cloud Platform

  1. Sign up for a trial account.

  2. After signing up, navigate to the Dashboard and click Create Project.

  3. After creating the project, click the "Activate Google Cloud Shell" button to open the web based shell.

  4. Paste the following commands into the web shell:

    gcloud config set compute/zone us-central1-b
    gcloud container clusters create --num-nodes=1 light-controller
    kubectl run light-controller --image=rtld/light-controller --port=80
    kubectl expose deployment light-controller --type="LoadBalancer"
  5. When the commands complete, wait one minute and run the following command to get the public IP address:

    kubectl get service light-controller
  6. Enter the IP address (from step 5) in your browser and navigate to the Light Controller

  7. Set the Light Controller admin credentials

The following two-minute video shows the complete installation procedure.


Installing the Light Controller on Azure

  1. Sign up for a trial: https://azure.microsoft.com/en-us/free/

  2. After signup, navigate to: https://github.com/Azure/azure-quickstart-templates/tree/master/docker-simple-on-ubuntu

  3. Click Deploy to Azure.

  4. Configure credentials (you need the credentials later when using SSH).

  5. Wait for the process to complete.

  6. Click MyDockerVM in the control panel.

  7. Take note of the IP address.

  8. Use an SSH client such as putty and connect as: username@ip-address

  9. Login using the password you set in step 4.

  10. Run the command:  sudo docker run -d -p 80:80 rtld/light-controller 

  11. When the command has completed, use a browser and navigate to http://ip-address

Download Red Hat’s blueprint for building an open IoT platform—open source from cloud to gateways to devices.

Topics:
docker ,iot cloud ,arduino ,iot

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}