Skip to content

Commit 228710a

Browse files
authored
Merge pull request #436 from Paraphraser/20211023-blynkServer-selfRepair-old-menu
20211023 Blynk Server - old-menu branch - PR 2 of 3
2 parents 95e7856 + 49cf402 commit 228710a

File tree

7 files changed

+148
-192
lines changed

7 files changed

+148
-192
lines changed

.templates/blynk_server/Dockerfile

Lines changed: 69 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,75 @@
1-
FROM adoptopenjdk/openjdk14
2-
MAINTAINER 877dev <[email protected]>
1+
# Acknowledgements:
2+
# Based on:
3+
# https://github.com/SensorsIot/IOTstack/blob/master/.templates/blynk_server/Dockerfile
4+
# (as at commit ID 4dff89c1bb6a5b1c01d3c087dcb662256a0c050f)
5+
# Borrows from:
6+
# https://github.com/Peterkn2001/blynk-server/blob/master/server/Docker/Dockerfile
7+
# (as at commit ID 889c7e55161832e21264d993d9fa5abd1c015e1c)
38

4-
#RUN apt-get update
5-
#RUN apt-get install -y apt-utils
6-
#RUN apt-get install -y default-jdk curl
9+
FROM ubuntu
710

8-
ENV BLYNK_SERVER_VERSION 0.41.14
9-
RUN mkdir /blynk
10-
RUN curl -L https://github.com/blynkkk/blynk-server/releases/download/v${BLYNK_SERVER_VERSION}/server-${BLYNK_SERVER_VERSION}.jar > /blynk/server.jar
11+
# declare the version to be built, defaulting to 0.41.16 (which is
12+
# current as of 2021-10-22)
13+
ARG BLYNK_SERVER_VERSION=0.41.16
1114

12-
# Create data folder. To persist data, map a volume to /data
13-
RUN mkdir /data
15+
# form the download URL
16+
ENV BLYNK_SERVER_URL=https://github.com/Peterkn2001/blynk-server/releases/download/v${BLYNK_SERVER_VERSION}/server-${BLYNK_SERVER_VERSION}.jar
1417

15-
# Create configuration folder. To persist data, map a file to /config/server.properties
16-
RUN mkdir /config && touch /config/server.properties
17-
VOLUME ["/config", "/data/backup"]
18+
# Add support packages to the base image
19+
RUN apt-get update \
20+
&& apt-get install -y \
21+
apt-utils \
22+
libreadline8 \
23+
libreadline-dev \
24+
&& apt-get install -y \
25+
curl \
26+
libxrender1 \
27+
maven \
28+
openjdk-11-jdk \
29+
rsync
1830

19-
# IP port listing:
20-
# 8080: Hardware without ssl/tls support
21-
# 9443: Blynk app, https, web sockets, admin port
22-
EXPOSE 8080 9443
31+
# Add IOTstack-specific support
32+
ENV IOTSTACK_DEFAULTS_DIR="iotstack_defaults"
33+
ENV IOTSTACK_ENTRY_POINT="docker-entrypoint.sh"
34+
COPY ${IOTSTACK_DEFAULTS_DIR} /${IOTSTACK_DEFAULTS_DIR}
35+
COPY ${IOTSTACK_ENTRY_POINT} /${IOTSTACK_ENTRY_POINT}
36+
RUN chmod 755 /${IOTSTACK_ENTRY_POINT}
2337

24-
WORKDIR /data
25-
ENTRYPOINT ["java", "-jar", "/blynk/server.jar", "-dataFolder", "/data", "-serverConfig", "/config/server.properties", "-mailConfig", "/config/mail.properties"]
38+
# define well-known paths
39+
ENV IOTSTACK_DATA_DIR="/data"
40+
ENV IOTSTACK_CONF_DIR="/config"
41+
ENV IOTSTACK_JAVA_DIR="/blynk"
42+
43+
# Create and populate expected folders
44+
RUN mkdir -p ${IOTSTACK_DATA_DIR} ${IOTSTACK_JAVA_DIR} \
45+
&& curl -L ${BLYNK_SERVER_URL} >"${IOTSTACK_JAVA_DIR}/server.jar"
46+
47+
# declare expected mapped volumes
48+
VOLUME ["${IOTSTACK_CONF_DIR}", "${IOTSTACK_DATA_DIR}"]
49+
50+
# Expose assumed internal ports:
51+
# 8080 http.port
52+
# 8440 hardware.mqtt.port
53+
# 9443 https.port
54+
EXPOSE 8080 8440 9443
55+
56+
# set the working directory
57+
WORKDIR ${IOTSTACK_DATA_DIR}
58+
59+
# define launch procedure
60+
ENTRYPOINT ["/docker-entrypoint.sh"]
61+
CMD ["java", "-jar", "/blynk/server.jar", "-dataFolder", "/data", "-serverConfig", "/config/server.properties", "-mailConfig", "/config/mail.properties"]
62+
63+
# supplement image metadata
64+
LABEL blynk-server.version=${BLYNK_SERVER_VERSION}
65+
LABEL blynk-server.url=${BLYNK_SERVER_URL}
66+
LABEL com.github.SensorsIot.IOTstack.Dockerfile.maintainer="877dev <[email protected]>"
67+
LABEL com.github.Peterkn2001.blynk-server.Dockerfile.maintainer="Florian Mauduit <[email protected]>"
68+
69+
# unset variables that are not needed by docker-entrypoint.sh
70+
ENV IOTSTACK_ENTRY_POINT=
71+
ENV IOTSTACK_DATA_DIR=
72+
ENV IOTSTACK_JAVA_DIR=
73+
ENV BLYNK_SERVER_URL=
74+
75+
# EOF

.templates/blynk_server/directoryfix.sh

Lines changed: 0 additions & 90 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# were we launched as root with defaults available?
5+
if [ "$(id -u)" = "0" -a -d /"$IOTSTACK_DEFAULTS_DIR" ]; then
6+
7+
# yes! ensure that the IOTSTACK_CONF_DIR exists
8+
mkdir -p "$IOTSTACK_CONF_DIR"
9+
10+
# populate runtime directory from the defaults
11+
rsync -arp --ignore-existing "/${IOTSTACK_DEFAULTS_DIR}/" "${IOTSTACK_CONF_DIR}"
12+
13+
# enforce correct ownership
14+
chown -R "${IOTSTACK_UID:-nobody}":"${IOTSTACK_GID:-nobody}" "$IOTSTACK_CONF_DIR"
15+
16+
fi
17+
18+
# start the blynk server
19+
exec "$@"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
mail.smtp.auth=true
2+
mail.smtp.starttls.enable=true
3+
mail.smtp.host=smtp.gmail.com
4+
mail.smtp.port=587
5+
mail.smtp.username[email protected]
6+
mail.smtp.password=YOUR_GMAIL_APP_PASSWORD
7+
mail.smtp.connectiontimeout=30000
8+
mail.smtp.timeout=120000
9+
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
hardware.mqtt.port=8440
2+
http.port=8080
3+
force.port.80.for.csv=false
4+
force.port.80.for.redirect=true
5+
https.port=9443
6+
data.folder=./data
7+
logs.folder=./logs
8+
log.level=info
9+
user.devices.limit=10
10+
user.tags.limit=100
11+
user.dashboard.max.limit=100
12+
user.widget.max.size.limit=20
13+
user.message.quota.limit=100
14+
notifications.queue.limit=2000
15+
blocking.processor.thread.pool.limit=6
16+
notifications.frequency.user.quota.limit=5
17+
webhooks.frequency.user.quota.limit=1000
18+
webhooks.response.size.limit=96
19+
user.profile.max.size=128
20+
terminal.strings.pool.size=25
21+
map.strings.pool.size=25
22+
lcd.strings.pool.size=6
23+
table.rows.pool.size=100
24+
profile.save.worker.period=60000
25+
stats.print.worker.period=60000
26+
web.request.max.size=524288
27+
csv.export.data.points.max=43200
28+
hard.socket.idle.timeout=10
29+
enable.db=false
30+
enable.raw.db.data.store=false
31+
async.logger.ring.buffer.size=2048
32+
allow.reading.widget.without.active.app=false
33+
allow.store.ip=true
34+
initial.energy=1000000
35+
admin.rootPath=/admin
36+
restore.host=blynk-cloud.com
37+
product.name=Blynk
38+
admin.email[email protected]
39+
admin.pass=admin
40+
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
blynk_server:
2-
build: ./services/blynk_server/.
2+
build:
3+
context: ./.templates/blynk_server/.
4+
args:
5+
- BLYNK_SERVER_VERSION=0.41.16
36
container_name: blynk_server
47
restart: unless-stopped
8+
environment:
9+
- TZ=Etc/UTC
10+
- IOTSTACK_UID=1000
11+
- IOTSTACK_GID=1000
512
ports:
613
- "8180:8080"
7-
- "8441:8441"
14+
- "8440:8440"
815
- "9443:9443"
916
volumes:
1017
- ./volumes/blynk_server/data:/data
11-
- ./volumes/blynk_server/data/config:/config
18+
- ./volumes/blynk_server/config:/config

docs/Containers/Blynk_server.md

Lines changed: 1 addition & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,3 @@
11
# Blynk server
2-
This is a custom implementation of Blynk Server
32

4-
```yml
5-
blynk_server:
6-
build: ./services/blynk_server/.
7-
container_name: blynk_server
8-
restart: unless-stopped
9-
ports:
10-
- 8180:8080
11-
- 8441:8441
12-
- 9443:9443
13-
volumes:
14-
- ./volumes/blynk_server/data:/data
15-
```
16-
17-
To connect to the admin interface navigate to `<your pis IP>:9443/admin`
18-
19-
I don't know anything about this service so you will need to read though the setup on the [Project Homepage](https://github.com/blynkkk/blynk-server)
20-
21-
When setting up the application on your mobile be sure to select custom setup [here](https://github.com/blynkkk/blynk-server#app-and-sketch-changes)
22-
23-
Writeup From @877dev
24-
25-
## Getting started
26-
Log into admin panel at https://youripaddress:9443/admin
27-
(Use your Pi's IP address, and ignore Chrome warning).
28-
29-
Default credentials:
30-
31-
pass:admin
32-
33-
## Change username and password
34-
Click on Users > "email address" and edit email, name and password.
35-
Save changes
36-
Restarting the container using Portainer may be required to take effect.
37-
38-
## Setup gmail
39-
Optional step, useful for getting the auth token emailed to you.
40-
(To be added once confirmed working....)
41-
42-
## iOS/Android app setup
43-
Login the app as per the photos [HERE](https://github.com/blynkkk/blynk-server#app-and-sketch-changes)
44-
Press "New Project"
45-
Give it a name, choose device "Raspberry Pi 3 B" so you have plenty of [virtual pins](http://help.blynk.cc/en/articles/512061-what-is-virtual-pins) available, and lastly select WiFi.
46-
Create project and the [auth token](https://docs.blynk.cc/#getting-started-getting-started-with-the-blynk-app-4-auth-token) will be emailed to you (if emails configured). You can also find the token in app under the phone app settings, or in the admin web interface by clicking Users>"email address" and scroll down to token.
47-
48-
## Quick usage guide for app
49-
Press on the empty page, the widgets will appear from the right.
50-
Select your widget, let's say a button.
51-
It appears on the page, press on it to configure.
52-
Give it a name and colour if you want.
53-
Press on PIN, and select virtual. Choose any pin i.e. V0
54-
Press ok.
55-
To start the project running, press top right Play button.
56-
You will get an offline message, because no devices are connected to your project via the token.
57-
Enter node red.....
58-
59-
## Node red
60-
Install node-red-contrib-blynk-ws from pallette manager
61-
Drag a "write event" node into your flow, and connect to a debug node
62-
Configure the Blynk node for the first time:
63-
```URL: wss://youripaddress:9443/websockets``` more info [HERE](https://github.com/gablau/node-red-contrib-blynk-ws/blob/master/README.md#how-to-use)
64-
Enter your [auth token](https://docs.blynk.cc/#getting-started-getting-started-with-the-blynk-app-4-auth-token) from before and save/exit.
65-
When you deploy the flow, notice the app shows connected message, as does the Blynk node.
66-
Press the button on the app, you will notice the payload is sent to the debug node.
67-
68-
## What next?
69-
Further information and advanced setup:
70-
https://github.com/blynkkk/blynk-server
71-
72-
Check the documentation:
73-
https://docs.blynk.cc/
74-
75-
Visit the community forum pages:
76-
https://community.blynk.cc/
77-
78-
Interesting post by Peter Knight on MQTT/Node Red flows:
79-
https://community.blynk.cc/t/my-home-automation-projects-built-with-mqtt-and-node-red/29045
80-
81-
Some Blynk flow examples:
82-
https://github.com/877dev/Node-Red-flow-examples
3+
Please refer to the [documentation on the master branch](https://sensorsiot.github.io/IOTstack/Containers/Blynk_server/).

0 commit comments

Comments
 (0)