Skip to content

Commit

Permalink
create docker-compose, add users dir, add mosquitto.conf
Browse files Browse the repository at this point in the history
tavdog committed Dec 5, 2024
1 parent 76b0ef6 commit 50c3af6
Showing 6 changed files with 36 additions and 9 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -6,6 +6,5 @@ configs/**
**/*.log
.env
**/tidbyt-apps/**
**/users/**
.DS_Store
tidbyt-apps/
3 changes: 2 additions & 1 deletion device_runner.py
Original file line number Diff line number Diff line change
@@ -25,12 +25,13 @@ def mqtt_setup(connect_string):
url = urlparse(connect_string)
user = url.username
passw = url.password
host = url.hostname
host = url.hostname or 'mqtt'
port = url.port
topic = url.path
topic = topic[1:]
client = mqtt.Client()
if user and passw : client.username_pw_set(user,passw)
dprint(f"Connecting to {host}:{port}")
client.connect(host,port)
client.loop_start()
return client,topic
23 changes: 23 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: '3.8'

services:
web:
build:
context: .
dockerfile: Dockerfile
ports:
- "8000:8000" # Map port 8000 on the host to port 8000 in the container
- "5100:5100" # 5100 is used for pixlet serve interface during app configuration
environment:
- MQTT_BROKER_HOST=mqtt # Name of the MQTT service (hostname inside the Docker network)
- MQTT_BROKER_PORT=1883
depends_on:
- mqtt

mqtt:
image: eclipse-mosquitto:latest
ports:
- "1883:1883" # MQTT broker port
- "9001:9001" # (optional) WebSocket support
volumes:
- ./mosquitto.conf:/mosquitto/config/mosquitto.conf
12 changes: 6 additions & 6 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -9,8 +9,8 @@ ENV DOMAIN=localhost
# ###################################
# install pixlet
ENV NODE_URL=https://deb.nodesource.com/setup_21.x
ENV PIXLET_REPO=https://github.com/tavdog/pixlet
#ENV PIXLET_REPO_ZIP=https://github.com/tavdog/pixlet/archive/refs/heads/config_merge.zip
#ENV PIXLET_REPO=https://github.com/tavdog/pixlet
ENV PIXLET_REPO_ZIP=https://github.com/tavdog/pixlet/archive/refs/heads/config_merge.zip

ENV TDM_REPO=https://github.com/tavdog/tidbyt-manager
ENV TIDBYT_APPS_REPO=https://github.com/tidbyt/community
@@ -20,10 +20,10 @@ RUN pip3 install --break-system-packages python-dotenv paho-mqtt python-pidfile
WORKDIR /tmp
RUN curl -fsSL $NODE_URL | bash - && apt-get install -y nodejs && node -v
WORKDIR /
RUN git clone --depth 1 -b config_merge $PIXLET_REPO /pixlet
# RUN apt install unzip
# RUN wget $PIXLET_REPO_ZIP && unzip main.zip
# RUN mv pixlet-main pixlet
# RUN git clone --depth 1 -b config_merge $PIXLET_REPO /pixlet
RUN apt install unzip
RUN wget $PIXLET_REPO_ZIP -O pixlet-main.zip && unzip pixlet-main.zip
RUN mv pixlet-config_merge pixlet
WORKDIR /pixlet
RUN npm install && npm run build && make build

4 changes: 4 additions & 0 deletions mosquitto.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Listen on port 1883 for all network interfaces (external hosts)
listener 1883
# Allow anonymous connections (optional; for testing only)
allow_anonymous true
2 changes: 1 addition & 1 deletion tidbyt_manager/templates/manager/create.html
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ <h1>{% block title %}New Tidbyt Device{% endblock %}</h1>
{% block content %} <form method="post">
<span><label for="name">Name</label> (Descriptive name for this Tidbyt device)</span>
<input name="name" id="name" value="{{ request.form['name'] }}" required>
<span><label for="api_id">Device ID</label> (ID from Tidbyt app or mqtt url eg. mqtt://user:pass@hostname:1883/topic )</span>
<span><label for="api_id">Device ID</label> (Leave Blank is using docker-compose.) -- ID from Tidbyt app or mqtt url eg. mqtt://user:pass@hostname:1883/topic </span>
<input name="api_id" id="api_id" value="{{ request.form['api_id'] }}" required>
<span><label for="api_key">Device API KEY</label> (leave blank when using mqtt)</span>
<textarea name="api_key" id="api_key" rows="5"></textarea>

0 comments on commit 50c3af6

Please sign in to comment.