Skip to content

Commit

Permalink
env var config
Browse files Browse the repository at this point in the history
  • Loading branch information
8cH9azbsFifZ committed Nov 17, 2023
1 parent 58bdb73 commit 1f8d168
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
0.0.10 - environment variable config
0.0.9 - add versioned json output
0.0.8 - move json duration string to mopp module (pip)
0.0.7 - topic for durations array
Expand Down
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,20 @@ ADD requirements-test.txt .
RUN pip3 install -r requirements-test.txt
ADD *.py /app/

# Configuration for UDP connections
ENV SERVER_IP "mopp_chat_server"
ENV UDP_PORT "7373"

# Configuration for Chat Server
ENV CLIENT_TIMEOUT "300"
ENV MAX_CLIENTS "100"
ENV KEEPALIVE "10"
ENV CHAT_WPM "20"

# MQTT configuration
ENV MQTT_HOST "broker.hivemq.com"
ENV MQTT_PORT "1883"
ENV MQTT_TOPIC "/moip/udp2mqtt/durations"


ENTRYPOINT [ "python3", "./udp2mqtt.py" ]
24 changes: 12 additions & 12 deletions config.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import os

# Configuration for UDP connections
SERVER_IP = "mopp_chat_server" #"127.0.0.1" # "10.101.101.14"
#SERVER_IP = "10.101.101.14" #"127.0.0.1" # ""
UDP_PORT = 7373
SERVER_IP = os.environ.get('SERVER_IP', "mopp_chat_server")
UDP_PORT = int(os.environ.get('UDP_PORT', "7373"))

# Configuration for Chat Server
CLIENT_TIMEOUT = 3000
MAX_CLIENTS = 100
KEEPALIVE = 10
CHAT_WPM = 20
CLIENT_TIMEOUT = int(os.environ.get('CLIENT_TIMEOUT', "300"))
MAX_CLIENTS = int(os.environ.get('MAX_CLIENTS', "100"))
KEEPALIVE = int(os.environ.get('KEEPALIVE', "10"))
CHAT_WPM = int(os.environ.get('CHAT_WPM', "20"))

# MQTT configuration
MQTT_HOST = "broker.hivemq.com"
MQTT_PORT = 1883

TOPIC = "/moip/udp2mqtt/mopp"
TOPICDURATIONS = "/moip/udp2mqtt/durations"
MQTT_HOST = os.environ.get('MQTT_HOST', "broker.hivemq.com")
MQTT_PORT = int(os.environ.get('MQTT_PORT', "1883"))
MQTT_TOPIC = os.environ.get('MQTT_TOPIC', "/moip/udp2mqtt/durations")

# Internal configuration with code dependencies
MORSE_JSON_VERSION = 1
14 changes: 14 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,17 @@ services:
udp2mqtt:
image: ghcr.io/morse-code-over-ip/udp2mqtt:latest
restart: always
environment:
# Configuration for UDP connections
SERVER_IP: "mopp_chat_server" #"10.101.101.14" #"127.0.0.1"
UDP_PORT: "7373"
# Configuration for Chat Server
CLIENT_TIMEOUT: "300"
MAX_CLIENTS: "100"
KEEPALIVE: "10"
CHAT_WPM: "20"
# MQTT configuration
MQTT_HOST: "broker.hivemq.com"
MQTT_PORT: "1883"
MQTT_TOPIC: "/moip/udp2mqtt/durations"

0 comments on commit 1f8d168

Please sign in to comment.