From 3db18fff4c1c5104cc78c9c72304335c227087ed Mon Sep 17 00:00:00 2001 From: Martin Hjelmare Date: Fri, 23 Dec 2022 12:34:21 +0100 Subject: [PATCH] Add docker files (#139) --- Dockerfile.dev | 50 ++++++++++++++++++++++++++++++++++++++++++++ README.md | 15 +++++++++++++ docker-compose.yml | 19 +++++++++++++++++ docker-entrypoint.sh | 7 +++++++ 4 files changed, 91 insertions(+) create mode 100644 Dockerfile.dev create mode 100644 docker-compose.yml create mode 100755 docker-entrypoint.sh diff --git a/Dockerfile.dev b/Dockerfile.dev new file mode 100644 index 00000000..84f49ab9 --- /dev/null +++ b/Dockerfile.dev @@ -0,0 +1,50 @@ +FROM debian:bullseye as base + +# Set shell +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +ARG MATTER_SERVER_VERSION=1.0.7 +ARG HOME_ASSISTANT_CHIP_VERSION=2022.11.1 + +WORKDIR /app + +RUN \ + set -x \ + && apt-get update \ + && apt-get install -y --no-install-recommends \ + libuv1 \ + openssl \ + zlib1g \ + libjson-c5 \ + python3-venv \ + python3-pip \ + python3-gi \ + python3-gi-cairo \ + python3-dbus \ + python3-psutil \ + unzip \ + libcairo2 \ + gdb \ + git \ + && git clone --depth 1 -b master \ + https://github.com/project-chip/connectedhomeip \ + && cp -r connectedhomeip/credentials /root/credentials \ + && rm -rf connectedhomeip \ + && apt-get purge -y --auto-remove \ + git \ + && rm -rf /var/lib/apt/lists/* \ + && rm -rf /usr/src/* + +# hadolint ignore=DL3013 +RUN \ + pip3 install \ + home-assistant-chip-clusters==${HOME_ASSISTANT_CHIP_VERSION} \ + home-assistant-chip-core==${HOME_ASSISTANT_CHIP_VERSION} \ + && pip3 install --no-cache-dir python-matter-server=="${MATTER_SERVER_VERSION}" + +COPY docker-entrypoint.sh ./ + +VOLUME ["/data"] +EXPOSE 5580 + +ENTRYPOINT ["./docker-entrypoint.sh"] diff --git a/README.md b/README.md index 1cbb72c1..e9808f2a 100644 --- a/README.md +++ b/README.md @@ -159,3 +159,18 @@ Please note that development is only possible on Linux and MacOS, no Windows sup - Download/clone the repo to your local machine. - Create a Python virtual environment. - Install the correct SDK wheels for both the cluster and core package, see instructions above if there is no wheel for your setup prebuilt. + +## Dockerfile + +### Build + +```sh +docker-compose build --no-cache matter-server +``` + +### Run + +```sh +docker-compose up -d matter-server +docker-compose logs -f matter-server +``` diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..d1ccc47c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,19 @@ +version: "3.8" +services: + # python-matter-server + matter-server: + build: + context: ./ + dockerfile: Dockerfile.dev + image: matter-server:latest + container_name: matter-server + restart: always + security_opt: + # needed for bluetooth via dbus + - apparmor:unconfined + ports: + - "5580:5580" + volumes: + # Create an .env file that sets the USERDIR environment variable. + - ${USERDIR}/docker/matter-server/data:/data/ + - /run/dbus:/run/dbus:ro diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100755 index 00000000..35106a28 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/sh +set -e + +set -- matter-server --storage-path /data "$@" + +echo "Starting server:" "$@" +exec "$@"