mirror of
https://github.com/TheCommsChannel/TC2-BBS-mesh.git
synced 2025-04-20 07:16:06 -04:00
Added docker support
This commit is contained in:
parent
af95c0175b
commit
46c38748cf
14
Dockerfile
Normal file
14
Dockerfile
Normal file
@ -0,0 +1,14 @@
|
||||
FROM python:3.8
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN chmod +x /app/entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||
|
||||
CMD ["python", "-u", "server.py"]
|
16
README.md
16
README.md
@ -48,7 +48,9 @@ source venv/bin/activate
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
5. Set up the configuration in `config.ini`:
|
||||
5. Configuration
|
||||
- Copy config/config.init.sample to config/config.ini
|
||||
- Set up the configuration in `config.ini`:
|
||||
|
||||
**[interface]**
|
||||
|
||||
@ -73,7 +75,7 @@ pip install -r requirements.txt
|
||||
```ini
|
||||
[interface]
|
||||
type = serial
|
||||
# port = /dev/ttyUSB0
|
||||
# port = /dev/ttyUSB0 # or /dev/ttyACM0
|
||||
# hostname = 192.168.x.x
|
||||
|
||||
[sync]
|
||||
@ -90,6 +92,16 @@ python server.py
|
||||
|
||||
Be sure you've followed the Python virtual environment steps above and activated it before running.
|
||||
|
||||
## Docker
|
||||
The docker entrypoint.sh will automatically copy config.ini.sample to config.ini
|
||||
if you want to edit config, make sure you add the config directory as a docker volume.
|
||||
|
||||
```sh
|
||||
docker run -it --name tc2bbsmesh -v tc2bbsmesh-config:/config/ -v tc2bbsmesh-data:/data/ --device=/dev/ttyACM0 tc2-bbs-mesh
|
||||
```
|
||||
|
||||
Tested on Orange Pi 3 LTS (Armbian), but should work on all linux distros.
|
||||
|
||||
## Features
|
||||
|
||||
- **Mail System**: Send and receive mail messages.
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
[interface]
|
||||
type = serial
|
||||
# port = /dev/ttyUSB0
|
||||
# port = /dev/ttyACM0
|
||||
# hostname = 192.168.x.x
|
||||
|
||||
|
@ -2,11 +2,12 @@ import configparser
|
||||
import time
|
||||
import meshtastic.serial_interface
|
||||
import meshtastic.tcp_interface
|
||||
import os
|
||||
import serial.tools.list_ports
|
||||
|
||||
def initialize_config():
|
||||
config = configparser.ConfigParser()
|
||||
config.read('config.ini')
|
||||
config.read(os.getenv('CONFIG_FILE', 'config/config.ini'))
|
||||
|
||||
interface_type = config['interface']['type']
|
||||
hostname = config['interface'].get('hostname', None)
|
||||
|
@ -1,4 +1,5 @@
|
||||
import logging
|
||||
import os
|
||||
import sqlite3
|
||||
import threading
|
||||
import uuid
|
||||
@ -16,7 +17,7 @@ thread_local = threading.local()
|
||||
|
||||
def get_db_connection():
|
||||
if not hasattr(thread_local, 'connection'):
|
||||
thread_local.connection = sqlite3.connect('bulletins.db')
|
||||
thread_local.connection = sqlite3.connect(os.getenv('DB_FILE', 'data/bulletins.db'))
|
||||
return thread_local.connection
|
||||
|
||||
def initialize_database():
|
||||
|
23
entrypoint.sh
Normal file
23
entrypoint.sh
Normal file
@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
CONFIG_DIR=/app/config
|
||||
CONFIG_FILE=$CONFIG_DIR/config.ini
|
||||
SAMPLE_FILE=config.ini.sample
|
||||
|
||||
# Create the config directory if it does not exist
|
||||
mkdir -p $CONFIG_DIR
|
||||
|
||||
# Check if the config file exists, if not, copy the sample file
|
||||
if [ ! -f $CONFIG_FILE ]; then
|
||||
if [ -f $SAMPLE_FILE ]; then
|
||||
cp $SAMPLE_FILE $CONFIG_FILE
|
||||
echo "Copied $SAMPLE_FILE to $CONFIG_FILE"
|
||||
else
|
||||
echo "Sample file $SAMPLE_FILE does not exist. Please provide a sample file."
|
||||
fi
|
||||
else
|
||||
echo "Config file $CONFIG_FILE already exists."
|
||||
fi
|
||||
|
||||
exec "$@"
|
Loading…
x
Reference in New Issue
Block a user