Skip to content

Commit

Permalink
Fixes and optimizes the Docker build (#206)
Browse files Browse the repository at this point in the history
This resolves issue #203 and also optimizes the Dockerfile to use less
resources. Also the current version from the Git repo is copied to
the Docker container for easy access.

I've taken the liberty to also update the DTLSSocket requirement to
version 0.1.7 which resolves an issue regarding cython. According to
their repo, nothing else has changed [1].

The RPi and RPiW Dockerfiles were not updated because of compatibility
reasons. I cannot easily test those files and do not want to break
anything.

**References**

 1. https://git.fslab.de/jkonra2m/tinydtls-cython/commits/master
  • Loading branch information
alex3305 authored and ggravlingen committed Nov 18, 2018
1 parent 506b9e8 commit 685027b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 25 deletions.
27 changes: 9 additions & 18 deletions Dockerfile
@@ -1,22 +1,13 @@
FROM debian:latest
FROM python:3.7-stretch

# https://community.home-assistant.io/t/ikea-tradfri-gateway-zigbee-very-basic-working-implementation/14788/19?u=balloob
RUN apt-get update -y && \
apt-get install -y python3 python3-pip git autoconf automake libtool && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* build/
COPY . /usr/src/app/

RUN mkdir -p /usr/src/app /usr/src/build
WORKDIR /usr/src/build

RUN python3 -m pip install --upgrade pip setuptools wheel cython

COPY ./script/install-coap-client.sh install-coap-client.sh
RUN ./install-coap-client.sh

COPY requirements.txt requirements.txt
RUN python3 -m pip install -r requirements.txt
RUN mkdir -p /usr/src/build && \
cd /usr/src/build && \
pip3 install --upgrade pip setuptools wheel cython && \
pip3 install -r /usr/src/app/requirements.txt && \
/usr/src/app/script/install-coap-client.sh && \
python /usr/src/app/setup.py install

WORKDIR /usr/src/app
ENV LANG=C.UTF-8
CMD /bin/bash

2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -87,6 +87,8 @@ Please see the example files.

There is a Docker script available to bootstrap a dev environment. Run `./script/dev_docker` and you will build and launch a container that is ready to go for both sync and async. After launching, follow the above instructions to test the library stand-alone.

The working directory of the Docker image is `/usr/src/app`. The checked out version of this repo is added there and installed as a Python dependency for easy development and testing. When you want to use the latest stable version from pip, you only have to change to another working directory.

## Acknowledgements
This is an implementation based on analysis [I](https://github.com/ggravlingen/) found [here](https://bitsex.net/software/2017/coap-endpoints-on-ikea-tradfri/) by [vidarlo](https://bitsex.net/).

Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
@@ -1,3 +1,3 @@
aiocoap==0.4a1
DTLSSocket==0.1.4
typing>=3,<4
DTLSSocket==0.1.7
typing>=3,<4
7 changes: 2 additions & 5 deletions script/dev_docker
Expand Up @@ -19,9 +19,6 @@ case "$MACHINE" in
esac

docker build -t tradfri-dev -f "$PWD/$DOCKERFILE" .
docker run -it --rm -v `pwd`:/usr/src/app -v /etc/localtime:/etc/localtime:ro \
--net=host tradfri-dev bash

docker run \
--net=host \
-v /etc/localtime:/etc/localtime:ro \
-v `pwd`:/usr/src/app \
-t -i --rm tradfri-dev

0 comments on commit 685027b

Please sign in to comment.