changeset 1272:298948c177ed

docker setup work but i think this is not functional yet Ignore-this: 3a295e302214cb868cb252f0748e2b5b darcs-hash:6c0058fbfe628f36eca0161d17f80363c79b603b
author drewp <drewp@bigasterisk.com>
date Sat, 20 Apr 2019 23:45:51 -0700
parents 398bd2b2490c
children 6f27fe20f6eb
files service/tradfri/Dockerfile service/tradfri/makefile service/tradfri/requirements.txt
diffstat 3 files changed, 31 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/service/tradfri/Dockerfile	Sat Apr 20 23:44:18 2019 -0700
+++ b/service/tradfri/Dockerfile	Sat Apr 20 23:45:51 2019 -0700
@@ -2,14 +2,23 @@
 
 WORKDIR /opt
 
-COPY requirements.txt ./
-RUN pip install -r requirements.txt
+RUN apt-get install -y autoconf automake libtool
+# this is https://github.com/ggravlingen/pytradfri/blob/master/script/install-coap-client.sh
+RUN \
+git clone --depth 1 --recursive -b dtls https://github.com/home-assistant/libcoap.git \
+&& cd libcoap \
+&& ./autogen.sh \
+&& ./configure --disable-documentation --disable-shared --without-debug CFLAGS="-D COAP_DEBUG_FD=stderr" \
+&& make \
+&& make install
 
-COPY pytradfri pytradfri
-COPY libcoap libcoap
+
+COPY requirements.txt ./
+RUN pip3 install -r requirements.txt
+
 COPY static static
 COPY *.py req* ./
 
 EXPOSE 10009
 
-CMD [ "python", "./tradfri.py" ]
+CMD [ "python3", "./tradfri.py" ]
--- a/service/tradfri/makefile	Sat Apr 20 23:44:18 2019 -0700
+++ b/service/tradfri/makefile	Sat Apr 20 23:45:51 2019 -0700
@@ -6,25 +6,35 @@
 build_image:
 	rm -rf tmp_ctx
 	mkdir -p tmp_ctx
-	cp -a Dockerfile ../../lib/*.py *.py req* pytradfri libcoap ../arduinoNode/static tmp_ctx
+	cp -a Dockerfile ../../lib/*.py *.py req* ../arduinoNode/static tmp_ctx
 	docker build --network=host -t ${TAG} tmp_ctx
 	docker push ${TAG}
 	rm -rf tmp_ctx
 
-shell:
-	docker run --rm -it --cap-add SYS_PTRACE --net=host ${TAG} /bin/bash
+shell: build_image
+	docker run --rm --name tradfri_shell -it --cap-add SYS_PTRACE --net=host ${TAG} /bin/bash
 
-local_run:
+local_run: build_image
 	docker run --rm -it -p ${PORT}:${PORT} \
           -v `pwd`:/mnt \
           --net=host \
           ${TAG} \
           python /mnt/${JOB}.py -v
 
-local_run_strace:
+local_run_strace: build_strace
 	docker run --rm -it -p ${PORT}:${PORT} \
           -v `pwd`:/mnt \
           --net=host \
           --cap-add SYS_PTRACE \
           ${TAG} \
           strace -f -tts 200 python /mnt/${JOB}.py -v
+
+local_run_trad_mqtt:
+	docker volume create tradfri-mqtt-data
+	docker run -d \
+	  --name tradfri-mqtt -c 'local bridge to tradfri' \
+	  --volume tradfri-mqtt-data:/data \
+	  --env TRADFRI_GATEWAY=tradfri \
+	  --env TRADFRI_PSK=`python -c 'from private import *; print hubKey'` \
+	  --env MQTT_ADDRESS=tcp://127.0.0.1:1883 \
+	  bonan/tradfri-mqtt
--- a/service/tradfri/requirements.txt	Sat Apr 20 23:44:18 2019 -0700
+++ b/service/tradfri/requirements.txt	Sat Apr 20 23:45:51 2019 -0700
@@ -2,6 +2,8 @@
 cyclone
 docopt
 python-dateutil
+pytradfri[async]==6.0.1
+
 rdflib==4.2.2
 rdflib-jsonld==0.4.0