it can now run in a docker container. YEEEY

This commit is contained in:
DasMoorhuhn 2024-05-30 17:26:54 +02:00
parent 837807c066
commit 42248456d8
6 changed files with 46 additions and 3 deletions

16
Dockerfile Normal file
View File

@ -0,0 +1,16 @@
FROM python:3.12
WORKDIR = /src
COPY python/src/ .
COPY python/requierements.txt .
COPY python/docker_entrypoint.sh /
RUN mkdir data
RUN apt-get update && \
apt-get install -y bluez sudo
RUN pip3.12 install -r requierements.txt && rm -f requierements.txt
ENTRYPOINT sh /docker_entrypoint.sh

View File

@ -41,3 +41,14 @@ Run Gateway
cd python/src cd python/src
sudo python3 main.py sudo python3 main.py
``` ```
### Docker
Build docker container
```bash
docker-compose build
```
Run docker container. Killing the hosts bluetooth service is needed to access it from the docker container.
```bash
sudo sh run_docker.sh
```

View File

@ -1,6 +1,7 @@
version: '3.3' version: '3'
services: services:
atc_mithermometer_gateway: atc_mithermometer_gateway:
image: atc-mithermometer-gateway:develop image: atc-mithermometer-gateway:develop
container_name: ATC_MiThermometer_Gateway container_name: ATC_MiThermometer_Gateway
build: .

View File

@ -1,2 +0,0 @@
FROM python:3.12-alpine3.20

View File

@ -0,0 +1,8 @@
#!/bin/bash
service dbus start
bluetoothd &
/bin/bash
sudo python3 main.py

9
run_docker.sh Normal file
View File

@ -0,0 +1,9 @@
sudo killall -9 bluetoothd
docker stop atc-mithermometer-gateway:develop
docker run \
--cap-add=SYS_ADMIN \
--cap-add=NET_ADMIN \
--net=host \
-v /var/run/dbus/:/var/run/dbus/ \
-v /path/to/data:/src/data \
atc-mithermometer-gateway:develop