Self-Hosted Blynk

Server Application

via Docker for Raspberry Pi


The Self-Hosted Blynk Server Application

Blynk is a full suite of software required to prototype, deploy, and remotely manage connected electronic devices at any scale: from personal IoT projects to millions of commercial connected products.

Blynk Server is an Open-Source Netty based Java server, responsible for forwarding messages between Blynk mobile application and various microcontroller boards and SBCs (i.e. Arduino, Raspberry Pi. etc).

Run your IoT projects locally

If you have no internet connectivity, but would still like to run your IoT devices locally, then configuring the Blynk server as a self-hosted environment is a great option.

In the instructions below I will try to guide you with your installation of the server. It is assumed that you understand Linux basics and already have Docker installed and running on your Pi. These instructions may not work on your platform, but it is what worked for me on my Raspberry-Pi 3B+ running latest Docker on DietPi.


What You Will Need

Gather up the files needed to host your Blynk server locally.

FYI: As of 9/2021, the Blynk Server application is no longer available from the developers and the versions listed below are the latest I could source.

The Blynk Server Java11

Use this version of the server if you are on Java version 11

The Blynk Server Java8

Use this version of the server if you are on Java version 8

The Blynk Mobile App

The Blynk (Legacy) Mobile App for Android

by apkpure.com.apk


The Hard Part..

So, this is the way I got everything running.


FYI: I use a combination of Putty and WinSCP to manage my server, as my main working computer is windows based. You can use whatever method you prefer to manage yours and to create the file structure below (nano, vim, etc.)

You will need to create a directory structure where blynk-server.yml and .dockerfiles/blynk-server.df will be stored (note the hidden directory .dockerfiles).

I like organizing my container's files into a working directory with a descriptive name, such as the app's name, and located within the home directory of my server (i.e. /home/containers/blynk-server). This will be where I run the build/updates from and maintain data persistence for this container, as you'll see later in the code.

So, head on over to your home directory where you want to have the files located, and create your file structure.


pi@skynet: cd /home/containers
pi@skynet: mkdir -p blynk-server/.dockerfiles

pi@skynet: cd blynk-server/.dockerfiles

Now you are ready to create the blynk-server.df file, either through the console, using a tool such as nano or vim, or via WinSCP.

The file contents are as follows:

Copy these contents to a file named blynk-server.df and place it in the /home/containers/blynk-server/.dockerfiles directory.


FROM openjdk:11-jre
MAINTAINER "Your Name <network@mail.com>"

ENV BLYNK_SERVER_VERSION 0.41.16

###
### Labels
###
# https://github.com/opencontainers/image-spec/blob/master/annotations.md
LABEL "maintainer"="Lazo Consumer Products, LLC. "

LABEL "org.opencontainers.image.created"="27/19/2021"
LABEL "org.opencontainers.image.version"="v${BLYNK_SERVER_VERSION}"
LABEL "org.opencontainers.image.authors"="Lazo Consumer Products, LLC. "
LABEL "org.opencontainers.image.source"="https://github.com/blynkkk/blynk-server/releases/download/v${BLYNK_SERVER_VERSION}/server-${BLYNK_SERVER_VERSION}.jar"

LABEL "com.lazoconsumerproducts.image.title"="Blynk-Server"
LABEL "com.lazoconsumerproducts.image.description"="Self-Hosted Blynk Server Application"
LABEL "com.lazoconsumerproducts.image.url"="https://cdn.lazoconsumerproducts.com/blynk-server/${BLYNK_SERVER_VERSION}/server-${BLYNK_SERVER_VERSION}.jar"
LABEL "com.lazoconsumerproducts.image.architecture"="arm64v8/aarch64"
LABEL "com.lazoconsumerproducts.image.build"="27/19/2021"
LABEL "com.lazoconsumerproducts.image.authors"="Lazo Consumer Products, LLC. "
LABEL "com.lazoconsumerproducts.image.vendor"="Lazo Consumer Products, LLC."
LABEL "com.lazoconsumerproducts.image.licenses"="MIT"

RUN mkdir /blynk

# The Blynk server app was originally available on Blynk's github location, but it is no longer supported.
# You may need to specify your own server location for the downloads above or leave it as is, but I too may end up removing it from my server some day.

#OLD DOWNLOAD URL
#RUN curl -L https://github.com/blynkkk/blynk-server/releases/download/v${BLYNK_SERVER_VERSION}/server-${BLYNK_SERVER_VERSION}.jar > /blynk/server.jar

#NEW DOWNLOAD URL (May change in the future...)
RUN curl -L https://cdn.lazoconsumerproducts.com/blynk-server/${BLYNK_SERVER_VERSION}/server-${BLYNK_SERVER_VERSION}.jar > /blynk/server.jar

# Create data folder. To persist data, map a volume to /data
RUN mkdir /data

# Create configuration folder. To persist data, map a file to /config/server.properties
RUN mkdir /config && touch /config/server.properties
VOLUME ["/config", "/data/backup"]

WORKDIR /data
ENTRYPOINT ["java", "-jar", "/blynk/server.jar", "-dataFolder", "/data", "-serverConfig", "/config/server.properties"]


The Easy Part...

For this next part you will need to create one more file. This will be the docker compose file that will be run to build or update the server.

Start by changing back to the blynk-server directory (cd ..) and creating the blynk-server.yml file from the code below.

version: "3.9" networks: local-net: external: true Volumes: config: data: services: ######################################################################### # BLYNK SERVER docker-compose -f blynk-server.yml up -d --build # ######################################################################### blynk: container_name: "Blynk_Server_v0.41.16" restart: unless-stopped build: context: .dockerfiles dockerfile: blynk-server.df volumes: - config:/config - data:/data ports: - 8080:8080 - 9443:9443 networks: - local-net

Finally, you will need to run the build command.

pi@skynet: docker-compose -f blynk-server.yml up -d --build

You can see the install process on screen as it completes each task. When successfully completed it will look something similar to this:

...
...
Removing intermediate container 9b2fa8aa7023
 ---> 644178836b07
Step 24/24 : ENTRYPOINT ["java", "-jar", "/blynk/server.jar", "-dataFolder", "/data", "-serverConfig", "/config/server.properties"]
 ---> Running in d1d52bf013c9
Removing intermediate container d1d52bf013c9
 ---> 98faafd053ce
Successfully built 98faafd053ce
Successfully tagged blynk-server_blynk:latest
Creating Blynk_Server_v0.41.16 ... done

pi@skynet:/home/containers/blynk-server#

You should now be able to access your container via its IP address.

https://172.71.0.9:9443/admin


If you do not know what your server IP is, check the logs within the container. It should have printed your IP and login credentials there. Normally this would look something like this:

Blynk Server 0.41.16 successfully started., All server output is stored in folder '/data/logs' file., Admin password not specified. Random password generated., Your Admin url is https://172.71.0.9:9443/admin, Your Admin login email is admin@blynk.cc, Your Admin password is ursGfQDWGVVdCgaPX2D7qct7,

The Blynk Login Page

Hurray, we're done! Nearly...

Login to the server and change your admin credentials. You may also want to change some settings in the configuration area, namely the server.properties and mail.properties sections.

The Blynk Admin Page

After all this, now you will need to download the mobile app from your app vendor. The android app is provided above in case it disappears from the Play Store, but basically, do a search for Blynk and you should be able to install the Legacy version of the app.

Portainer: Containers running along side the Blynk-Server app.


Final thoughts

Please let me know what you thought of this tutorial and where you think it can be improved upon.

Happy Blynking!


Copyright © 2023 - Lazo Consumer Products, LLC. All Rights Reserved.