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.
Join the DZone community and get the full member experience.Join For Free
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.
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.
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
Sign up for a trial account.
After signing up, navigate to the Dashboard and click Create Project.
After creating the project, click the "Activate Google Cloud Shell" button to open the web based shell.
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"
When the commands complete, wait one minute and run the following command to get the public IP address:
kubectl get service light-controller
Enter the IP address (from step 5) in your browser and navigate to the Light Controller
Set the Light Controller admin credentials
The following two-minute video shows the complete installation procedure.
Installing the Light Controller on Azure
Sign up for a trial: https://azure.microsoft.com/en-us/free/
After signup, navigate to: https://github.com/Azure/azure-quickstart-templates/tree/master/docker-simple-on-ubuntu
Click Deploy to Azure.
Configure credentials (you need the credentials later when using SSH).
Wait for the process to complete.
Click MyDockerVM in the control panel.
Take note of the IP address.
Use an SSH client such as putty and connect as: username@ip-address
Login using the password you set in step 4.
Run the command:
sudo docker run -d -p 80:80 rtld/light-controller
When the command has completed, use a browser and navigate to http://ip-address
Opinions expressed by DZone contributors are their own.